Skip to content

Commit ed93fb0

Browse files
juaoosetobiasleijs
authored andcommitted
feat: add colorScheme parameter
1 parent 2848c56 commit ed93fb0

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

ios/Classes/MapView/FlutterMapView.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class FlutterMapView: MKMapView, UIGestureRecognizerDelegate {
2020
var oldBounds: CGRect?
2121
var options: Dictionary<String, Any>?
2222
var isMyLocationButtonShowing: Bool? = false
23+
var mapStyle: Int? = 0
2324

2425
fileprivate let locationManager: CLLocationManager = CLLocationManager()
2526

@@ -144,6 +145,14 @@ class FlutterMapView: MKMapView, UIGestureRecognizerDelegate {
144145
if let mapType: Int = options["mapType"] as? Int {
145146
self.mapType = self.mapTypes[mapType]
146147
}
148+
149+
if let mapStyle: Int = options["mapStyle"] as? Int {
150+
if #available(iOS 13.0, *) {
151+
if mapStyle != 0 {
152+
self.overrideUserInterfaceStyle = UIUserInterfaceStyle(rawValue: mapStyle) ?? .unspecified
153+
}
154+
}
155+
}
147156

148157
if let trafficEnabled: Bool = options["trafficEnabled"] as? Bool {
149158
if #available(iOS 9.0, *) {

lib/src/apple_map.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class AppleMap extends StatefulWidget {
2323
this.compassEnabled = true,
2424
this.trafficEnabled = false,
2525
this.mapType = MapType.standard,
26+
this.mapStyle = MapStyle.system,
2627
this.minMaxZoomPreference = MinMaxZoomPreference.unbounded,
2728
this.trackingMode = TrackingMode.none,
2829
this.rotateGesturesEnabled = true,
@@ -59,6 +60,9 @@ class AppleMap extends StatefulWidget {
5960
/// Type of map tiles to be rendered.
6061
final MapType mapType;
6162

63+
/// TODO
64+
final MapStyle mapStyle;
65+
6266
/// The mode used to track the user location.
6367
final TrackingMode trackingMode;
6468

@@ -332,6 +336,7 @@ class _AppleMapOptions {
332336
this.compassEnabled,
333337
this.trafficEnabled,
334338
this.mapType,
339+
this.mapStyle,
335340
this.minMaxZoomPreference,
336341
this.rotateGesturesEnabled,
337342
this.scrollGesturesEnabled,
@@ -349,6 +354,7 @@ class _AppleMapOptions {
349354
compassEnabled: map.compassEnabled,
350355
trafficEnabled: map.trafficEnabled,
351356
mapType: map.mapType,
357+
mapStyle: map.mapStyle,
352358
minMaxZoomPreference: map.minMaxZoomPreference,
353359
rotateGesturesEnabled: map.rotateGesturesEnabled,
354360
scrollGesturesEnabled: map.scrollGesturesEnabled,
@@ -368,6 +374,8 @@ class _AppleMapOptions {
368374

369375
final MapType? mapType;
370376

377+
final MapStyle? mapStyle;
378+
371379
final MinMaxZoomPreference? minMaxZoomPreference;
372380

373381
final bool? rotateGesturesEnabled;
@@ -400,6 +408,7 @@ class _AppleMapOptions {
400408
addIfNonNull('compassEnabled', compassEnabled);
401409
addIfNonNull('trafficEnabled', trafficEnabled);
402410
addIfNonNull('mapType', mapType?.index);
411+
addIfNonNull('mapStyle', mapStyle?.index);
403412
addIfNonNull('minMaxZoomPreference', minMaxZoomPreference?._toJson());
404413
addIfNonNull('rotateGesturesEnabled', rotateGesturesEnabled);
405414
addIfNonNull('scrollGesturesEnabled', scrollGesturesEnabled);

lib/src/ui.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ enum MapType {
1616
hybrid,
1717
}
1818

19+
enum MapStyle {
20+
/// Follow system style
21+
system,
22+
23+
light,
24+
dark,
25+
}
26+
1927
enum TrackingMode {
2028
// the user's location is not followed
2129
none,

0 commit comments

Comments
 (0)