diff --git a/submodules/Display/Display/DeviceMetrics.swift b/submodules/Display/Display/DeviceMetrics.swift index bc78143e2a..ac0304f736 100644 --- a/submodules/Display/Display/DeviceMetrics.swift +++ b/submodules/Display/Display/DeviceMetrics.swift @@ -43,7 +43,7 @@ public enum DeviceMetrics: CaseIterable, Equatable { let additionalSize = CGSize(width: screenSize.width, height: screenSize.height + 20.0) for device in DeviceMetrics.allCases { - if let _ = onScreenNavigationHeight, device.onScreenNavigationHeight(inLandscape: false) == nil { + if let _ = onScreenNavigationHeight, device.onScreenNavigationHeight(inLandscape: false, systemOnScreenNavigationHeight: nil) == nil { if case .tablet = device.type { if screenSize.height == 1024.0 && screenSize.width == 768.0 { } else { @@ -111,16 +111,22 @@ public enum DeviceMetrics: CaseIterable, Equatable { } } - func onScreenNavigationHeight(inLandscape: Bool) -> CGFloat? { + func onScreenNavigationHeight(inLandscape: Bool, systemOnScreenNavigationHeight: CGFloat?) -> CGFloat? { switch self { - case .iPhoneX, .iPhoneXSMax: - return inLandscape ? 21.0 : 34.0 - case .iPadPro3rdGen, .iPadPro11Inch: + case .iPhoneX, .iPhoneXSMax: + return inLandscape ? 21.0 : 34.0 + case .iPadPro3rdGen, .iPadPro11Inch: + return 21.0 + case .iPad, .iPadPro, .iPadPro10Inch: + if let systemOnScreenNavigationHeight = systemOnScreenNavigationHeight, !systemOnScreenNavigationHeight.isZero { return 21.0 - case let .unknown(_, _, onScreenNavigationHeight): - return onScreenNavigationHeight - default: + } else { return nil + } + case let .unknown(_, _, onScreenNavigationHeight): + return onScreenNavigationHeight + default: + return nil } } diff --git a/submodules/Display/Display/WindowContent.swift b/submodules/Display/Display/WindowContent.swift index dfa258bf3e..12426cf2ef 100644 --- a/submodules/Display/Display/WindowContent.swift +++ b/submodules/Display/Display/WindowContent.swift @@ -310,7 +310,7 @@ public class Window1 { let isLandscape = boundsSize.width > boundsSize.height let safeInsets = self.deviceMetrics.safeInsets(inLandscape: isLandscape) - let onScreenNavigationHeight = self.deviceMetrics.onScreenNavigationHeight(inLandscape: isLandscape) + let onScreenNavigationHeight = self.deviceMetrics.onScreenNavigationHeight(inLandscape: isLandscape, systemOnScreenNavigationHeight: self.hostView.onScreenNavigationHeight) self.windowLayout = WindowLayout(size: boundsSize, metrics: layoutMetricsForScreenSize(boundsSize), statusBarHeight: statusBarHeight, forceInCallStatusBarText: self.forceInCallStatusBarText, inputHeight: 0.0, safeInsets: safeInsets, onScreenNavigationHeight: onScreenNavigationHeight, upperKeyboardInputPositionBound: nil, inVoiceOver: UIAccessibility.isVoiceOverRunning) self.updatingLayout = UpdatingLayout(layout: self.windowLayout, transition: .immediate) @@ -950,7 +950,7 @@ public class Window1 { statusBarHeight = max(statusBarHeightValue, statusBarHost.statusBarFrame.size.height) } - if self.deviceMetrics.type == .tablet, let onScreenNavigationHeight = self.hostView.onScreenNavigationHeight, onScreenNavigationHeight != self.deviceMetrics.onScreenNavigationHeight(inLandscape: false) { + if self.deviceMetrics.type == .tablet, let onScreenNavigationHeight = self.hostView.onScreenNavigationHeight, onScreenNavigationHeight != self.deviceMetrics.onScreenNavigationHeight(inLandscape: false, systemOnScreenNavigationHeight: self.hostView.onScreenNavigationHeight) { self.deviceMetrics = DeviceMetrics(screenSize: UIScreen.main.bounds.size, statusBarHeight: statusBarHeight ?? defaultStatusBarHeight, onScreenNavigationHeight: onScreenNavigationHeight) } @@ -967,7 +967,7 @@ public class Window1 { } let previousInputOffset = inputHeightOffsetForLayout(self.windowLayout) - self.windowLayout = WindowLayout(size: updatingLayout.layout.size, metrics: layoutMetricsForScreenSize(updatingLayout.layout.size), statusBarHeight: statusBarHeight, forceInCallStatusBarText: updatingLayout.layout.forceInCallStatusBarText, inputHeight: updatingLayout.layout.inputHeight, safeInsets: updatingLayout.layout.safeInsets, onScreenNavigationHeight: self.deviceMetrics.onScreenNavigationHeight(inLandscape: isLandscape), upperKeyboardInputPositionBound: updatingLayout.layout.upperKeyboardInputPositionBound, inVoiceOver: updatingLayout.layout.inVoiceOver) + self.windowLayout = WindowLayout(size: updatingLayout.layout.size, metrics: layoutMetricsForScreenSize(updatingLayout.layout.size), statusBarHeight: statusBarHeight, forceInCallStatusBarText: updatingLayout.layout.forceInCallStatusBarText, inputHeight: updatingLayout.layout.inputHeight, safeInsets: updatingLayout.layout.safeInsets, onScreenNavigationHeight: self.deviceMetrics.onScreenNavigationHeight(inLandscape: isLandscape, systemOnScreenNavigationHeight: self.hostView.onScreenNavigationHeight), upperKeyboardInputPositionBound: updatingLayout.layout.upperKeyboardInputPositionBound, inVoiceOver: updatingLayout.layout.inVoiceOver) let childLayout = containedLayoutForWindowLayout(self.windowLayout, deviceMetrics: self.deviceMetrics) let childLayoutUpdated = self.updatedContainerLayout != childLayout