From 8520f32f2df51b0c02225017f26401b818ebecb5 Mon Sep 17 00:00:00 2001 From: Kiryl Kaveryn Date: Mon, 15 Sep 2025 19:09:27 +0400 Subject: [PATCH] [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 --- .../UI/CarPlay/CarPlayMapViewController.swift | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift b/iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift index 2146d2c60..fb01ee0e6 100644 --- a/iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift +++ b/iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift @@ -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() {