Skip to content

Instantly share code, notes, and snippets.

@GeekAndDad
Created April 3, 2020 23:20
Show Gist options
  • Save GeekAndDad/0474355f177ac8d47e6e87772c1678ba to your computer and use it in GitHub Desktop.
Save GeekAndDad/0474355f177ac8d47e6e87772c1678ba to your computer and use it in GitHub Desktop.
Bug? Two `.alert` modifiers mean only last one works?
//
// ContentView.swift
// TestAlert
//
//
import SwiftUI
struct ContentView: View {
@State private var showAlert1: Bool = false
@State private var showAlert2: Bool = false
var body: some View {
VStack {
Spacer()
Text("Hello, World!")
Button(action: { self.showAlert1 = true}, label: { Text("show Alert 1")})
Button(action: { self.showAlert2 = true}, label: { Text("show Alert 2")})
Spacer()
}
.alert(isPresented: self.$showAlert1, content: {
Alert(title: Text("Alert 1!"))
})
.alert(isPresented: self.$showAlert2, content: {
Alert(title: Text("Alert 2!"))
})
}
}
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