mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Fix device metrics on iPads
This commit is contained in:
parent
eac7b8d948
commit
a886689ab0
@ -43,7 +43,7 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
|||||||
|
|
||||||
let additionalSize = CGSize(width: screenSize.width, height: screenSize.height + 20.0)
|
let additionalSize = CGSize(width: screenSize.width, height: screenSize.height + 20.0)
|
||||||
for device in DeviceMetrics.allCases {
|
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 case .tablet = device.type {
|
||||||
if screenSize.height == 1024.0 && screenSize.width == 768.0 {
|
if screenSize.height == 1024.0 && screenSize.width == 768.0 {
|
||||||
} else {
|
} else {
|
||||||
@ -111,12 +111,18 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func onScreenNavigationHeight(inLandscape: Bool) -> CGFloat? {
|
func onScreenNavigationHeight(inLandscape: Bool, systemOnScreenNavigationHeight: CGFloat?) -> CGFloat? {
|
||||||
switch self {
|
switch self {
|
||||||
case .iPhoneX, .iPhoneXSMax:
|
case .iPhoneX, .iPhoneXSMax:
|
||||||
return inLandscape ? 21.0 : 34.0
|
return inLandscape ? 21.0 : 34.0
|
||||||
case .iPadPro3rdGen, .iPadPro11Inch:
|
case .iPadPro3rdGen, .iPadPro11Inch:
|
||||||
return 21.0
|
return 21.0
|
||||||
|
case .iPad, .iPadPro, .iPadPro10Inch:
|
||||||
|
if let systemOnScreenNavigationHeight = systemOnScreenNavigationHeight, !systemOnScreenNavigationHeight.isZero {
|
||||||
|
return 21.0
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
case let .unknown(_, _, onScreenNavigationHeight):
|
case let .unknown(_, _, onScreenNavigationHeight):
|
||||||
return onScreenNavigationHeight
|
return onScreenNavigationHeight
|
||||||
default:
|
default:
|
||||||
|
@ -310,7 +310,7 @@ public class Window1 {
|
|||||||
|
|
||||||
let isLandscape = boundsSize.width > boundsSize.height
|
let isLandscape = boundsSize.width > boundsSize.height
|
||||||
let safeInsets = self.deviceMetrics.safeInsets(inLandscape: isLandscape)
|
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.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)
|
self.updatingLayout = UpdatingLayout(layout: self.windowLayout, transition: .immediate)
|
||||||
@ -950,7 +950,7 @@ public class Window1 {
|
|||||||
statusBarHeight = max(statusBarHeightValue, statusBarHost.statusBarFrame.size.height)
|
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)
|
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)
|
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 childLayout = containedLayoutForWindowLayout(self.windowLayout, deviceMetrics: self.deviceMetrics)
|
||||||
let childLayoutUpdated = self.updatedContainerLayout != childLayout
|
let childLayoutUpdated = self.updatedContainerLayout != childLayout
|
||||||
|
Loading…
x
Reference in New Issue
Block a user