diff --git a/enzevalos_iphone/AppDelegate.swift b/enzevalos_iphone/AppDelegate.swift index 553f9a4a05ea89107261723fafeb3e06eb532404..1b89fe945bbbcc58df148ca18037f438bd4a2627 100644 --- a/enzevalos_iphone/AppDelegate.swift +++ b/enzevalos_iphone/AppDelegate.swift @@ -132,7 +132,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } func showBadgeCase() { - self.window?.rootViewController = UIHostingController(rootView: BadgeCaseView()) + // self.window?.rootViewController = UIHostingController(rootView: BadgeCaseView()) + // return + guard let vc = self.window?.rootViewController as? UINavigationController else { + fatalError("No rootViewController!") + } + let nextVC = UIHostingController(rootView: BadgeCaseView()) + vc.navigationBar.isHidden = true + vc.pushViewController(nextVC, animated: true) } // Option removed from Settings app, but this might still be usefull in the future diff --git a/enzevalos_iphone/BadgeCaseView.swift b/enzevalos_iphone/BadgeCaseView.swift index b2627040641f97aab3f6e1314bd584bb18125ea6..1fc7518dd47c1fc67a863b7b2e0a09d05dde37ae 100644 --- a/enzevalos_iphone/BadgeCaseView.swift +++ b/enzevalos_iphone/BadgeCaseView.swift @@ -27,11 +27,35 @@ struct BadgeCaseView: View { } } } - }.navigationBarTitle(Text(NSLocalizedString("Gamification.Overview.HeaderTitle", comment:"Badge Case Navigation Title" )), displayMode: .inline).navigationBarItems(leading: titleIcon) + }.navigationBarTitle(Text(NSLocalizedString("Gamification.Overview.HeaderTitle", comment:"Badge Case Navigation Title" )), displayMode: .inline).navigationBarItems(leading: Button(action: goBack, label: { + Text("Back") + } + )) } } } +private func goBack() { + if let win = AppDelegate.getAppDelegate().window { + if let root = win.rootViewController { + print("Appdelegates current root: \(root.debugDescription)") + if let navi = root.navigationController { + navi.popViewController(animated: true) + } + else if let root = root as? UINavigationController { + print("Root is a UINavigationController -> we can pop!") + root.popViewController(animated: true) + } + else { + if let coord = AppDelegate.getAppDelegate().inboxCoordinator { + print("Inbox coord root: \(coord.root.topViewController.debugDescription)") + coord.root.popViewController(animated: true) + } + } + } + } + +} private var titleIcon: some View { HStack{ Image("verschluesseltOn")