From 5bc0f0b141a4b5adf020b68406259738ba87eef1 Mon Sep 17 00:00:00 2001 From: zuvola Date: Sun, 28 Aug 2022 07:25:50 +0900 Subject: [PATCH 1/3] Adds insetsLayoutMarginsFromSafeArea param --- example/lib/scrolling_map.dart | 2 ++ ios/Classes/MapView/FlutterMapView.swift | 7 +++++++ lib/src/apple_map.dart | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/example/lib/scrolling_map.dart b/example/lib/scrolling_map.dart index 54c4fef..4b6143a 100644 --- a/example/lib/scrolling_map.dart +++ b/example/lib/scrolling_map.dart @@ -29,6 +29,7 @@ class ScrollingMapBody extends StatelessWidget { @override Widget build(BuildContext context) { return SafeArea( + bottom: false, child: ListView( children: [ Card( @@ -99,6 +100,7 @@ class ScrollingMapBody extends StatelessWidget { () => ScaleGestureRecognizer(), ), ].toSet(), + insetsLayoutMarginsFromSafeArea: false, ), ), ), diff --git a/ios/Classes/MapView/FlutterMapView.swift b/ios/Classes/MapView/FlutterMapView.swift index 628d533..1e733ed 100644 --- a/ios/Classes/MapView/FlutterMapView.swift +++ b/ios/Classes/MapView/FlutterMapView.swift @@ -194,6 +194,13 @@ class FlutterMapView: MKMapView, UIGestureRecognizerDelegate { self.maxZoomLevel = _maxZoom } } + + if let insetsSafeArea: Bool = options["insetsLayoutMarginsFromSafeArea"] as? Bool { + if #available(iOS 11.0, *) { + self.insetsLayoutMarginsFromSafeArea = insetsSafeArea + } + } + } func setUserLocation() { diff --git a/lib/src/apple_map.dart b/lib/src/apple_map.dart index 5ca5191..793a269 100644 --- a/lib/src/apple_map.dart +++ b/lib/src/apple_map.dart @@ -42,6 +42,7 @@ class AppleMap extends StatefulWidget { this.onTap, this.onLongPress, this.snapshotOptions, + this.insetsLayoutMarginsFromSafeArea = true, }) : super(key: key); final MapCreatedCallback? onMapCreated; @@ -165,6 +166,10 @@ class AppleMap extends StatefulWidget { final SnapshotOptions? snapshotOptions; + /// A Boolean value indicating whether the view's layout margins are updated + /// automatically to reflect the safe area. + final bool insetsLayoutMarginsFromSafeArea; + @override State createState() => _AppleMapState(); } @@ -336,6 +341,7 @@ class _AppleMapOptions { this.myLocationEnabled, this.myLocationButtonEnabled, this.padding, + this.insetsLayoutMarginsFromSafeArea, }); static _AppleMapOptions fromWidget(AppleMap map) { @@ -352,6 +358,7 @@ class _AppleMapOptions { myLocationEnabled: map.myLocationEnabled, myLocationButtonEnabled: map.myLocationButtonEnabled, padding: map.padding, + insetsLayoutMarginsFromSafeArea: map.insetsLayoutMarginsFromSafeArea, ); } @@ -379,6 +386,8 @@ class _AppleMapOptions { final EdgeInsets? padding; + final bool? insetsLayoutMarginsFromSafeArea; + Map toMap() { final Map optionsMap = {}; @@ -400,6 +409,8 @@ class _AppleMapOptions { addIfNonNull('myLocationEnabled', myLocationEnabled); addIfNonNull('myLocationButtonEnabled', myLocationButtonEnabled); addIfNonNull('padding', _serializePadding(padding)); + addIfNonNull( + 'insetsLayoutMarginsFromSafeArea', insetsLayoutMarginsFromSafeArea); return optionsMap; } From 9d5dee52089ac35e3349dec023f78a097f46d2cd Mon Sep 17 00:00:00 2001 From: zuvola Date: Sun, 28 Aug 2022 07:27:41 +0900 Subject: [PATCH 2/3] fix: Odd movement of the Apple logo --- ios/Classes/MapView/AppleMapController.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ios/Classes/MapView/AppleMapController.swift b/ios/Classes/MapView/AppleMapController.swift index 300f647..455590c 100644 --- a/ios/Classes/MapView/AppleMapController.swift +++ b/ios/Classes/MapView/AppleMapController.swift @@ -9,6 +9,7 @@ import Foundation import MapKit public class AppleMapController: NSObject, FlutterPlatformView { + var contentView: UIView var mapView: FlutterMapView var registrar: FlutterPluginRegistrar var channel: FlutterMethodChannel @@ -25,6 +26,11 @@ public class AppleMapController: NSObject, FlutterPlatformView { self.mapView = FlutterMapView(channel: channel, options: options) self.registrar = registrar + // To stop the odd movement of the Apple logo. + self.contentView = UIScrollView() + self.contentView.addSubview(mapView) + mapView.autoresizingMask = [.flexibleHeight, .flexibleWidth] + self.initialCameraPosition = args["initialCameraPosition"]! as! Dictionary super.init() @@ -56,7 +62,7 @@ public class AppleMapController: NSObject, FlutterPlatformView { } public func view() -> UIView { - return mapView + return contentView } private func setMethodCallHandlers() { From 150065eddeef0bc76fa3e3fb17a64af651dd6155 Mon Sep 17 00:00:00 2001 From: zuvola Date: Sun, 28 Aug 2022 07:31:42 +0900 Subject: [PATCH 3/3] chore: Bump Version + Update CHANGELOG --- CHANGELOG.md | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e06899..392959a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.2.1 + +* Fixed an issue where onCameraMove was not invoked by double-tapping +* Added insetsLayoutMarginsFromSafeArea + ## 1.2.0 * Added a `markerAnnotationWithHue()` and `pinAnnotationWithHue()` method to allow custom marker/pin colors diff --git a/pubspec.yaml b/pubspec.yaml index 522be5f..b90629a 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.2.0 +version: 1.2.1 homepage: https://luisthein.de repository: https://github.com/LuisThein/apple_maps_flutter issue_tracker: https://github.com/LuisThein/apple_maps_flutter/issues