[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 <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn
2025-09-15 18:05:55 +04:00
committed by Yannik Bloscheck
parent 056711f4bd
commit 47f16c5b89

View File

@@ -181,7 +181,7 @@ final class CarPlayMapViewController: MWMViewController {
frame.origin = origin frame.origin = origin
frame.size = CGSize(width: viewBounds.width - origin.x, frame.size = CGSize(width: viewBounds.width - origin.x,
height: viewBounds.height - origin.y) height: viewBounds.height - origin.y)
FrameworkHelper.setVisibleViewport(frame, scaleFactor: mapView?.contentScaleFactor ?? 1) updateVisibleViewPort(frame: frame)
} }
private func updateVisibleViewPortToNavigationState() { private func updateVisibleViewPortToNavigationState() {
@@ -194,11 +194,16 @@ final class CarPlayMapViewController: MWMViewController {
frame.origin = origin frame.origin = origin
frame.size = CGSize(width: viewBounds.width - (origin.x + mapControlsWidth), frame.size = CGSize(width: viewBounds.width - (origin.x + mapControlsWidth),
height: viewBounds.height - origin.y) height: viewBounds.height - origin.y)
FrameworkHelper.setVisibleViewport(frame, scaleFactor: mapView?.contentScaleFactor ?? 1) updateVisibleViewPort(frame: frame)
} }
private func updateVisibleViewPortToDefaultState() { 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?) { override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {