mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-10 16:29:55 +00:00
Fix replaceAllButRootController when not initialized
This commit is contained in:
parent
d444a36f98
commit
709df1faef
@ -764,7 +764,11 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
let appliedLayout = controllerLayout.withUpdatedInputHeight(controller.hasActiveInput ? controllerLayout.inputHeight : nil)
|
let appliedLayout = controllerLayout.withUpdatedInputHeight(controller.hasActiveInput ? controllerLayout.inputHeight : nil)
|
||||||
controller.containerLayoutUpdated(appliedLayout, transition: .immediate)
|
controller.containerLayoutUpdated(appliedLayout, transition: .immediate)
|
||||||
strongSelf.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { _ in
|
strongSelf.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { _ in
|
||||||
if let strongSelf = self, let validLayout = strongSelf.validLayout {
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if let validLayout = strongSelf.validLayout {
|
||||||
let (_, controllerLayout) = strongSelf.layoutDataForConfiguration(strongSelf.layoutConfiguration(for: validLayout), layout: validLayout, index: strongSelf.viewControllers.count)
|
let (_, controllerLayout) = strongSelf.layoutDataForConfiguration(strongSelf.layoutConfiguration(for: validLayout), layout: validLayout, index: strongSelf.viewControllers.count)
|
||||||
|
|
||||||
let containerLayout = controllerLayout.withUpdatedInputHeight(controller.hasActiveInput ? controllerLayout.inputHeight : nil)
|
let containerLayout = controllerLayout.withUpdatedInputHeight(controller.hasActiveInput ? controllerLayout.inputHeight : nil)
|
||||||
@ -813,13 +817,19 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
|
|
||||||
public func replaceAllButRootController(_ controller: ViewController, animated: Bool, ready: ValuePromise<Bool>? = nil, completion: @escaping () -> Void = {}) {
|
public func replaceAllButRootController(_ controller: ViewController, animated: Bool, ready: ValuePromise<Bool>? = nil, completion: @escaping () -> Void = {}) {
|
||||||
self.view.endEditing(true)
|
self.view.endEditing(true)
|
||||||
if let validLayout = self.validLayout {
|
self.scheduleAfterLayout { [weak self] in
|
||||||
var (_, controllerLayout) = self.layoutDataForConfiguration(self.layoutConfiguration(for: validLayout), layout: validLayout, index: self.viewControllers.count)
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if let validLayout = strongSelf.validLayout {
|
||||||
|
var (_, controllerLayout) = strongSelf.layoutDataForConfiguration(strongSelf.layoutConfiguration(for: validLayout), layout: validLayout, index: strongSelf.viewControllers.count)
|
||||||
controllerLayout.inputHeight = nil
|
controllerLayout.inputHeight = nil
|
||||||
controller.containerLayoutUpdated(controllerLayout, transition: .immediate)
|
controller.containerLayoutUpdated(controllerLayout, transition: .immediate)
|
||||||
}
|
}
|
||||||
self.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { [weak self] _ in
|
strongSelf.currentPushDisposable.set((controller.ready.get() |> take(1)).start(next: { _ in
|
||||||
if let strongSelf = self {
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
ready?.set(true)
|
ready?.set(true)
|
||||||
var controllers = strongSelf.viewControllers
|
var controllers = strongSelf.viewControllers
|
||||||
while controllers.count > 1 {
|
while controllers.count > 1 {
|
||||||
@ -828,9 +838,9 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
controllers.append(controller)
|
controllers.append(controller)
|
||||||
strongSelf.setViewControllers(controllers, animated: animated)
|
strongSelf.setViewControllers(controllers, animated: animated)
|
||||||
completion()
|
completion()
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func popToRoot(animated: Bool) {
|
public func popToRoot(animated: Bool) {
|
||||||
var controllers = self.viewControllers
|
var controllers = self.viewControllers
|
||||||
@ -993,7 +1003,7 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func scheduleAfterLayout(_ f: @escaping () -> Void) {
|
private func scheduleAfterLayout(_ f: @escaping () -> Void) {
|
||||||
(self.view as? UITracingLayerView)?.schedule(layout: { [weak self] in
|
(self.view as? UITracingLayerView)?.schedule(layout: {
|
||||||
f()
|
f()
|
||||||
})
|
})
|
||||||
self.view.setNeedsLayout()
|
self.view.setNeedsLayout()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user