Skip to content

Instantly share code, notes, and snippets.

@IsaAliev
Created August 12, 2021 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IsaAliev/8333185637759e02f1d3f01c669b3250 to your computer and use it in GitHub Desktop.
Save IsaAliev/8333185637759e02f1d3f01c669b3250 to your computer and use it in GitHub Desktop.
struct AccountView: View {
@State var showsModal: Bool = false
// 1 - Add EnvironmentObject variable to set your modal view
@EnvironmentObject var fullScreenModal: FullScreenModalProvider
var body: some View {
ZStack {
Button("Show modal") {
withAnimation {
// 2 - Set your modal view to content property
fullScreenModal.content = AnyView(
ModalView {
// 3 - Set content property to nil ti dismiss
fullScreenModal.content = nil
}
)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment