[ios] The viewport is calculated using the safe area insets

Instead of manual origin and frame calculation. It fixes the issue when the location arrow and road are not centered while navigation.

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn
2025-09-15 19:09:27 +04:00
committed by Yannik Bloscheck
parent 47f16c5b89
commit 8520f32f2d

View File

@@ -173,28 +173,11 @@ final class CarPlayMapViewController: MWMViewController {
}
private func updateVisibleViewPortToPreviewState() {
let viewBounds = view.bounds
let previewWidth = self.view.frame.width * 0.45
let navigationHeight: CGFloat = 45.0
var frame = CGRect.zero
let origin = isLeftWheelCar ? CGPoint(x: previewWidth, y: navigationHeight) : CGPoint(x: 0, y: navigationHeight)
frame.origin = origin
frame.size = CGSize(width: viewBounds.width - origin.x,
height: viewBounds.height - origin.y)
updateVisibleViewPort(frame: frame)
updateVisibleViewPort(frame: view.frame.inset(by: view.safeAreaInsets))
}
private func updateVisibleViewPortToNavigationState() {
let viewBounds = view.bounds
let previewWidth = viewBounds.width * 0.45
let mapControlsWidth = viewBounds.width * 0.15
let navigationHeight: CGFloat = 45.0
var frame = CGRect.zero
let origin = isLeftWheelCar ? CGPoint(x: previewWidth, y: navigationHeight) : CGPoint(x: 0, y: navigationHeight)
frame.origin = origin
frame.size = CGSize(width: viewBounds.width - (origin.x + mapControlsWidth),
height: viewBounds.height - origin.y)
updateVisibleViewPort(frame: frame)
updateVisibleViewPort(frame: view.frame.inset(by: view.safeAreaInsets))
}
private func updateVisibleViewPortToDefaultState() {