apply delete label alert on macOS

This commit is contained in:
Satindar Dhillon
2022-06-27 16:06:56 -07:00
parent ae4f82ac5c
commit ed70ceb2c4

View File

@ -17,21 +17,6 @@ struct LabelsView: View {
#if os(iOS)
Form {
innerBody
.alert("Are you sure you want to delete this label?", isPresented: $showDeleteConfirmation) {
Button("Delete Label", role: .destructive) {
if let label = labelToRemove {
withAnimation {
viewModel.deleteLabel(
dataService: dataService,
labelID: label.unwrappedID,
name: label.unwrappedName
)
}
}
self.labelToRemove = nil
}
Button("Cancel", role: .cancel) { self.labelToRemove = nil }
}
}
#elseif os(macOS)
List {
@ -39,6 +24,21 @@ struct LabelsView: View {
}
#endif
}
.alert("Are you sure you want to delete this label?", isPresented: $showDeleteConfirmation) {
Button("Delete Label", role: .destructive) {
if let label = labelToRemove {
withAnimation {
viewModel.deleteLabel(
dataService: dataService,
labelID: label.unwrappedID,
name: label.unwrappedName
)
}
}
self.labelToRemove = nil
}
Button("Cancel", role: .cancel) { self.labelToRemove = nil }
}
.sheet(isPresented: $viewModel.showCreateLabelModal) {
CreateLabelView(viewModel: viewModel)
}