Skip to content

Commit ceec91b

Browse files
committed
refactor(map): Attributtions correctly updated
chore: Syncronized actions to match private implementations
1 parent aac49fe commit ceec91b

5 files changed

Lines changed: 103 additions & 45 deletions

File tree

.github/actions/changelog/action.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,12 @@ runs:
238238
ENTRY_SUFFIX="($COMMIT_LINK by $contributors)"
239239
240240
# Process subject line
241-
if [[ "$message" =~ $CONV_REGEX ]]; then
241+
if [[ "$message" =~ ^BREAKING[\ -]CHANGE:[[:space:]]*.+ ]]; then
242+
# Subject line is a breaking change declaration
243+
BREAKING_DESC=$(echo "$message" | sed -E 's/^BREAKING[ -]CHANGE:[[:space:]]*//')
244+
[ ! -f /tmp/breaking.txt ] && echo "### 🚨 Breaking Changes" > /tmp/breaking.txt
245+
echo "- $BREAKING_DESC $ENTRY_SUFFIX" >> /tmp/breaking.txt
246+
elif [[ "$message" =~ $CONV_REGEX ]]; then
242247
categorize_line "$message" "$ENTRY_SUFFIX"
243248
else
244249
[ ! -f /tmp/changes.txt ] && echo "### 📝 Changes" > /tmp/changes.txt
@@ -288,6 +293,23 @@ runs:
288293
echo "- No changes detected" > changelog.txt
289294
fi
290295
296+
# Generate diff stats
297+
DIFFSTAT=$(git diff --shortstat ${FROM_REF}..${TO_REF} 2>/dev/null || true)
298+
if [ -n "$DIFFSTAT" ]; then
299+
FILES_CHANGED=$(echo "$DIFFSTAT" | sed -E 's/^ *([0-9]+) files? changed.*/\1/')
300+
INSERTIONS=$(echo "$DIFFSTAT" | grep -oE '[0-9]+ insertions?' | grep -oE '[0-9]+' || echo "0")
301+
DELETIONS=$(echo "$DIFFSTAT" | grep -oE '[0-9]+ deletions?' | grep -oE '[0-9]+' || echo "0")
302+
303+
{
304+
echo "### 📊 Diff Stats"
305+
echo "| Metric | Count |"
306+
echo "|--------|------:|"
307+
echo "| 📄 Files changed | ${FILES_CHANGED} |"
308+
echo "| 🟢 Insertions | \$\\color{green}\\textsf{+${INSERTIONS}}\$ |"
309+
echo "| 🔴 Deletions | \$\\color{red}\\textsf{-${DELETIONS}}\$ |"
310+
} > diffstats.txt
311+
fi
312+
291313
- name: Format Changelog
292314
if: ${{ steps.check-skip.outputs.skip != 'true' }}
293315
id: format
@@ -307,6 +329,10 @@ runs:
307329
echo ""
308330
cat changelog.txt
309331
echo ""
332+
if [ -f diffstats.txt ]; then
333+
cat diffstats.txt
334+
echo ""
335+
fi
310336
echo "---"
311337
echo ""
312338
echo "<sub>🤖 Auto-generated by changelog workflow</sub>"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 7.5.17
4+
5+
- Updated attributions on `ThemedTileLayer` for OpenStreetMaps.
6+
37
## 7.5.16
48

59
- Native support for `TZDateTime` on Date and DateTime pickers.

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ packages:
390390
path: ".."
391391
relative: true
392392
source: path
393-
version: "7.5.16"
393+
version: "7.5.17"
394394
leak_tracker:
395395
dependency: transitive
396396
description:

lib/src/map/src/layers/tile.dart

Lines changed: 69 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class _ThemedTileLayerState extends State<ThemedTileLayer> {
7979
bool get isDark => Theme.of(context).brightness == .dark;
8080

8181
String get _osmUrl => 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
82-
// String get _osmUrl => 'http://127.0.0.1:5000/{z}/{x}/{y}.png';
8382

8483
String get _mapboxUrl {
8584
if (layer.source != .mapbox) return _osmUrl;
@@ -225,7 +224,6 @@ class _ThemedTileLayerState extends State<ThemedTileLayer> {
225224
}
226225

227226
String get _layrzAttributionLight => 'https://cdn.layrz.com/resources/layrz/logo/normal.png';
228-
// String get _layrzAttributionDark => 'https://cdn.layrz.com/resources/layrz/logo/white.png';
229227

230228
String get _mapboxAttributionLight => 'https://cdn.layrz.com/resources/map_attributions/mapbox_maps/normal.png';
231229
String get _mapboxAttributionDark => 'https://cdn.layrz.com/resources/map_attributions/mapbox_maps/white.png';
@@ -266,46 +264,90 @@ class _ThemedTileLayerState extends State<ThemedTileLayer> {
266264
}
267265
: {};
268266

269-
TileLayer _buildTile({required String urlTemplate}) {
270-
return TileLayer(
271-
urlTemplate: urlTemplate,
272-
minZoom: widget.minZoom,
273-
maxZoom: widget.maxZoom,
274-
minNativeZoom: widget.minZoom.toInt(),
275-
maxNativeZoom: widget.maxZoom.toInt(),
276-
tileProvider: NetworkTileProvider(
277-
headers: headers,
278-
279-
/// Setting for the previous CancellableNetworkTileProvider
280-
abortObsoleteRequests: widget.isCancellable,
281-
),
282-
283-
keepBuffer: buffer,
284-
panBuffer: buffer,
285-
);
267+
String _googleUrl = '';
268+
String get _urlTemplate {
269+
switch (layer.source) {
270+
case .osm:
271+
return _osmUrl;
272+
case .mapbox:
273+
return _mapboxUrl;
274+
case .here:
275+
return _hereUrl;
276+
case .google:
277+
return _googleUrl;
278+
case .custom:
279+
return _customUrl;
280+
}
281+
}
282+
283+
@override
284+
void initState() {
285+
super.initState();
286+
if (layer.source == MapSource.google) _initializeGoogleMaps();
287+
}
288+
289+
@override
290+
void didUpdateWidget(covariant ThemedTileLayer oldWidget) {
291+
super.didUpdateWidget(oldWidget);
292+
293+
if (oldWidget.layer?.id != widget.layer?.id && layer.source == MapSource.google) {
294+
_initializeGoogleMaps();
295+
}
296+
}
297+
298+
Future<void> _initializeGoogleMaps() async {
299+
setState(() => _googleUrl = '');
300+
String? url = await _fetchGoogleAuth(layer: layer);
301+
if (url != null) setState(() => _googleUrl = url);
286302
}
287303

288304
@override
289305
Widget build(BuildContext context) {
290306
return Stack(
291307
children: [
308+
if (_urlTemplate.isNotEmpty) ...[
309+
TileLayer(
310+
urlTemplate: _urlTemplate,
311+
minZoom: widget.minZoom,
312+
maxZoom: widget.maxZoom,
313+
minNativeZoom: widget.minZoom.toInt(),
314+
maxNativeZoom: widget.maxZoom.toInt(),
315+
tileProvider: NetworkTileProvider(
316+
headers: headers,
317+
318+
/// Setting for the previous CancellableNetworkTileProvider
319+
abortObsoleteRequests: widget.isCancellable,
320+
),
321+
322+
keepBuffer: buffer,
323+
panBuffer: buffer,
324+
),
325+
],
292326
if (layer.source == .osm) ...[
293-
_buildTile(urlTemplate: _osmUrl),
294327
Align(
295328
alignment: .bottomLeft,
296329
child: Padding(
297330
padding: const .all(10),
298-
child: Image.network(
299-
_layrzAttributionLight,
300-
width: 80,
301-
height: 20,
302-
filterQuality: .medium,
303-
alignment: .centerLeft,
331+
child: Container(
332+
decoration: generateContainerElevation(context: context, elevation: 0),
333+
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2.5),
334+
child: RichText(
335+
text: TextSpan(
336+
style: Theme.of(context).textTheme.bodySmall,
337+
children: [
338+
TextSpan(text: "Map data from"),
339+
TextSpan(
340+
text: " OpenStreetMap ",
341+
style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: .bold),
342+
),
343+
TextSpan(text: "and their contributors"),
344+
],
345+
),
346+
),
304347
),
305348
),
306349
),
307350
] else if (layer.source == .mapbox) ...[
308-
_buildTile(urlTemplate: _mapboxUrl),
309351
Align(
310352
alignment: .bottomLeft,
311353
child: Padding(
@@ -320,7 +362,6 @@ class _ThemedTileLayerState extends State<ThemedTileLayer> {
320362
),
321363
),
322364
] else if (layer.source == MapSource.here) ...[
323-
_buildTile(urlTemplate: _hereUrl),
324365
Align(
325366
alignment: Alignment.bottomLeft,
326367
child: Padding(
@@ -335,18 +376,6 @@ class _ThemedTileLayerState extends State<ThemedTileLayer> {
335376
),
336377
),
337378
] else if (layer.source == .google) ...[
338-
FutureBuilder<String?>(
339-
future: _fetchGoogleAuth(layer: layer),
340-
builder: (context, snapshot) {
341-
if (snapshot.hasData) {
342-
if (snapshot.data != null) {
343-
return _buildTile(urlTemplate: snapshot.data!);
344-
}
345-
}
346-
347-
return const SizedBox.expand();
348-
},
349-
),
350379
Align(
351380
alignment: .bottomLeft,
352381
child: Padding(
@@ -361,7 +390,6 @@ class _ThemedTileLayerState extends State<ThemedTileLayer> {
361390
),
362391
),
363392
] else ...[
364-
_buildTile(urlTemplate: _customUrl),
365393
Align(
366394
alignment: .bottomLeft,
367395
child: Padding(

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: layrz_theme
22
description: Layrz standard styling library for Flutter. Widget library following the Material Design 3 guidelines, with a focus on reliavility and functionality.
3-
version: "7.5.16"
3+
version: "7.5.17"
44
homepage: https://theme.layrz.com
55
repository: https://github.com/goldenm-software/layrz_theme
66

@@ -40,7 +40,7 @@ dependencies:
4040
two_dimensional_scrollables: ^0.3.4
4141
sync_scroll_controller: ^1.0.1
4242
web: ^1.1.0
43-
flutter_map: ^8.2.1
43+
flutter_map: ^8.2.2
4444
flutter_highlight: ^0.7.0
4545
highlight: ^0.7.0
4646
code_text_field: ^1.1.0

0 commit comments

Comments
 (0)