mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-17 09:10:30 +00:00
Fix keyboard rotation
This commit is contained in:
parent
26b55adfb3
commit
96647e265f
@ -180,13 +180,6 @@ private final class NativeWindow: UIWindow, WindowHost {
|
||||
var forEachControllerImpl: (((ContainableController) -> Void) -> Void)?
|
||||
var getAccessibilityElementsImpl: (() -> [Any]?)?
|
||||
|
||||
/*override var accessibilityElements: [Any]? {
|
||||
get {
|
||||
return self.getAccessibilityElementsImpl?()
|
||||
} set(value) {
|
||||
}
|
||||
}*/
|
||||
|
||||
override var frame: CGRect {
|
||||
get {
|
||||
return super.frame
|
||||
@ -248,13 +241,13 @@ private final class NativeWindow: UIWindow, WindowHost {
|
||||
self.layoutSubviewsEvent?()
|
||||
}
|
||||
|
||||
/*override func _update(toInterfaceOrientation arg1: Int32, duration arg2: Double, force arg3: Bool) {
|
||||
override func _update(toInterfaceOrientation arg1: Int32, duration arg2: Double, force arg3: Bool) {
|
||||
self.updateIsUpdatingOrientationLayout?(true)
|
||||
super._update(toInterfaceOrientation: arg1, duration: arg2, force: arg3)
|
||||
self.updateIsUpdatingOrientationLayout?(false)
|
||||
|
||||
self.updateToInterfaceOrientation?()
|
||||
}*/
|
||||
}
|
||||
|
||||
func present(_ controller: ContainableController, on level: PresentationSurfaceLevel, blockInteraction: Bool, completion: @escaping () -> Void) {
|
||||
self.presentController?(controller, level, blockInteraction, completion)
|
||||
|
@ -812,8 +812,12 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
|
||||
public func replaceTopController(_ controller: ViewController, animated: Bool, ready: ValuePromise<Bool>? = nil) {
|
||||
self.view.endEditing(true)
|
||||
if !controller.hasActiveInput {
|
||||
self.view.endEditing(true)
|
||||
}
|
||||
if let validLayout = self.validLayout {
|
||||
let (_, controllerLayout) = self.layoutDataForConfiguration(self.layoutConfiguration(for: validLayout), layout: validLayout, index: self.viewControllers.count)
|
||||
var (_, controllerLayout) = self.layoutDataForConfiguration(self.layoutConfiguration(for: validLayout), layout: validLayout, index: self.viewControllers.count)
|
||||
controllerLayout.inputHeight = nil
|
||||
controller.containerLayoutUpdated(controllerLayout, transition: .immediate)
|
||||
}
|
||||
self.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { [weak self] _ in
|
||||
|
@ -6,6 +6,6 @@
|
||||
+ (void)addPostDeviceOrientationDidChangeBlock:(void (^)())block;
|
||||
+ (bool)isDeviceRotating;
|
||||
|
||||
//- (void)_updateToInterfaceOrientation:(int)arg1 duration:(double)arg2 force:(BOOL)arg3;
|
||||
- (void)_updateToInterfaceOrientation:(int)arg1 duration:(double)arg2 force:(BOOL)arg3;
|
||||
|
||||
@end
|
||||
|
@ -290,6 +290,7 @@ public class Window1 {
|
||||
private let statusBarManager: StatusBarManager?
|
||||
private let keyboardManager: KeyboardManager?
|
||||
private var statusBarChangeObserver: AnyObject?
|
||||
private var keyboardRotationChangeObserver: AnyObject?
|
||||
private var keyboardFrameChangeObserver: AnyObject?
|
||||
private var keyboardTypeChangeObserver: AnyObject?
|
||||
private var voiceOverStatusObserver: AnyObject?
|
||||
@ -436,6 +437,28 @@ public class Window1 {
|
||||
strongSelf.updateLayout { $0.update(statusBarHeight: statusBarHeight, transition: transition, overrideTransition: false) }
|
||||
}
|
||||
})
|
||||
self.keyboardRotationChangeObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name("UITextEffectsWindowDidRotateNotification"), object: nil, queue: nil, using: { [weak self] notification in
|
||||
if let strongSelf = self {
|
||||
if !strongSelf.hostView.isUpdatingOrientationLayout {
|
||||
return
|
||||
}
|
||||
let keyboardHeight = max(0.0, strongSelf.keyboardManager?.getCurrentKeyboardHeight() ?? 0.0)
|
||||
var duration: Double = (notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.0
|
||||
if duration > Double.ulpOfOne {
|
||||
duration = 0.5
|
||||
}
|
||||
let curve: UInt = (notification.userInfo?[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber)?.uintValue ?? 7
|
||||
|
||||
let transitionCurve: ContainedViewLayoutTransitionCurve
|
||||
if curve == 7 {
|
||||
transitionCurve = .spring
|
||||
} else {
|
||||
transitionCurve = .easeInOut
|
||||
}
|
||||
|
||||
strongSelf.updateLayout { $0.update(inputHeight: keyboardHeight.isLessThanOrEqualTo(0.0) ? nil : keyboardHeight, transition: .animated(duration: duration, curve: transitionCurve), overrideTransition: false) }
|
||||
}
|
||||
})
|
||||
|
||||
self.keyboardFrameChangeObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil, queue: nil, using: { [weak self] notification in
|
||||
if let strongSelf = self {
|
||||
@ -536,6 +559,9 @@ public class Window1 {
|
||||
if let statusBarChangeObserver = self.statusBarChangeObserver {
|
||||
NotificationCenter.default.removeObserver(statusBarChangeObserver)
|
||||
}
|
||||
if let keyboardRotationChangeObserver = self.keyboardRotationChangeObserver {
|
||||
NotificationCenter.default.removeObserver(keyboardRotationChangeObserver)
|
||||
}
|
||||
if let keyboardFrameChangeObserver = self.keyboardFrameChangeObserver {
|
||||
NotificationCenter.default.removeObserver(keyboardFrameChangeObserver)
|
||||
}
|
||||
@ -794,7 +820,7 @@ public class Window1 {
|
||||
}
|
||||
|
||||
if !UIWindow.isDeviceRotating() {
|
||||
if true || !self.hostView.isUpdatingOrientationLayout {
|
||||
if !self.hostView.isUpdatingOrientationLayout {
|
||||
self.commitUpdatingLayout()
|
||||
} else {
|
||||
self.addPostUpdateToInterfaceOrientationBlock(f: { [weak self] in
|
||||
|
Loading…
x
Reference in New Issue
Block a user