diff options
author | Marc Stibane <marc@taler.net> | 2024-01-18 00:40:17 +0100 |
---|---|---|
committer | Marc Stibane <marc@taler.net> | 2024-01-18 00:40:17 +0100 |
commit | eaa421cfe14a078ce46b66d0cdf2ead907071ed1 (patch) | |
tree | 0893468c726177a276fd8e848424676add6db357 | |
parent | f5d399ef4239c5be20f7c9bb8d1ec8d1d14e87d8 (diff) | |
download | taler-ios-eaa421cfe14a078ce46b66d0cdf2ead907071ed1.tar.gz taler-ios-eaa421cfe14a078ce46b66d0cdf2ead907071ed1.tar.bz2 taler-ios-eaa421cfe14a078ce46b66d0cdf2ead907071ed1.zip |
return to Balances after tx
-rw-r--r-- | TalerWallet1/Helper/View+dismissTop.swift | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/TalerWallet1/Helper/View+dismissTop.swift b/TalerWallet1/Helper/View+dismissTop.swift index 3d11bd0..2e2a92a 100644 --- a/TalerWallet1/Helper/View+dismissTop.swift +++ b/TalerWallet1/Helper/View+dismissTop.swift @@ -35,12 +35,31 @@ extension View { if gotPresented { topController.dismiss(animated: animated) } else { - print("Yikes❗️ Trying to dismiss the rootViewController!") + Self.findNavigationController(viewController: topController)?.popToRootViewController(animated: animated) } } else { print("Yikes❗️ There is no window/rootViewController!") } } + @MainActor static func findNavigationController(viewController: UIViewController?) -> UINavigationController? { + guard let viewController = viewController else { + return nil + } + + if let navigationController = viewController as? UITabBarController { + return findNavigationController(viewController: navigationController.selectedViewController) + } + + if let navigationController = viewController as? UINavigationController { + return navigationController + } + + for childViewController in viewController.children { + return findNavigationController(viewController: childViewController) + } + + return nil + } } // MARK: - extension View { |