Implemented the DeleteItemViewModifier view modifier.
This commit is contained in:
parent
0438b1ad83
commit
27df9d3ffd
@ -25,6 +25,16 @@
|
|||||||
"message.type_not_supported.text.second" = "Please be patient while the support for this type of document is being built by our development team.";
|
"message.type_not_supported.text.second" = "Please be patient while the support for this type of document is being built by our development team.";
|
||||||
"message.type_not_supported.button.text" = "Go back to folder";
|
"message.type_not_supported.button.text" = "Go back to folder";
|
||||||
|
|
||||||
|
// DeleteItemViewModifier
|
||||||
|
|
||||||
|
"delete_item.action_sheet.title" = "Delete an item";
|
||||||
|
"delete_item.action_sheet.message" = "You are about to delete an item named \"%@\" from this folder.\n\nAre you sure you wish to proceed?";
|
||||||
|
"delete_item.action_sheet.button.ok" = "Yes, please delete it.";
|
||||||
|
"delete_item.action_sheet.button.cancel" = "No, I reconsidered.";
|
||||||
|
"delete_item.system_alert.title" = "...";
|
||||||
|
"delete_item.system_alert.message" = "...";
|
||||||
|
"delete_item.system_alert.button.dismiss" = "...";
|
||||||
|
|
||||||
// BrowseView
|
// BrowseView
|
||||||
|
|
||||||
"browse.toolbar_item.menu.add_actions.text" = "Add file and/or folder";
|
"browse.toolbar_item.menu.add_actions.text" = "Add file and/or folder";
|
||||||
|
@ -20,4 +20,10 @@ extension View {
|
|||||||
destination: { destination }
|
destination: { destination }
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func delete(
|
||||||
|
item: Binding<(any FileSystemItemIdentifiable)?>
|
||||||
|
) -> some View {
|
||||||
|
modifier(DeleteItemViewModifier(item: item))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
//
|
||||||
|
// DeleteItemViewModifier.swift
|
||||||
|
// Browse
|
||||||
|
//
|
||||||
|
// Created by Javier Cicchelli on 16/12/2022.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct DeleteItemViewModifier: ViewModifier {
|
||||||
|
|
||||||
|
// MARK: States
|
||||||
|
|
||||||
|
@State private var showErrorAlert: Bool = false
|
||||||
|
|
||||||
|
// MARK: Bindings
|
||||||
|
|
||||||
|
@Binding var item: (any FileSystemItemIdentifiable)?
|
||||||
|
|
||||||
|
// MARK: Body
|
||||||
|
|
||||||
|
func body(content: Content) -> some View {
|
||||||
|
content
|
||||||
|
.actionSheet(isPresented: showDeletionConfirmation) {
|
||||||
|
ActionSheet(
|
||||||
|
title: Text(
|
||||||
|
"delete_item.action_sheet.title",
|
||||||
|
bundle: .module
|
||||||
|
),
|
||||||
|
message: Text(
|
||||||
|
"delete_item.action_sheet.message",
|
||||||
|
bundle: .module
|
||||||
|
),
|
||||||
|
buttons: [
|
||||||
|
.destructive(Text(
|
||||||
|
"delete_item.action_sheet.button.ok",
|
||||||
|
bundle: .module
|
||||||
|
)) {
|
||||||
|
// TODO: implement the deletion of an item from the backend.
|
||||||
|
},
|
||||||
|
.cancel(Text(
|
||||||
|
"delete_item.action_sheet.button.cancel",
|
||||||
|
bundle: .module
|
||||||
|
)) {
|
||||||
|
item = nil
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.alert(isPresented: $showErrorAlert) {
|
||||||
|
Alert(
|
||||||
|
title: Text(
|
||||||
|
"delete_item.system_alert.title",
|
||||||
|
bundle: .module
|
||||||
|
),
|
||||||
|
message: Text(
|
||||||
|
"delete_item.system_alert.message",
|
||||||
|
bundle: .module
|
||||||
|
),
|
||||||
|
dismissButton: .cancel(Text(
|
||||||
|
"delete_item.system_alert.button.dismiss",
|
||||||
|
bundle: .module
|
||||||
|
))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Helpers
|
||||||
|
|
||||||
|
private extension DeleteItemViewModifier {
|
||||||
|
var showDeletionConfirmation: Binding<Bool> {
|
||||||
|
.init { item != nil } set: { _ in }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user