diff --git a/CHANGELOG.md b/CHANGELOG.md index eb3e9a3..10c66b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.4.0 + +* Add option to set a `colorScheme` for the map (system, light, dark) + ## 1.3.0 * Animate marker position changes instead of removing and re-adding diff --git a/lib/src/apple_map.dart b/lib/src/apple_map.dart index a4dcce6..a94bd6c 100644 --- a/lib/src/apple_map.dart +++ b/lib/src/apple_map.dart @@ -192,7 +192,7 @@ class _AppleMapState extends State { Widget build(BuildContext context) { final Map creationParams = { 'initialCameraPosition': widget.initialCameraPosition._toMap(), - 'options': _appleMapOptions.toMap(), + 'options': _appleMapOptions.toMap(context: context), 'annotationsToAdd': _serializeAnnotationSet(widget.annotations), 'polylinesToAdd': _serializePolylineSet(widget.polylines), 'polygonsToAdd': _serializePolygonSet(widget.polygons), @@ -396,7 +396,7 @@ class _AppleMapOptions { final bool? insetsLayoutMarginsFromSafeArea; - Map toMap() { + Map toMap({BuildContext? context}) { final Map optionsMap = {}; void addIfNonNull(String fieldName, dynamic value) { @@ -405,10 +405,22 @@ class _AppleMapOptions { } } + if (context != null) { + final systemScheme = Theme.of(context).brightness == Brightness.dark + ? MapColorScheme.dark + : MapColorScheme.light; + addIfNonNull( + 'colorScheme', + colorScheme == MapColorScheme.system + ? systemScheme.index + : colorScheme?.index); + } else { + addIfNonNull('colorScheme', colorScheme?.index); + } + addIfNonNull('compassEnabled', compassEnabled); addIfNonNull('trafficEnabled', trafficEnabled); addIfNonNull('mapType', mapType?.index); - addIfNonNull('colorScheme', colorScheme?.index); addIfNonNull('minMaxZoomPreference', minMaxZoomPreference?._toJson()); addIfNonNull('rotateGesturesEnabled', rotateGesturesEnabled); addIfNonNull('scrollGesturesEnabled', scrollGesturesEnabled); diff --git a/lib/src/ui.dart b/lib/src/ui.dart index 9c2235b..5fac373 100644 --- a/lib/src/ui.dart +++ b/lib/src/ui.dart @@ -19,8 +19,8 @@ enum MapType { enum MapColorScheme { /// Follow system style system, - - light, + + light, dark, } diff --git a/pubspec.yaml b/pubspec.yaml index ff7ca9e..168fba9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: apple_maps_flutter description: This plugin uses the Flutter platform view to display an Apple Maps widget. -version: 1.3.0 +version: 1.4.0 homepage: https://luisthein.de repository: https://github.com/LuisThein/apple_maps_flutter issue_tracker: https://github.com/LuisThein/apple_maps_flutter/issues