Skip to content

Instantly share code, notes, and snippets.

@b3ll
Created May 9, 2023 09:11
Show Gist options
  • Save b3ll/61bee477ee1dd06475b3e7b699269eb3 to your computer and use it in GitHub Desktop.
Save b3ll/61bee477ee1dd06475b3e7b699269eb3 to your computer and use it in GitHub Desktop.
y tho
// 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