// // 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 FileSystemItem)? // 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 { .init { item != nil } set: { _ in } } }