Skip to content

Commit

Permalink
fix: file delete confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Nov 29, 2024
1 parent 595d701 commit 4f03d58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/Screens/File/FileToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct FileToolbar: ViewModifier {
fileStore.downloadIsPresented = true
},
onDelete: {
fileStore.deleteIsPresented = true
fileStore.deleteConfirmationIsPresented = true
},
onRename: {
fileStore.renameIsPresented = true
Expand Down
2 changes: 1 addition & 1 deletion Sources/Screens/File/Menu/FileActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct FileActions: ViewModifier {
fileStore.downloadIsPresented = true
},
onDelete: {
fileStore.deleteIsPresented = true
fileStore.deleteConfirmationIsPresented = true
},
onRename: {
fileStore.renameIsPresented = true
Expand Down
17 changes: 16 additions & 1 deletion Sources/Screens/File/Sheet/FileSheetDelete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ import SwiftUI

struct FileSheetDelete: ViewModifier {
@ObservedObject private var fileStore: FileStore
@State private var deleteIsPresented: Bool = false

init(fileStore: FileStore) {
self.fileStore = fileStore
}

func body(content: Content) -> some View {
content
.sheet(isPresented: $fileStore.deleteIsPresented) {
.alert(
fileStore.selection.count > 1 ? "Delete (\(fileStore.selection.count)) Items" : "Delete Item",
isPresented: $fileStore.deleteConfirmationIsPresented
) {
Button("Delete", role: .destructive) {
deleteIsPresented = true
}
} message: {
if fileStore.selection.count > 1 {
Text("Are you sure you want to delete these items?")
} else {
Text("Are you sure you want to delete this item?")
}
}
.sheet(isPresented: $deleteIsPresented) {
if !fileStore.selection.isEmpty {
FileDelete(fileStore: fileStore)
}
Expand Down

0 comments on commit 4f03d58

Please sign in to comment.