mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
Fixed various screen inset imperfections on iPad in Slide Over
This commit is contained in:
parent
ec6526b07d
commit
93c6442af8
@ -83,6 +83,12 @@ public struct ContainerViewLayout: Equatable {
|
||||
public extension ContainerViewLayout {
|
||||
func insets(options: ContainerViewLayoutInsetOptions) -> UIEdgeInsets {
|
||||
var insets = self.intrinsicInsets
|
||||
if self.inSlideOver {
|
||||
let onScreenNavigationHeight = self.deviceMetrics.onScreenNavigationHeight(inLandscape: false) ?? 0.0
|
||||
if insets.bottom > 0.0 && abs(insets.bottom - onScreenNavigationHeight) < 0.1 {
|
||||
insets.bottom = 0.0
|
||||
}
|
||||
}
|
||||
if let statusBarHeight = self.statusBarHeight, options.contains(.statusBar) {
|
||||
insets.top += statusBarHeight
|
||||
}
|
||||
@ -92,6 +98,50 @@ public extension ContainerViewLayout {
|
||||
return insets
|
||||
}
|
||||
|
||||
var isNonExclusive: Bool {
|
||||
if case .tablet = self.deviceMetrics.type {
|
||||
if case .compact = self.metrics.widthClass {
|
||||
return true
|
||||
}
|
||||
if case .compact = self.metrics.heightClass {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var inSplitView: Bool {
|
||||
var maybeSplitView = false
|
||||
if case .tablet = self.deviceMetrics.type {
|
||||
if case .compact = self.metrics.widthClass {
|
||||
maybeSplitView = true
|
||||
}
|
||||
if case .compact = self.metrics.heightClass {
|
||||
maybeSplitView = true
|
||||
}
|
||||
}
|
||||
if maybeSplitView && abs(max(self.size.width, self.size.height) - self.deviceMetrics.screenSize.height) < 1.0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var inSlideOver: Bool {
|
||||
var maybeSlideOver = false
|
||||
if case .tablet = self.deviceMetrics.type {
|
||||
if case .compact = self.metrics.widthClass {
|
||||
maybeSlideOver = true
|
||||
}
|
||||
if case .compact = self.metrics.heightClass {
|
||||
maybeSlideOver = true
|
||||
}
|
||||
}
|
||||
if maybeSlideOver && abs(max(self.size.width, self.size.height) - self.deviceMetrics.screenSize.height) > 10.0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var orientation: LayoutOrientation {
|
||||
return self.size.width > self.size.height ? .landscape : .portrait
|
||||
}
|
||||
|
||||
@ -438,6 +438,10 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
if self.controllerView.sharedStatusBar.view.superview != nil {
|
||||
self.controllerView.sharedStatusBar.removeFromSupernode()
|
||||
self.controllerView.containerView.layer.setTraceableInfo(nil)
|
||||
|
||||
if layout.deviceMetrics.type == .tablet {
|
||||
self.controllerView.containerView.layer.setTraceableInfo(CATracingLayerInfo(shouldBeAdjustedToInverseTransform: true, userData: self, tracingTag: 0, disableChildrenTracingTags: WindowTracingTags.statusBar | WindowTracingTags.keyboard))
|
||||
}
|
||||
}
|
||||
case .masterDetail:
|
||||
if self.controllerView.sharedStatusBar.view.superview == nil {
|
||||
@ -865,7 +869,6 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
let translation = recognizer.translation(in: self.view).x
|
||||
let progress = max(0.0, min(1.0, translation / self.view.frame.width))
|
||||
navigationTransitionCoordinator.progress = progress
|
||||
|
||||
}
|
||||
case .ended:
|
||||
if let navigationTransitionCoordinator = self.navigationTransitionCoordinator, !navigationTransitionCoordinator.animatingCompletion {
|
||||
|
||||
@ -191,7 +191,6 @@ open class TabBarController: ViewController {
|
||||
}
|
||||
updatedLayout.intrinsicInsets.bottom = tabBarHeight
|
||||
|
||||
|
||||
strongSelf.controllers[index].containerLayoutUpdated(updatedLayout, transition: .immediate)
|
||||
}
|
||||
let startTime = CFAbsoluteTimeGetCurrent()
|
||||
@ -302,7 +301,6 @@ open class TabBarController: ViewController {
|
||||
}
|
||||
updatedLayout.intrinsicInsets.bottom = tabBarHeight
|
||||
|
||||
|
||||
currentController.containerLayoutUpdated(updatedLayout, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,7 +237,7 @@ public final class WindowHostView {
|
||||
|
||||
fileprivate var onScreenNavigationHeight: CGFloat? {
|
||||
if #available(iOSApplicationExtension 11.0, *) {
|
||||
return !self.eventView.safeAreaInsets.bottom.isLessThanOrEqualTo(0.0) ? nil : self.eventView.safeAreaInsets.bottom
|
||||
return self.eventView.safeAreaInsets.bottom.isLessThanOrEqualTo(0.0) ? nil : self.eventView.safeAreaInsets.bottom
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -342,7 +342,6 @@ public class Window1 {
|
||||
self.volumeControlStatusBarNode.isHidden = true
|
||||
|
||||
let boundsSize = self.hostView.eventView.bounds.size
|
||||
|
||||
self.deviceMetrics = DeviceMetrics(screenSize: UIScreen.main.bounds.size, statusBarHeight: statusBarHost?.statusBarFrame.height ?? 20.0, onScreenNavigationHeight: self.hostView.onScreenNavigationHeight)
|
||||
|
||||
self.statusBarHost = statusBarHost
|
||||
@ -451,7 +450,10 @@ public class Window1 {
|
||||
if !strongSelf.hostView.isUpdatingOrientationLayout {
|
||||
return
|
||||
}
|
||||
let keyboardHeight = max(0.0, strongSelf.keyboardManager?.getCurrentKeyboardHeight() ?? 0.0)
|
||||
var keyboardHeight = max(0.0, strongSelf.keyboardManager?.getCurrentKeyboardHeight() ?? 0.0)
|
||||
if strongSelf.deviceMetrics.type == .tablet, abs(strongSelf.windowLayout.size.height - UIScreen.main.bounds.height) > 41.0 {
|
||||
keyboardHeight = max(0.0, keyboardHeight - 24.0)
|
||||
}
|
||||
var duration: Double = (notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.0
|
||||
if duration > Double.ulpOfOne {
|
||||
duration = 0.5
|
||||
@ -474,10 +476,11 @@ public class Window1 {
|
||||
let keyboardFrame: CGRect = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? CGRect()
|
||||
|
||||
let screenHeight: CGFloat
|
||||
|
||||
var inPopover = false
|
||||
if keyboardFrame.width.isEqual(to: UIScreen.main.bounds.width) {
|
||||
if abs(strongSelf.windowLayout.size.height - UIScreen.main.bounds.height) > 41.0 {
|
||||
screenHeight = UIScreen.main.bounds.height
|
||||
inPopover = true
|
||||
} else {
|
||||
screenHeight = strongSelf.windowLayout.size.height
|
||||
}
|
||||
@ -485,7 +488,11 @@ public class Window1 {
|
||||
screenHeight = UIScreen.main.bounds.width
|
||||
}
|
||||
|
||||
let keyboardHeight = max(0.0, screenHeight - keyboardFrame.minY)
|
||||
var keyboardHeight = max(0.0, screenHeight - keyboardFrame.minY)
|
||||
if inPopover {
|
||||
keyboardHeight = max(0.0, keyboardHeight - 48.0)
|
||||
}
|
||||
|
||||
var duration: Double = (notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.0
|
||||
if duration > Double.ulpOfOne {
|
||||
duration = 0.5
|
||||
@ -518,7 +525,10 @@ public class Window1 {
|
||||
}
|
||||
|
||||
if let keyboardManager = strongSelf.keyboardManager {
|
||||
let updatedKeyboardHeight = keyboardManager.getCurrentKeyboardHeight()
|
||||
var updatedKeyboardHeight = keyboardManager.getCurrentKeyboardHeight()
|
||||
if strongSelf.deviceMetrics.type == .tablet, abs(strongSelf.windowLayout.size.height - UIScreen.main.bounds.height) > 41.0 {
|
||||
updatedKeyboardHeight = max(0.0, updatedKeyboardHeight - 24.0)
|
||||
}
|
||||
if !updatedKeyboardHeight.isEqual(to: initialInputHeight) {
|
||||
strongSelf.updateLayout({ $0.update(inputHeight: updatedKeyboardHeight, transition: .immediate, overrideTransition: false) })
|
||||
}
|
||||
@ -544,6 +554,7 @@ public class Window1 {
|
||||
recognizer.delaysTouchesBegan = false
|
||||
recognizer.delaysTouchesEnded = false
|
||||
recognizer.delegate = self.keyboardGestureRecognizerDelegate
|
||||
recognizer.isEnabled = self.deviceMetrics.type == .phone
|
||||
recognizer.began = { [weak self] point in
|
||||
self?.panGestureBegan(location: point)
|
||||
}
|
||||
|
||||
@ -3957,13 +3957,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
||||
}
|
||||
|
||||
let controller = ChatSendMessageActionSheetController(context: strongSelf.context, controllerInteraction: strongSelf.controllerInteraction, interfaceState: strongSelf.presentationInterfaceState, sendButtonFrame: sendButtonFrame, textInputNode: textInputNode, completion: { [weak self] in
|
||||
let controller = ChatSendMessageActionSheetController(context: strongSelf.context, controllerInteraction: strongSelf.controllerInteraction, interfaceState: strongSelf.presentationInterfaceState, sendButtonFrame: strongSelf.chatDisplayNode.convert(sendButtonFrame, to: nil), textInputNode: textInputNode, completion: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .all)
|
||||
}
|
||||
})
|
||||
strongSelf.sendMessageActionsController = controller
|
||||
strongSelf.presentInGlobalOverlay(controller, with: nil)
|
||||
if layout.isNonExclusive {
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
} else {
|
||||
strongSelf.presentInGlobalOverlay(controller, with: nil)
|
||||
}
|
||||
}
|
||||
}, openScheduledMessages: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user