From 1e6f079ea03687a43743da64000b3ad25fc744ae Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 1 Aug 2024 09:21:54 +0900 Subject: [PATCH] Flip automaticallyAdjustsContentInset to avoid contentInsets edit war --- Sources/MapLibreSwiftUI/MapView.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/MapLibreSwiftUI/MapView.swift b/Sources/MapLibreSwiftUI/MapView.swift index 8802e15..7fe949e 100644 --- a/Sources/MapLibreSwiftUI/MapView.swift +++ b/Sources/MapLibreSwiftUI/MapView.swift @@ -18,7 +18,7 @@ public struct MapView: UIViewControllerRepresentab var onStyleLoaded: ((MLNStyle) -> Void)? var onViewPortChanged: ((MapViewPort) -> Void)? - public var mapViewContentInset: UIEdgeInsets = .zero + var mapViewContentInset: UIEdgeInsets? = .zero var unsafeMapViewControllerModifier: ((T) -> Void)? @@ -103,13 +103,16 @@ public struct MapView: UIViewControllerRepresentab if cameraDisabled == false { context.coordinator.updateCamera(mapView: uiViewController.mapView, - camera: $camera.wrappedValue, + camera: camera, animated: isStyleLoaded) } } @MainActor private func applyModifiers(_ mapViewController: T, runUnsafe: Bool) { - mapViewController.mapView.contentInset = mapViewContentInset + if let mapViewContentInset { + mapViewController.mapView.automaticallyAdjustsContentInset = false + mapViewController.mapView.contentInset = mapViewContentInset + } // Assume all controls are hidden by default (so that an empty list returns a map with no controls) mapViewController.mapView.logoView.isHidden = true