Skip to content

Instantly share code, notes, and snippets.

@archieedwards
Created May 25, 2020 13:42
Show Gist options
  • Save archieedwards/46bbe46e0706b7b85a82b68f95c58528 to your computer and use it in GitHub Desktop.
Save archieedwards/46bbe46e0706b7b85a82b68f95c58528 to your computer and use it in GitHub Desktop.
struct ContentView: View {
@State var showAlert = false
var body: some View {
Button(action: {
self.showAlert.toggle()
}, label: {
Text("SHOW ALERT")
})
.alert(isPresented: self.$showAlert, content: {
Alert(title: Text("I'm an alert"), message: Text("Are you sure you want to do this?"), primaryButton: .default(Text("Yes"), action: {
/// insert action for when user confirms they want to do this action
}), secondaryButton: .cancel())
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment