Created
May 9, 2023 09:11
-
-
Save b3ll/61bee477ee1dd06475b3e7b699269eb3 to your computer and use it in GitHub Desktop.
y tho
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
// Why does this work? | |
Menu { | |
Button { | |
print("applied") | |
} label: { | |
Text("Apply to All") | |
} | |
Button(role: .destructive) { | |
self.showingDeleteConfirmAlert = true | |
} label: { | |
Text("Delete") | |
} | |
} label: { | |
Image(systemName: "ellipsis.circle") | |
} | |
.alert(isPresented: $showingDeleteConfirmAlert) { | |
Alert(title: Text("Delete?"), | |
message: Text("You sure?"), | |
primaryButton: .cancel(Text("Cancel")), | |
secondaryButton: .destructive(Text("Delete"), action: { delete() }) ) | |
} | |
// And not this? | |
Menu { | |
Button { | |
print("applied") | |
} label: { | |
Text("Apply to All") | |
} | |
Button(role: .destructive) { | |
self.showingDeleteConfirmAlert = true | |
} label: { | |
Text("Delete") | |
} | |
.alert(isPresented: $showingDeleteConfirmAlert) { | |
Alert(title: Text("Delete?"), | |
message: Text("You sure?"), | |
primaryButton: .cancel(Text("Cancel")), | |
secondaryButton: .destructive(Text("Delete"), action: { delete() }) ) | |
} | |
} label: { | |
Image(systemName: "ellipsis.circle") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment