summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-02-26 15:03:09 +0100
committerAndrej Mihajlov <and@mullvad.net>2020-02-26 17:19:33 +0100
commitd6788768aa4c24bd0dbe2cf3b529909030293b08 (patch)
treefeefc72224b311e8160faa2c99fb1f5f346cefd8
parent94e4e8acbe4db12852cf6f661a5ebc015f2d0d8f (diff)
downloadmullvadvpn-d6788768aa4c24bd0dbe2cf3b529909030293b08.tar.xz
mullvadvpn-d6788768aa4c24bd0dbe2cf3b529909030293b08.zip
Use hint when unwinding to execute the right-to-left animation
-rw-r--r--ios/MullvadVPN/RootContainerViewController.swift60
1 files changed, 36 insertions, 24 deletions
diff --git a/ios/MullvadVPN/RootContainerViewController.swift b/ios/MullvadVPN/RootContainerViewController.swift
index 6cf98e8267..6b47847538 100644
--- a/ios/MullvadVPN/RootContainerViewController.swift
+++ b/ios/MullvadVPN/RootContainerViewController.swift
@@ -126,12 +126,44 @@ class RootContainerViewController: UIViewController {
let animated = UIView.areAnimationsEnabled
- setViewControllers(newViewControllers, animated: animated)
+ setViewControllersInternal(newViewControllers, isUnwinding: true, animated: animated)
}
// MARK: - Public
- func setViewControllers(_ newViewControllers: [UIViewController], animated: Bool, completion: CompletionHandler? = nil) {
+ func setViewControllers(_ newViewControllers: [UIViewController],
+ animated: Bool,
+ completion: CompletionHandler? = nil)
+ {
+ setViewControllersInternal(
+ newViewControllers,
+ isUnwinding: false,
+ animated: animated,
+ completion: completion
+ )
+ }
+
+ func pushViewController(_ viewController: UIViewController, animated: Bool) {
+ var newViewControllers = viewControllers.filter({ $0 != viewController })
+ newViewControllers.append(viewController)
+
+ setViewControllersInternal(newViewControllers, isUnwinding: false, animated: animated)
+ }
+
+ /// Request the root container to query the top controller for the new header bar style
+ func updateHeaderBarAppearance() {
+ updateHeaderBarStyleFromChildPreferences(animated: UIView.areAnimationsEnabled)
+ }
+
+ // MARK: - Actions
+
+ @IBAction func doShowSettings() {
+ performSegue(withIdentifier: SegueIdentifier.Root.showSettings.rawValue, sender: self)
+ }
+
+ // MARK: - Private
+
+ private func setViewControllersInternal(_ newViewControllers: [UIViewController], isUnwinding: Bool, animated: Bool, completion: CompletionHandler? = nil) {
// Dot not handle appearance events when the container itself is not visible
let shouldHandleAppearanceEvents = view.window != nil
@@ -192,7 +224,7 @@ class RootContainerViewController: UIViewController {
for newViewController in newViewControllers {
newViewController.loadViewIfNeeded()
}
-
+
// Add the destination view into the view hierarchy
if let targetView = targetViewController?.view {
addChildView(targetView)
@@ -231,7 +263,7 @@ class RootContainerViewController: UIViewController {
case (.some(let lhs), .some(let rhs)):
transition.subtype = lhs > rhs ? .fromLeft : .fromRight
case (.none, .some):
- transition.subtype = .fromLeft
+ transition.subtype = isUnwinding ? .fromLeft : .fromRight
default:
transition.subtype = .fromRight
}
@@ -246,26 +278,6 @@ class RootContainerViewController: UIViewController {
}
}
- func pushViewController(_ viewController: UIViewController, animated: Bool) {
- var newViewControllers = viewControllers.filter({ $0 != viewController })
- newViewControllers.append(viewController)
-
- setViewControllers(newViewControllers, animated: animated)
- }
-
- /// Request the root container to query the top controller for the new header bar style
- func updateHeaderBarAppearance() {
- updateHeaderBarStyleFromChildPreferences(animated: UIView.areAnimationsEnabled)
- }
-
- // MARK: - Actions
-
- @IBAction func doShowSettings() {
- performSegue(withIdentifier: SegueIdentifier.Root.showSettings.rawValue, sender: self)
- }
-
- // MARK: - Private
-
private func addChildView(_ childView: UIView) {
childView.translatesAutoresizingMaskIntoConstraints = true
childView.autoresizingMask = [.flexibleWidth, .flexibleHeight]