From 47f16c5b8943687c95c8ade897d1e075e8480ab1 Mon Sep 17 00:00:00 2001 From: Kiryl Kaveryn Date: Mon, 15 Sep 2025 18:05:55 +0400 Subject: [PATCH] [ios] Skip CarPlay VC from updating the viewport when CP was disabed The updateVisibleViewPortToDefaultState was called from the `viewDidLayoutSubviews` when the VC is removed from the stack, updates the viewport unexpectedly and overwrite the correct viewport with CP screen size. It may break the viewport when switching to the phone. Signed-off-by: Kiryl Kaveryn --- iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift b/iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift index 65881c05c..2146d2c60 100644 --- a/iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift +++ b/iphone/Maps/UI/CarPlay/CarPlayMapViewController.swift @@ -181,7 +181,7 @@ final class CarPlayMapViewController: MWMViewController { frame.origin = origin frame.size = CGSize(width: viewBounds.width - origin.x, height: viewBounds.height - origin.y) - FrameworkHelper.setVisibleViewport(frame, scaleFactor: mapView?.contentScaleFactor ?? 1) + updateVisibleViewPort(frame: frame) } private func updateVisibleViewPortToNavigationState() { @@ -194,11 +194,16 @@ final class CarPlayMapViewController: MWMViewController { frame.origin = origin frame.size = CGSize(width: viewBounds.width - (origin.x + mapControlsWidth), height: viewBounds.height - origin.y) - FrameworkHelper.setVisibleViewport(frame, scaleFactor: mapView?.contentScaleFactor ?? 1) + updateVisibleViewPort(frame: frame) } private func updateVisibleViewPortToDefaultState() { - FrameworkHelper.setVisibleViewport(view.bounds, scaleFactor: mapView?.contentScaleFactor ?? 1) + updateVisibleViewPort(frame: view.bounds) + } + + private func updateVisibleViewPort(frame: CGRect) { + guard CarPlayService.shared.isCarplayActivated else { return } + FrameworkHelper.setVisibleViewport(frame, scaleFactor: mapView?.contentScaleFactor ?? 1) } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {