Created
April 3, 2020 23:20
-
-
Save GeekAndDad/0474355f177ac8d47e6e87772c1678ba to your computer and use it in GitHub Desktop.
Bug? Two `.alert` modifiers mean only last one works?
This file contains hidden or 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
// | |
// 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