diff --git a/apps/ios/GuideDogs/Code/Visual UI/Helpers/View Controller Representable/AnyViewControllerRepresentable.swift b/apps/ios/GuideDogs/Code/Visual UI/Helpers/View Controller Representable/AnyViewControllerRepresentable.swift index 849dc3e5e..f8711b0a5 100644 --- a/apps/ios/GuideDogs/Code/Visual UI/Helpers/View Controller Representable/AnyViewControllerRepresentable.swift +++ b/apps/ios/GuideDogs/Code/Visual UI/Helpers/View Controller Representable/AnyViewControllerRepresentable.swift @@ -3,6 +3,7 @@ // Soundscape // // Copyright (c) Microsoft Corporation. +// Copyright (c) Soundscape Community Contributors. // Licensed under the MIT License. // @@ -31,8 +32,7 @@ struct AnyViewControllerRepresentable: ViewControllerRepresentable { sIdentifier = "Help" vIdentifier = "OfflinePage" case .routeGuidance: - sIdentifier = "RecreationalActivities" - vIdentifier = "RouteDetailsView" + return RouteDetailsViewHostingController.makeForActiveRoute() case .manageDevices: sIdentifier = "Devices" vIdentifier = "manageDevices" diff --git a/apps/ios/GuideDogs/Code/Visual UI/View Controllers/Home/HomeViewController.swift b/apps/ios/GuideDogs/Code/Visual UI/View Controllers/Home/HomeViewController.swift index 1ad3b50ca..b4383e4c3 100644 --- a/apps/ios/GuideDogs/Code/Visual UI/View Controllers/Home/HomeViewController.swift +++ b/apps/ios/GuideDogs/Code/Visual UI/View Controllers/Home/HomeViewController.swift @@ -26,7 +26,6 @@ class HomeViewController: UIViewController { // Main Menu Segues - static let showRecreationActivities = "ShowRecreationActivities" static let showManageDevices = "ShowManageDevices" static let showStatus = "ShowStatus" static let showHelp = "ShowHelpSegue" @@ -38,7 +37,7 @@ class HomeViewController: UIViewController { /// - Returns: The segue associated with this menu item static func segue(for menuItem: MenuItem) -> String? { switch menuItem { - case .recreation: return Segue.showRecreationActivities + case .recreation: return nil case .devices: return Segue.showManageDevices case .help: return Segue.showHelp case .settings: return Segue.showSettings @@ -322,27 +321,31 @@ class HomeViewController: UIViewController { logContext: telemetryContext ) } + + private func showRecreationActivities() { + show(AuthoredActivitiesListHostingController(), sender: self) + } private func showOrRefreshExperiences() { if navigationController?.visibleViewController is HomeViewController { - // The HomeViewController is currently the visible VC - segue to the AuthoredActivitiesList - performSegue(withIdentifier: Segue.showRecreationActivities, sender: self) + // The HomeViewController is currently visible - show the AuthoredActivitiesList + showRecreationActivities() } else if let vc = navigationController?.visibleViewController as? MenuViewController { - // The MenuViewController is currently the visible VC - dismiss it and segue to the AdaptiveSportsEventsList + // The MenuViewController is currently visible - dismiss it and show the AuthoredActivitiesList vc.dismiss(animated: true) { [weak self] in - self?.performSegue(withIdentifier: Segue.showRecreationActivities, sender: self) + self?.showRecreationActivities() } } else { - // Some other view controller is currently the visible VC - return to home and then segue to the AuthoredActivitiesList + // Return to home and then show the AuthoredActivitiesList CATransaction.begin() navigationController?.popToViewController(self, animated: true) CATransaction.setCompletionBlock { [weak self] in - self?.performSegue(withIdentifier: Segue.showRecreationActivities, sender: self) + self?.showRecreationActivities() } CATransaction.commit() @@ -477,12 +480,16 @@ extension HomeViewController: UIViewControllerTransitioningDelegate { guard finished else { return } + + if dismissed.selected == .recreation { + self?.showRecreationActivities() + return + } guard let segue = Segue.segue(for: dismissed.selected) else { return } - self?.performSegue(withIdentifier: segue, sender: self) } } diff --git a/apps/ios/GuideDogs/Code/Visual UI/Views/Authored Activities/AuthoredActivitiesListHostingController.swift b/apps/ios/GuideDogs/Code/Visual UI/Views/Authored Activities/AuthoredActivitiesListHostingController.swift index 4afd3eb3e..d28d9ad95 100644 --- a/apps/ios/GuideDogs/Code/Visual UI/Views/Authored Activities/AuthoredActivitiesListHostingController.swift +++ b/apps/ios/GuideDogs/Code/Visual UI/Views/Authored Activities/AuthoredActivitiesListHostingController.swift @@ -3,19 +3,25 @@ // Soundscape // // Copyright (c) Microsoft Corporation. +// Copyright (c) Soundscape Community Contributors. // Licensed under the MIT License. // import SwiftUI class AuthoredActivitiesListHostingController: UIHostingController { - required init?(coder aDecoder: NSCoder) { + init() { let navHelper = ViewNavigationHelper() let storage = AuthoredActivityStorage(AuthoredActivityLoader.shared) let view = AuthoredActivitiesList().environmentObject(storage).environmentObject(navHelper) - super.init(coder: aDecoder, rootView: AnyView(view)) + super.init(rootView: AnyView(view)) navHelper.host = self } + + @available(*, unavailable, message: "Use init()") + required init?(coder aDecoder: NSCoder) { + fatalError("Use init()") + } } diff --git a/apps/ios/GuideDogs/Code/Visual UI/Views/Beacon/BeaconToolbarView.swift b/apps/ios/GuideDogs/Code/Visual UI/Views/Beacon/BeaconToolbarView.swift index 4b9166e89..a49c2fa89 100644 --- a/apps/ios/GuideDogs/Code/Visual UI/Views/Beacon/BeaconToolbarView.swift +++ b/apps/ios/GuideDogs/Code/Visual UI/Views/Beacon/BeaconToolbarView.swift @@ -3,6 +3,7 @@ // Soundscape // // Copyright (c) Microsoft Corporation. +// Copyright (c) Soundscape Community Contributors. // Licensed under the MIT License. // @@ -82,9 +83,10 @@ struct BeaconToolbarView: View { // View details Button(action: { - let storyboard = UIStoryboard(name: "RecreationalActivities", bundle: Bundle.main) - let viewController = storyboard.instantiateViewController(withIdentifier: "RouteDetailsView") - + guard let viewController = RouteDetailsViewHostingController.makeForActiveRoute() else { + return + } + navHelper.pushViewController(viewController, animated: true) }, label: { Image(systemName: "info.circle.fill") diff --git a/apps/ios/GuideDogs/Code/Visual UI/Views/RecreationalActivities.storyboard b/apps/ios/GuideDogs/Code/Visual UI/Views/RecreationalActivities.storyboard deleted file mode 100644 index 08734074f..000000000 --- a/apps/ios/GuideDogs/Code/Visual UI/Views/RecreationalActivities.storyboard +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/ios/GuideDogs/Code/Visual UI/Views/Route Details/RouteDetailsViewHostingController.swift b/apps/ios/GuideDogs/Code/Visual UI/Views/Route Details/RouteDetailsViewHostingController.swift index b8188f91e..da32be7ff 100644 --- a/apps/ios/GuideDogs/Code/Visual UI/Views/Route Details/RouteDetailsViewHostingController.swift +++ b/apps/ios/GuideDogs/Code/Visual UI/Views/Route Details/RouteDetailsViewHostingController.swift @@ -3,24 +3,34 @@ // Soundscape // // Copyright (c) Microsoft Corporation. +// Copyright (c) Soundscape Community Contributors. // Licensed under the MIT License. // import SwiftUI class RouteDetailsViewHostingController: UIHostingController { - required init?(coder aDecoder: NSCoder) { - guard let routeGuidance = AppContext.shared.eventProcessor.activeBehavior as? RouteGuidance else { - return nil - } - + init(routeGuidance: RouteGuidance) { let navHelper = ViewNavigationHelper() let view = RouteDetailsView(routeGuidance.content, deleteAction: nil) .environmentObject(UserLocationStore()) .environmentObject(navHelper) - super.init(coder: aDecoder, rootView: AnyView(view)) + super.init(rootView: AnyView(view)) navHelper.host = self } + + @available(*, unavailable, message: "Use init(routeGuidance:)") + required init?(coder aDecoder: NSCoder) { + fatalError("Use init(routeGuidance:)") + } + + static func makeForActiveRoute() -> RouteDetailsViewHostingController? { + guard let routeGuidance = AppContext.shared.eventProcessor.activeBehavior as? RouteGuidance else { + return nil + } + + return RouteDetailsViewHostingController(routeGuidance: routeGuidance) + } } diff --git a/apps/ios/GuideDogs/Code/Visual UI/Views/main.storyboard b/apps/ios/GuideDogs/Code/Visual UI/Views/main.storyboard index 159acb72d..9a6746850 100644 --- a/apps/ios/GuideDogs/Code/Visual UI/Views/main.storyboard +++ b/apps/ios/GuideDogs/Code/Visual UI/Views/main.storyboard @@ -88,14 +88,6 @@ - - - - - - - - @@ -352,7 +344,6 @@ -