-
-
Save laevandus/2307c0f99063ca20d7ecd2330e7c4e1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class FlowCoordinator: ObservableObject { | |
// … | |
func showDetailView() { | |
let detailView = DetailView() | |
.environmentObject(self) | |
let viewController = UIHostingController(rootView: detailView) | |
window.rootViewController?.present(viewController, animated: true, completion: nil) | |
} | |
func closeDetailView() { | |
// Needs to be more sophisticated later when there are more views | |
window.rootViewController?.presentedViewController?.dismiss(animated: true, completion: nil) | |
} | |
} | |
struct DetailView: View { | |
@EnvironmentObject var flowController: FlowCoordinator | |
var body: some View { | |
VStack(spacing: 8) { | |
Text("Detail view content") | |
Button("Dismiss", action: flowController.closeDetailView) | |
}.frame(maxWidth: .infinity, maxHeight: .infinity) | |
.background(.orange) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment