From d242171c6e580af6f55fdb2135aebe376af0ef05 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 18 Dec 2022 01:07:04 +0100 Subject: [PATCH] Implemented the DocumentToolbar toolbar content for the Browse module. --- .../Resources/en.lproj/Localizable.strings | 6 ++- .../Browse/UI/Toolbars/BrowseToolbar.swift | 12 ++---- .../Browse/UI/Toolbars/DocumentToolbar.swift | 42 +++++++++++++++++++ 3 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 Modules/Sources/Browse/UI/Toolbars/DocumentToolbar.swift diff --git a/Modules/Sources/Browse/Resources/en.lproj/Localizable.strings b/Modules/Sources/Browse/Resources/en.lproj/Localizable.strings index fd36893..01712b8 100644 --- a/Modules/Sources/Browse/Resources/en.lproj/Localizable.strings +++ b/Modules/Sources/Browse/Resources/en.lproj/Localizable.strings @@ -46,12 +46,16 @@ "delete_item.system_alert.message" = "An unexpected error occurred while trying to delete the indicated folder from the current folder.\n\nPlease check your Internet connection and try this operation at a later time."; "delete_item.system_alert.button.cancel" = "Understood"; -// BrowseView +// BrowseToolbar "browse.toolbar_item.menu.add_actions.text" = "Add file and/or folder"; "browse.toolbar_item.button.add_folder.text" = "Create a new folder"; "browse.toolbar_item.button.add_file.text" = "Upload a file"; "browse.toolbar_item.button.show_profile.text" = "Show profile"; +// DocumentToolbar + +"document.toolbar_item.button.download_file.text" = "Download this file"; + "browse.swipe_action.delete_item.text" = "Delete item"; "browse.swipe_action.download_item.text" = "Download item"; diff --git a/Modules/Sources/Browse/UI/Toolbars/BrowseToolbar.swift b/Modules/Sources/Browse/UI/Toolbars/BrowseToolbar.swift index 5f2d65c..07b913a 100644 --- a/Modules/Sources/Browse/UI/Toolbars/BrowseToolbar.swift +++ b/Modules/Sources/Browse/UI/Toolbars/BrowseToolbar.swift @@ -28,8 +28,7 @@ struct BrowseToolbar: ToolbarContent { Label { Text( "browse.toolbar_item.button.add_folder.text", - bundle: .module, - comment: "Add folder button text." + bundle: .module ) } icon: { Image.newFolder @@ -42,8 +41,7 @@ struct BrowseToolbar: ToolbarContent { Label { Text( "browse.toolbar_item.button.add_file.text", - bundle: .module, - comment: "Add file button text." + bundle: .module ) } icon: { Image.newFile @@ -53,8 +51,7 @@ struct BrowseToolbar: ToolbarContent { Label { Text( "browse.toolbar_item.menu.add_actions.text", - bundle: .module, - comment: "Add actions menu text." + bundle: .module ) } icon: { Image.add @@ -72,8 +69,7 @@ struct BrowseToolbar: ToolbarContent { Label { Text( "browse.toolbar_item.button.show_profile.text", - bundle: .module, - comment: "Show profile button text." + bundle: .module ) } icon: { Image.profile diff --git a/Modules/Sources/Browse/UI/Toolbars/DocumentToolbar.swift b/Modules/Sources/Browse/UI/Toolbars/DocumentToolbar.swift new file mode 100644 index 0000000..90a5aaf --- /dev/null +++ b/Modules/Sources/Browse/UI/Toolbars/DocumentToolbar.swift @@ -0,0 +1,42 @@ +// +// DocumentToolbar.swift +// Browse +// +// Created by Javier Cicchelli on 18/12/2022. +// Copyright © 2022 Röck+Cöde. All rights reserved. +// + +import DataModels +import SwiftUI + +struct DocumentToolbar: ToolbarContent { + + // MARK: Properties + + let disabled: Bool + let downloadFile: ActionClosure + + // MARK: Body + + var body: some ToolbarContent { + ToolbarItem(placement: .primaryAction) { + Button { + downloadFile() + } label: { + Label { + Text( + "document.toolbar_item.button.download_file.text", + bundle: .module + ) + } icon: { + Image.download + .resizable() + .scaledToFit() + .frame(width: 24, height: 24) + } + } + .disabled(disabled) + } + } + +}