Created
September 23, 2021 14:29
-
-
Save 4brunu/d75d9bd7f62d95f0b4830d3c56eb3c61 to your computer and use it in GitHub Desktop.
SwiftUI - show multiple alerts
This file contains 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
struct BlankView: View { | |
var body: some View { | |
Text("") | |
.frame(width: 0, height: 0) | |
.hidden() | |
} | |
} | |
struct MyScreenView: View { | |
var body: some View { | |
// loading alert | |
BlankView() | |
.alert(isPresented: $showLoadingAlert, content: { | |
Alert(title: Text("Logging in")) | |
}) | |
// error alert | |
BlankView() | |
.alert(isPresented: $showErrorAlert, content: { | |
Alert(title: Text("Wrong passcode"), message: Text("Enter again"), dismissButton: .default(Text("Confirm"))) | |
}) | |
VStack { | |
// Your View content | |
... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment