Skip to content

Instantly share code, notes, and snippets.

@dheerajn
Last active September 15, 2021 22:43
Show Gist options
  • Save dheerajn/d119a441ce2770fe75ab1eb889c895f7 to your computer and use it in GitHub Desktop.
Save dheerajn/d119a441ce2770fe75ab1eb889c895f7 to your computer and use it in GitHub Desktop.
struct ContentView: View {
@State private var shouldShowAlert1 = false
@State private var shouldShowAlert2 = false
@State private var shouldShowAlert3 = false
var body: some View {
VStack {
Button("Tap here to present Alert - 1") {
shouldShowAlert1 = true
}
.alert(isPresented: $shouldShowAlert1) {
Alert(title: Text("Showing Alert 1"), message: nil, dismissButton: .cancel())
}
Button("Tap here to present Alert - 2") {
shouldShowAlert2 = true
}
.alert(isPresented: $shouldShowAlert2) {
Alert(title: Text("Showing Alert 2"), message: nil, dismissButton: .cancel())
}
Button("Tap here to present Alert - 3") {
shouldShowAlert3 = true
}
.alert(isPresented: $shouldShowAlert3) {
Alert(title: Text("Showing Alert 3"), message: nil, dismissButton: .cancel())
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment