Skip to content

Commit

Permalink
Flip automaticallyAdjustsContentInset to avoid contentInsets edit war
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthetechie committed Aug 1, 2024
1 parent 5135853 commit 1e6f079
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/MapLibreSwiftUI/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public struct MapView<T: MapViewHostViewController>: UIViewControllerRepresentab
var onStyleLoaded: ((MLNStyle) -> Void)?
var onViewPortChanged: ((MapViewPort) -> Void)?

public var mapViewContentInset: UIEdgeInsets = .zero
var mapViewContentInset: UIEdgeInsets? = .zero

var unsafeMapViewControllerModifier: ((T) -> Void)?

Expand Down Expand Up @@ -103,13 +103,16 @@ public struct MapView<T: MapViewHostViewController>: 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
Expand Down

0 comments on commit 1e6f079

Please sign in to comment.