diff --git a/enzevalos_iphone/AppDelegate.swift b/enzevalos_iphone/AppDelegate.swift index 1b89fe945bbbcc58df148ca18037f438bd4a2627..2969dac058f58bba50535a67900115dc29cf5a46 100644 --- a/enzevalos_iphone/AppDelegate.swift +++ b/enzevalos_iphone/AppDelegate.swift @@ -132,8 +132,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } func showBadgeCase() { - // self.window?.rootViewController = UIHostingController(rootView: BadgeCaseView()) - // return guard let vc = self.window?.rootViewController as? UINavigationController else { fatalError("No rootViewController!") } diff --git a/enzevalos_iphone/BadgeCaseView.swift b/enzevalos_iphone/BadgeCaseView.swift index b2c295122c93911ae624ae03160363e2b27eebff..8ffed6480fc7bfb2b61e06c79ade1b63d068b988 100644 --- a/enzevalos_iphone/BadgeCaseView.swift +++ b/enzevalos_iphone/BadgeCaseView.swift @@ -12,17 +12,8 @@ struct BadgeCaseView: View { init() { UITableView.appearance().separatorStyle = .none } - let badges: [Badge] = GamificationData.sharedInstance.badges.map { Badge(type: $0.type, description: $0.displayName, imageOn: $0.onName, imageOff: $0.offName, isActive: $0.isAchieved()) } - var userRecord: KeyRecord { - get { - let keyID = UserManager.loadUserValue(Attribute.prefSecretKeyID) as? String - let addr = UserManager.loadUserValue(Attribute.userAddr) as! String - return DataHandler.handler.getKeyRecord(addr: addr, keyID: keyID) - } - } - var body: some View { NavigationView { VStack { @@ -37,56 +28,15 @@ struct BadgeCaseView: View { } }.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") - .resizable() - .scaledToFit() - .frame(width: 40,height: 40) - .padding(10) + + func goBack() { + if let coord = AppDelegate.getAppDelegate().inboxCoordinator { + coord.goBack() } } - private var backButton: some View { - VStack { - Button(action: goBack) { - Text("< My ID") - } - } - } - /* - func goBack() { - if let coord = AppDelegate.getAppDelegate().inboxCoordinator { - coord.pushInbox() - } - } - */ } struct Badge: Identifiable { diff --git a/enzevalos_iphone/SwiftUI/Inbox/InboxCoordinator.swift b/enzevalos_iphone/SwiftUI/Inbox/InboxCoordinator.swift index f1e3b56bfc5c6d0742427075165c93ac4b838f91..f168e8b434fb92f4550b06416940231ffa319aef 100644 --- a/enzevalos_iphone/SwiftUI/Inbox/InboxCoordinator.swift +++ b/enzevalos_iphone/SwiftUI/Inbox/InboxCoordinator.swift @@ -22,6 +22,10 @@ class InboxCoordinator { mainStoryboard = UIStoryboard(name: self.mainStoryboardName, bundle: nil) } + func goBack() { + root.popViewController(animated: true) + } + func pushInbox(){ try? AppDelegate.getAppDelegate().mailHandler.startIMAPIdleIfSupported() AppDelegate.getAppDelegate().mailHandler.updateFolder(folder: Folder.inbox, completionCallback: {_ in @@ -31,9 +35,7 @@ class InboxCoordinator { if let vc = inbox { if root.viewControllers.contains(vc) { - while root.topViewController != vc { - root.popViewController(animated: true) - } + root.popToViewController(vc, animated: false) } else { root.pushViewController(vc, animated: true) }