From 31353375bfcbc401781d69726149ec60e0acabd3 Mon Sep 17 00:00:00 2001 From: uttiya10 <56562649+uttiya10@users.noreply.github.com> Date: Sat, 1 May 2021 21:32:41 -0400 Subject: [PATCH 1/7] Show confirmation message when backup has imported successfully --- NineAnimator/Controllers/RootViewController.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NineAnimator/Controllers/RootViewController.swift b/NineAnimator/Controllers/RootViewController.swift index 91d1c335..5329d1a0 100644 --- a/NineAnimator/Controllers/RootViewController.swift +++ b/NineAnimator/Controllers/RootViewController.swift @@ -256,10 +256,22 @@ extension RootViewController { presentOnTop(errorAlert) } + func showConfirmationMessage() { + let confirmationAlert = UIAlertController( + title: "Backup Imported", + message: "This backup was imported successfully", + preferredStyle: .alert + ) + + confirmationAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) + presentOnTop(confirmationAlert) + } + alert.addAction(UIAlertAction(title: "Replace Current", style: .destructive) { _ in do { try replace(NineAnimator.default.user, with: config) + showConfirmationMessage() } catch { showErrorAlert(error: error) } @@ -269,6 +281,7 @@ extension RootViewController { _ in do { try merge(NineAnimator.default.user, with: config, policy: .localFirst) + showConfirmationMessage() } catch { showErrorAlert(error: error) } @@ -278,6 +291,7 @@ extension RootViewController { _ in do { try merge(NineAnimator.default.user, with: config, policy: .remoteFirst) + showConfirmationMessage() } catch { showErrorAlert(error: error) } From 3b0c3a8df53c4140a8f7769fb28dbfec8568805c Mon Sep 17 00:00:00 2001 From: uttiya10 <56562649+uttiya10@users.noreply.github.com> Date: Sat, 1 May 2021 21:33:52 -0400 Subject: [PATCH 2/7] Replaced "Configuration" with "Backup" for backup import alert --- NineAnimator/Controllers/RootViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NineAnimator/Controllers/RootViewController.swift b/NineAnimator/Controllers/RootViewController.swift index 5329d1a0..91e3998a 100644 --- a/NineAnimator/Controllers/RootViewController.swift +++ b/NineAnimator/Controllers/RootViewController.swift @@ -242,8 +242,8 @@ extension RootViewController { fileprivate func _restore(_ config: URL) { let alert = UIAlertController( - title: "Import Configurations", - message: "How do you want to import this configuration?", + title: "Import Backup", + message: "How do you want to import this backup?", preferredStyle: .alert ) From 9b19a2a50bb2f56e6d6908ac535f869d8aeb237f Mon Sep 17 00:00:00 2001 From: uttiya10 <56562649+uttiya10@users.noreply.github.com> Date: Sat, 1 May 2021 21:41:05 -0400 Subject: [PATCH 3/7] Fix Grammer for backup confirmation message --- NineAnimator/Controllers/RootViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NineAnimator/Controllers/RootViewController.swift b/NineAnimator/Controllers/RootViewController.swift index 91e3998a..20556a82 100644 --- a/NineAnimator/Controllers/RootViewController.swift +++ b/NineAnimator/Controllers/RootViewController.swift @@ -259,7 +259,7 @@ extension RootViewController { func showConfirmationMessage() { let confirmationAlert = UIAlertController( title: "Backup Imported", - message: "This backup was imported successfully", + message: "Backup was imported successfully", preferredStyle: .alert ) From c07a062779263b29cf0b97465b6f2900afecefbb Mon Sep 17 00:00:00 2001 From: uttiya10 <56562649+uttiya10@users.noreply.github.com> Date: Sat, 1 May 2021 21:44:56 -0400 Subject: [PATCH 4/7] Use navigate(toScene:) method when opening a AnyLink --- NineAnimator/Controllers/RootViewController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NineAnimator/Controllers/RootViewController.swift b/NineAnimator/Controllers/RootViewController.swift index 20556a82..a47eb622 100644 --- a/NineAnimator/Controllers/RootViewController.swift +++ b/NineAnimator/Controllers/RootViewController.swift @@ -203,9 +203,9 @@ extension RootViewController { if let navigationController = viewController.navigationController { navigationController.pushViewController(targetViewController, animated: true) } else { viewController.present(targetViewController, animated: true) } - } else { // If no view controller is provided, present the link in the featured tab - // Jump to Featured tab - selectedIndex = 0 + } else { + // If no view controller is provided, present the link in the watch next tab + navigate(toScene: .toWatch) guard let navigationController = viewControllers?.first as? ApplicationNavigationController else { Log.error("The first view controller is not ApplicationNavigationController.") From cbb7e1e955d13342750a6eb4b39c98cf512445b2 Mon Sep 17 00:00:00 2001 From: uttiya10 <56562649+uttiya10@users.noreply.github.com> Date: Sat, 1 May 2021 22:27:24 -0400 Subject: [PATCH 5/7] Fix bug where topViewController did not return the topmost view controller --- .../Controllers/RootViewController.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/NineAnimator/Controllers/RootViewController.swift b/NineAnimator/Controllers/RootViewController.swift index a47eb622..06905a4a 100644 --- a/NineAnimator/Controllers/RootViewController.swift +++ b/NineAnimator/Controllers/RootViewController.swift @@ -24,12 +24,23 @@ class RootViewController: UITabBarController, Themable { private weak var castControllerDelegate: AnyObject? + /// The top view controller visible by the user private var topViewController: UIViewController { - var topViewController: UIViewController = self - while let next = topViewController.presentedViewController { - topViewController = next + var topController: UIViewController = self + while true { + if let presentedController = topController.presentedViewController { + topController = presentedController + } // Special case for UINavigationController + else if let nav = topController as? UINavigationController, + let presentedController = nav.visibleViewController { + topController = presentedController + }// Special case for UITabBarController + else if let tab = topController as? UITabBarController, + let presentedController = tab.selectedViewController { + topController = presentedController + } else { break } } - return topViewController + return topController } override func viewDidLoad() { From b9db0f0136679e9518e4e3472df00cc067a53524 Mon Sep 17 00:00:00 2001 From: uttiya10 <56562649+uttiya10@users.noreply.github.com> Date: Sat, 1 May 2021 22:28:36 -0400 Subject: [PATCH 6/7] Fix comment spacing --- NineAnimator/Controllers/RootViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NineAnimator/Controllers/RootViewController.swift b/NineAnimator/Controllers/RootViewController.swift index 06905a4a..c20a9e35 100644 --- a/NineAnimator/Controllers/RootViewController.swift +++ b/NineAnimator/Controllers/RootViewController.swift @@ -34,7 +34,7 @@ class RootViewController: UITabBarController, Themable { else if let nav = topController as? UINavigationController, let presentedController = nav.visibleViewController { topController = presentedController - }// Special case for UITabBarController + } // Special case for UITabBarController else if let tab = topController as? UITabBarController, let presentedController = tab.selectedViewController { topController = presentedController From c45e50e07dc3ff1d64156e5a30f18b579fe70d71 Mon Sep 17 00:00:00 2001 From: uttiya10 <56562649+uttiya10@users.noreply.github.com> Date: Sat, 1 May 2021 22:38:11 -0400 Subject: [PATCH 7/7] Fix more code formatting.... dammit --- NineAnimator/Controllers/RootViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NineAnimator/Controllers/RootViewController.swift b/NineAnimator/Controllers/RootViewController.swift index c20a9e35..ab446080 100644 --- a/NineAnimator/Controllers/RootViewController.swift +++ b/NineAnimator/Controllers/RootViewController.swift @@ -32,11 +32,11 @@ class RootViewController: UITabBarController, Themable { topController = presentedController } // Special case for UINavigationController else if let nav = topController as? UINavigationController, - let presentedController = nav.visibleViewController { + let presentedController = nav.visibleViewController { topController = presentedController } // Special case for UITabBarController else if let tab = topController as? UITabBarController, - let presentedController = tab.selectedViewController { + let presentedController = tab.selectedViewController { topController = presentedController } else { break } }