From d0b39e66413c9d3b4584cbdc6beada002b638bee Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 09:15:23 +0100 Subject: [PATCH] Moved all the Browse UI files into their own Browse module. --- BeReal.xcodeproj/project.pbxproj | 64 ------------------- BeReal/ContentView.swift | 1 + Modules/Package.swift | 7 +- .../Resources/en.lproj/Localizable.strings | 14 ++++ .../Browse/UI}/Components/DocumentItem.swift | 0 .../Browse/UI}/Components/FolderItem.swift | 0 .../Browse/UI}/Extensions/Image+Helpers.swift | 0 .../Browse/UI}/Extensions/Text+Helpers.swift | 0 .../Browse/UI}/Toolbars/BrowseToolbar.swift | 30 +++++++-- .../Sources/Browse/UI}/Views/BrowseView.swift | 23 +++++-- 10 files changed, 65 insertions(+), 74 deletions(-) create mode 100644 Modules/Sources/Browse/Resources/en.lproj/Localizable.strings rename {BeReal/Browse => Modules/Sources/Browse/UI}/Components/DocumentItem.swift (100%) rename {BeReal/Browse => Modules/Sources/Browse/UI}/Components/FolderItem.swift (100%) rename {BeReal/Browse => Modules/Sources/Browse/UI}/Extensions/Image+Helpers.swift (100%) rename {BeReal/Browse => Modules/Sources/Browse/UI}/Extensions/Text+Helpers.swift (100%) rename {BeReal/Browse => Modules/Sources/Browse/UI}/Toolbars/BrowseToolbar.swift (59%) rename {BeReal/Browse => Modules/Sources/Browse/UI}/Views/BrowseView.swift (84%) diff --git a/BeReal.xcodeproj/project.pbxproj b/BeReal.xcodeproj/project.pbxproj index 34c0285..a49d426 100644 --- a/BeReal.xcodeproj/project.pbxproj +++ b/BeReal.xcodeproj/project.pbxproj @@ -14,12 +14,6 @@ 02AE650029363DC1005A4AF3 /* BeRealTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02AE64FF29363DC1005A4AF3 /* BeRealTests.swift */; }; 02AE650A29363DC1005A4AF3 /* BeRealUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02AE650929363DC1005A4AF3 /* BeRealUITests.swift */; }; 02AE650C29363DC1005A4AF3 /* BeRealUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02AE650B29363DC1005A4AF3 /* BeRealUITestsLaunchTests.swift */; }; - 02B334E8293A93DC00C45E31 /* FolderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02B334E7293A93DC00C45E31 /* FolderItem.swift */; }; - 02CE5554293B130100730DC9 /* DocumentItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CE5553293B130100730DC9 /* DocumentItem.swift */; }; - 02CE5557293B134200730DC9 /* Image+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CE5556293B134200730DC9 /* Image+Helpers.swift */; }; - 02CE5559293B1AB600730DC9 /* Text+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CE5558293B1AB600730DC9 /* Text+Helpers.swift */; }; - 02CE555B293B1D8400730DC9 /* BrowseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CE555A293B1D8400730DC9 /* BrowseView.swift */; }; - 02CE555E293B34E900730DC9 /* BrowseToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CE555D293B34E900730DC9 /* BrowseToolbar.swift */; }; 02FFFD7B29395DD200306533 /* String+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02FFFD7A29395DD200306533 /* String+Constants.swift */; }; 4694AAA0293A7C8800D54903 /* Modules in Frameworks */ = {isa = PBXBuildFile; productRef = 4694AA9F293A7C8800D54903 /* Modules */; }; /* End PBXBuildFile section */ @@ -53,12 +47,6 @@ 02AE650529363DC1005A4AF3 /* BeRealUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BeRealUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 02AE650929363DC1005A4AF3 /* BeRealUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeRealUITests.swift; sourceTree = ""; }; 02AE650B29363DC1005A4AF3 /* BeRealUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeRealUITestsLaunchTests.swift; sourceTree = ""; }; - 02B334E7293A93DC00C45E31 /* FolderItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderItem.swift; sourceTree = ""; }; - 02CE5553293B130100730DC9 /* DocumentItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentItem.swift; sourceTree = ""; }; - 02CE5556293B134200730DC9 /* Image+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Image+Helpers.swift"; sourceTree = ""; }; - 02CE5558293B1AB600730DC9 /* Text+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Text+Helpers.swift"; sourceTree = ""; }; - 02CE555A293B1D8400730DC9 /* BrowseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowseView.swift; sourceTree = ""; }; - 02CE555D293B34E900730DC9 /* BrowseToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowseToolbar.swift; sourceTree = ""; }; 02FFFD7A29395DD200306533 /* String+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Constants.swift"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -113,7 +101,6 @@ 02AE64ED29363DBF005A4AF3 /* BeReal */ = { isa = PBXGroup; children = ( - 02B334E2293A908800C45E31 /* Browse */, 02FFFD7929395DBF00306533 /* Extensions */, 02AE64EE29363DBF005A4AF3 /* BeRealApp.swift */, 02AE64F029363DBF005A4AF3 /* ContentView.swift */, @@ -148,51 +135,6 @@ path = BeRealUITests; sourceTree = ""; }; - 02B334E2293A908800C45E31 /* Browse */ = { - isa = PBXGroup; - children = ( - 02CE5555293B131D00730DC9 /* Extensions */, - 02B334E6293A93CE00C45E31 /* Components */, - 02CE555C293B34CF00730DC9 /* Toolbars */, - 02B334E5293A93C400C45E31 /* Views */, - ); - path = Browse; - sourceTree = ""; - }; - 02B334E5293A93C400C45E31 /* Views */ = { - isa = PBXGroup; - children = ( - 02CE555A293B1D8400730DC9 /* BrowseView.swift */, - ); - path = Views; - sourceTree = ""; - }; - 02B334E6293A93CE00C45E31 /* Components */ = { - isa = PBXGroup; - children = ( - 02B334E7293A93DC00C45E31 /* FolderItem.swift */, - 02CE5553293B130100730DC9 /* DocumentItem.swift */, - ); - path = Components; - sourceTree = ""; - }; - 02CE5555293B131D00730DC9 /* Extensions */ = { - isa = PBXGroup; - children = ( - 02CE5556293B134200730DC9 /* Image+Helpers.swift */, - 02CE5558293B1AB600730DC9 /* Text+Helpers.swift */, - ); - path = Extensions; - sourceTree = ""; - }; - 02CE555C293B34CF00730DC9 /* Toolbars */ = { - isa = PBXGroup; - children = ( - 02CE555D293B34E900730DC9 /* BrowseToolbar.swift */, - ); - path = Toolbars; - sourceTree = ""; - }; 02FFFD7929395DBF00306533 /* Extensions */ = { isa = PBXGroup; children = ( @@ -342,15 +284,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 02CE555B293B1D8400730DC9 /* BrowseView.swift in Sources */, - 02B334E8293A93DC00C45E31 /* FolderItem.swift in Sources */, 02AE64F129363DBF005A4AF3 /* ContentView.swift in Sources */, - 02CE5554293B130100730DC9 /* DocumentItem.swift in Sources */, - 02CE5557293B134200730DC9 /* Image+Helpers.swift in Sources */, - 02CE5559293B1AB600730DC9 /* Text+Helpers.swift in Sources */, 02AE64EF29363DBF005A4AF3 /* BeRealApp.swift in Sources */, 02FFFD7B29395DD200306533 /* String+Constants.swift in Sources */, - 02CE555E293B34E900730DC9 /* BrowseToolbar.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/BeReal/ContentView.swift b/BeReal/ContentView.swift index 54fac04..d783c13 100644 --- a/BeReal/ContentView.swift +++ b/BeReal/ContentView.swift @@ -7,6 +7,7 @@ // import SwiftUI +import Browse import Login struct ContentView: View { diff --git a/Modules/Package.swift b/Modules/Package.swift index 98ab061..93ead91 100644 --- a/Modules/Package.swift +++ b/Modules/Package.swift @@ -12,7 +12,8 @@ let package = Package( .library( name: "Modules", targets: [ - "Login" + "Login", + "Browse" ] ), ], @@ -21,5 +22,9 @@ let package = Package( name: "Login", resources: [.process("Resources")] ), + .target( + name: "Browse", + resources: [.process("Resources")] + ) ] ) diff --git a/Modules/Sources/Browse/Resources/en.lproj/Localizable.strings b/Modules/Sources/Browse/Resources/en.lproj/Localizable.strings new file mode 100644 index 0000000..2724f95 --- /dev/null +++ b/Modules/Sources/Browse/Resources/en.lproj/Localizable.strings @@ -0,0 +1,14 @@ +/* + Localizable.strings + Browse + + Created by Javier Cicchelli on 03/12/2022. + Copyright © 2022 Röck+Cöde. All rights reserved. +*/ + +"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"; +"browse.swipe_action.delete_item.text" = "Delete item"; +"browse.swipe_action.download_item.text" = "Download item"; diff --git a/BeReal/Browse/Components/DocumentItem.swift b/Modules/Sources/Browse/UI/Components/DocumentItem.swift similarity index 100% rename from BeReal/Browse/Components/DocumentItem.swift rename to Modules/Sources/Browse/UI/Components/DocumentItem.swift diff --git a/BeReal/Browse/Components/FolderItem.swift b/Modules/Sources/Browse/UI/Components/FolderItem.swift similarity index 100% rename from BeReal/Browse/Components/FolderItem.swift rename to Modules/Sources/Browse/UI/Components/FolderItem.swift diff --git a/BeReal/Browse/Extensions/Image+Helpers.swift b/Modules/Sources/Browse/UI/Extensions/Image+Helpers.swift similarity index 100% rename from BeReal/Browse/Extensions/Image+Helpers.swift rename to Modules/Sources/Browse/UI/Extensions/Image+Helpers.swift diff --git a/BeReal/Browse/Extensions/Text+Helpers.swift b/Modules/Sources/Browse/UI/Extensions/Text+Helpers.swift similarity index 100% rename from BeReal/Browse/Extensions/Text+Helpers.swift rename to Modules/Sources/Browse/UI/Extensions/Text+Helpers.swift diff --git a/BeReal/Browse/Toolbars/BrowseToolbar.swift b/Modules/Sources/Browse/UI/Toolbars/BrowseToolbar.swift similarity index 59% rename from BeReal/Browse/Toolbars/BrowseToolbar.swift rename to Modules/Sources/Browse/UI/Toolbars/BrowseToolbar.swift index 5508bf8..746a3ba 100644 --- a/BeReal/Browse/Toolbars/BrowseToolbar.swift +++ b/Modules/Sources/Browse/UI/Toolbars/BrowseToolbar.swift @@ -16,7 +16,11 @@ struct BrowseToolbar: ToolbarContent { // TODO: Implement the creation of a new folder. } label: { Label { - Text("Create a new folder") + Text( + "browse.toolbar_item.button.add_folder.text", + bundle: .module, + comment: "Add folder button text." + ) } icon: { Image.newFolder } @@ -26,14 +30,22 @@ struct BrowseToolbar: ToolbarContent { // TODO: Implement the upload of a file from the device to the API. } label: { Label { - Text("Upload a file") + Text( + "browse.toolbar_item.button.add_file.text", + bundle: .module, + comment: "Add file button text." + ) } icon: { Image.newFile } } } label: { Label { - Text("Add file and/or folder") + Text( + "browse.toolbar_item.menu.add_actions.text", + bundle: .module, + comment: "Add actions menu text." + ) } icon: { Image.add .foregroundColor(.red) @@ -45,8 +57,16 @@ struct BrowseToolbar: ToolbarContent { Button { // TODO: Implement the show of the user profile. } label: { - Image.profile - .foregroundColor(.red) + Label { + Text( + "browse.toolbar_item.button.show_profile.text", + bundle: .module, + comment: "Show profile button text." + ) + } icon: { + Image.profile + .foregroundColor(.red) + } } } } diff --git a/BeReal/Browse/Views/BrowseView.swift b/Modules/Sources/Browse/UI/Views/BrowseView.swift similarity index 84% rename from BeReal/Browse/Views/BrowseView.swift rename to Modules/Sources/Browse/UI/Views/BrowseView.swift index 5fc1369..18fcf98 100644 --- a/BeReal/Browse/Views/BrowseView.swift +++ b/Modules/Sources/Browse/UI/Views/BrowseView.swift @@ -8,8 +8,15 @@ import SwiftUI -struct BrowseView: View { - var body: some View { +public struct BrowseView: View { + + // MARK: Initialisers + + public init() {} + + // MARK: Body + + public var body: some View { List { Group { Group { @@ -67,7 +74,11 @@ struct BrowseView: View { // TODO: Implement the removal of the item from the API. } label: { Label { - Text("Delete item") + Text( + "browse.swipe_action.delete_item.text", + bundle: .module, + comment: "Delete item swipe action text." + ) } icon: { Image.trash } @@ -79,7 +90,11 @@ struct BrowseView: View { // TODO: Implement the downloading of the data of the item from the API into the device. } label: { Label { - Text("Download item") + Text( + "browse.swipe_action.download_item.text", + bundle: .module, + comment: "Download item swipe action text." + ) } icon: { Image.download }