inline-code
How do you achieve this effect in toolbar? Where is the documentation for this?
- How to make it appear top toolbar or bottom toolbar?
Thank you!
Here is what I have now...
.toolbar {
ToolbarItem(placement: .destructiveAction) {
Button {
showConfirm = true
} label: {
Image(systemName: "trash")
.foregroundColor(.red)
}
}
}
.confirmationDialog(
"Are you sure?",
isPresented: $showConfirm,
titleVisibility: .visible
) {
Button("Delete Item", role: .destructive) {
print("Deleted")
}
Button("Archive", role: .none) {
print("Archived")
}
Button("Cancel", role: .cancel) { }
}
}
Figured out the implementation! For anyone interested in implementing in IOS 26+
@Namespace private var namespace
@State private var presentDialog: Bool = false
and in the toolbar
ToolbarItem(placement: .cancellationAction){
Button(role: .destructive) {
presentDialog = true
} label: {
Text("Delete")
}
.confirmationDialog(
"Delete?",
isPresented: $presentDialog,
titleVisibility: .visible
) {
Button("Delete", role: .destructive) {
// perform delete
}
Button("Cancel", role: .cancel) { }
}
}