i'm trying to show a confirmation alert after you press the "Confirm" button on the first alert. Idea: You press a button and an alert pops up that asks you to cancel or confirm the action. When you press cancel, the alert gets dismissed and when you press confirm, the action gets performed and a second alert pops up that says something like (title: "Success", message: "the action was successful)" with just a dismiss button. The first alert works just fine and it does the action, but when i add the second alert right after the first alert, the first alert won't show anymore when pressing the button.
code:
Group {
Button(action: { self.showingAdminAlert = true }, label: {
Text("Als Admin hinzufügen").fontWeight(.bold).font(.system(size: 15)).padding().background(Color.gray).cornerRadius(40).foregroundColor(.white).padding(10).overlay(RoundedRectangle(cornerRadius: 40).stroke(Color.gray, lineWidth: 5))
}).padding().padding()
}.alert(isPresented: $showingAdminAlert) {
Alert(title: Text("Bestätigung erforderlich"), message: Text("Wollen sie \(data.vn) \(data.nn) wirklich die Berechtigung Admin erteilen?"), primaryButton: .cancel(Text("Abbrechen")), secondaryButton: .default(Text("Bestätigen")) {
self.AddUserAsAdmin()
self.showingAdminAlertConfirmation = true
})
}.alert(isPresented: $showingAdminAlertConfirmation) {
Alert(title: Text("Erfolgreich"), message: Text("Berechtigung Admin erfolgreich an \(data.vn) \(data.nn) vergeben!"), dismissButton: .default(Text("Zurück")))
}