diff --git a/submodules/Display/Display/NavigationController.swift b/submodules/Display/Display/NavigationController.swift index 9a06d87e4c..70b8690ec9 100644 --- a/submodules/Display/Display/NavigationController.swift +++ b/submodules/Display/Display/NavigationController.swift @@ -751,7 +751,7 @@ open class NavigationController: UINavigationController, ContainableController, } if let navigationTransitionCoordinator = self.navigationTransitionCoordinator { - navigationTransitionCoordinator.updateProgress() + navigationTransitionCoordinator.updateProgress(transition: transition) } } @@ -840,14 +840,14 @@ open class NavigationController: UINavigationController, ContainableController, bottomController.displayNode.recursivelyEnsureDisplaySynchronously(true) } - let navigationTransitionCoordinator = NavigationTransitionCoordinator(transition: .Pop, container: self.controllerView.containerView, topView: topView, topNavigationBar: (topController as? ViewController)?.navigationBar, bottomView: bottomView, bottomNavigationBar: (bottomController as? ViewController)?.navigationBar, didUpdateProgress: { [weak self] progress in + let navigationTransitionCoordinator = NavigationTransitionCoordinator(transition: .Pop, container: self.controllerView.containerView, topView: topView, topNavigationBar: (topController as? ViewController)?.navigationBar, bottomView: bottomView, bottomNavigationBar: (bottomController as? ViewController)?.navigationBar, didUpdateProgress: { [weak self] progress, transition in if let strongSelf = self { for i in 0 ..< strongSelf._viewControllers.count { if let controller = strongSelf._viewControllers[i].controller as? ViewController { if i < strongSelf._viewControllers.count - 1 { - controller.updateNavigationCustomData((strongSelf.viewControllers[i + 1] as? ViewController)?.customData, progress: 1.0 - progress, transition: .immediate) + controller.updateNavigationCustomData((strongSelf.viewControllers[i + 1] as? ViewController)?.customData, progress: 1.0 - progress, transition: transition) } else { - controller.updateNavigationCustomData(nil, progress: 1.0 - progress, transition: .immediate) + controller.updateNavigationCustomData(nil, progress: 1.0 - progress, transition: transition) } } } diff --git a/submodules/Display/Display/NavigationTransitionCoordinator.swift b/submodules/Display/Display/NavigationTransitionCoordinator.swift index 0b6bfd5321..055c9564cd 100644 --- a/submodules/Display/Display/NavigationTransitionCoordinator.swift +++ b/submodules/Display/Display/NavigationTransitionCoordinator.swift @@ -21,7 +21,7 @@ class NavigationTransitionCoordinator { } set(value) { self._progress = value - self.updateProgress() + self.updateProgress(transition: .immediate) } } @@ -39,8 +39,9 @@ class NavigationTransitionCoordinator { private(set) var animatingCompletion = false private var currentCompletion: (() -> Void)? - private var didUpdateProgress:((CGFloat)->Void)? - init(transition: NavigationTransition, container: UIView, topView: UIView, topNavigationBar: NavigationBar?, bottomView: UIView, bottomNavigationBar: NavigationBar?, didUpdateProgress: ((CGFloat) -> Void)? = nil) { + private var didUpdateProgress: ((CGFloat, ContainedViewLayoutTransition) -> Void)? + + init(transition: NavigationTransition, container: UIView, topView: UIView, topNavigationBar: NavigationBar?, bottomView: UIView, bottomNavigationBar: NavigationBar?, didUpdateProgress: ((CGFloat, ContainedViewLayoutTransition) -> Void)? = nil) { self.transition = transition self.container = container self.didUpdateProgress = didUpdateProgress @@ -79,14 +80,14 @@ class NavigationTransitionCoordinator { self.viewSuperview?.insertSubview(self.shadowView, belowSubview: dimView) self.maybeCreateNavigationBarTransition() - self.updateProgress() + self.updateProgress(transition: .immediate) } required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } - func updateProgress() { + func updateProgress(transition: ContainedViewLayoutTransition) { let position: CGFloat switch self.transition { case .Push: @@ -111,7 +112,7 @@ class NavigationTransitionCoordinator { self.updateNavigationBarTransition() - self.didUpdateProgress?(self.progress) + self.didUpdateProgress?(self.progress, transition) } func updateNavigationBarTransition() { diff --git a/submodules/Display/Display/PresentationContext.swift b/submodules/Display/Display/PresentationContext.swift index b61fe57e63..ef14a61fdf 100644 --- a/submodules/Display/Display/PresentationContext.swift +++ b/submodules/Display/Display/PresentationContext.swift @@ -14,7 +14,7 @@ public enum PresentationContextType { case window(PresentationSurfaceLevel) } -final class PresentationContext { +public final class PresentationContext { private var _view: UIView? var view: UIView? { get { diff --git a/submodules/Display/Display/TabBarController.swift b/submodules/Display/Display/TabBarController.swift index 517a548e09..c46eb45d07 100644 --- a/submodules/Display/Display/TabBarController.swift +++ b/submodules/Display/Display/TabBarController.swift @@ -176,7 +176,23 @@ open class TabBarController: ViewController { } } if let validLayout = strongSelf.validLayout { - strongSelf.controllers[index].containerLayoutUpdated(validLayout.addedInsets(insets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 49.0, right: 0.0)), transition: .immediate) + var updatedLayout = validLayout + + var tabBarHeight: CGFloat + var options: ContainerViewLayoutInsetOptions = [] + if validLayout.metrics.widthClass == .regular { + options.insert(.input) + } + let bottomInset: CGFloat = validLayout.insets(options: options).bottom + if !validLayout.safeInsets.left.isZero { + tabBarHeight = 34.0 + bottomInset + } else { + tabBarHeight = 49.0 + bottomInset + } + updatedLayout.intrinsicInsets.bottom = tabBarHeight + + + strongSelf.controllers[index].containerLayoutUpdated(updatedLayout, transition: .immediate) } let startTime = CFAbsoluteTimeGetCurrent() strongSelf.pendingControllerDisposable.set((strongSelf.controllers[index].ready.get() @@ -271,7 +287,23 @@ open class TabBarController: ViewController { if let currentController = self.currentController { currentController.view.frame = CGRect(origin: CGPoint(), size: layout.size) - currentController.containerLayoutUpdated(layout.addedInsets(insets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 49.0, right: 0.0)), transition: transition) + var updatedLayout = layout + + var tabBarHeight: CGFloat + var options: ContainerViewLayoutInsetOptions = [] + if updatedLayout.metrics.widthClass == .regular { + options.insert(.input) + } + let bottomInset: CGFloat = updatedLayout.insets(options: options).bottom + if !updatedLayout.safeInsets.left.isZero { + tabBarHeight = 34.0 + bottomInset + } else { + tabBarHeight = 49.0 + bottomInset + } + updatedLayout.intrinsicInsets.bottom = tabBarHeight + + + currentController.containerLayoutUpdated(updatedLayout, transition: transition) } } diff --git a/submodules/Display/Display/ViewController.swift b/submodules/Display/Display/ViewController.swift index 56e3fc2848..96842fc87f 100644 --- a/submodules/Display/Display/ViewController.swift +++ b/submodules/Display/Display/ViewController.swift @@ -65,7 +65,7 @@ open class ViewControllerPresentationArguments { return self.validLayout } - private let presentationContext: PresentationContext + public let presentationContext: PresentationContext public final var supportedOrientations: ViewControllerSupportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .allButUpsideDown) public final var lockedOrientation: UIInterfaceOrientationMask? @@ -81,6 +81,7 @@ open class ViewControllerPresentationArguments { public final var isOpaqueWhenInOverlay: Bool = false public final var blocksBackgroundWhenInOverlay: Bool = false + public final var automaticallyControlPresentationContextLayout: Bool = true public func combinedSupportedOrientations(currentOrientationToLock: UIInterfaceOrientationMask) -> ViewControllerSupportedOrientations { return self.supportedOrientations @@ -332,7 +333,9 @@ open class ViewControllerPresentationArguments { self.updateNavigationBarLayout(layout, transition: transition) - self.presentationContext.containerLayoutUpdated(layout, transition: transition) + if self.automaticallyControlPresentationContextLayout { + self.presentationContext.containerLayoutUpdated(layout, transition: transition) + } if let scrollToTopView = self.scrollToTopView { scrollToTopView.frame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: 10.0) diff --git a/submodules/TelegramUI/TelegramUI/ChatController.swift b/submodules/TelegramUI/TelegramUI/ChatController.swift index df17513377..4f1efc337f 100644 --- a/submodules/TelegramUI/TelegramUI/ChatController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatController.swift @@ -4541,8 +4541,8 @@ public final class ChatController: TelegramController, GalleryHiddenMediaTarget, } } }, recognizedQRCode: { [weak self] code in - if let strongSelf = self, let (host, port, username, password, secret, secretHost) = parseProxyUrl(code) { - strongSelf.openResolved(ResolvedUrl.proxy(host: host, port: port, username: username, password: password, secret: secret, secretHost: secretHost)) + if let strongSelf = self, let (host, port, username, password, secret) = parseProxyUrl(code) { + strongSelf.openResolved(ResolvedUrl.proxy(host: host, port: port, username: username, password: password, secret: secret)) } }) }