From d108f176467024d4a97122dc0938cda072ffa008 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 06:15:33 +0100 Subject: [PATCH 1/9] Implemented the FolderItem view component. --- BeReal.xcodeproj/project.pbxproj | 36 ++++++++--- BeReal/Browse/Components/FolderItem.swift | 74 +++++++++++++++++++++++ 2 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 BeReal/Browse/Components/FolderItem.swift diff --git a/BeReal.xcodeproj/project.pbxproj b/BeReal.xcodeproj/project.pbxproj index c9f7f8b..dbb11e5 100644 --- a/BeReal.xcodeproj/project.pbxproj +++ b/BeReal.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 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 */; }; 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 */ @@ -47,6 +48,7 @@ 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 = ""; }; 02FFFD7A29395DD200306533 /* String+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Constants.swift"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -76,13 +78,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 027F60592937662300467238 /* Login */ = { - isa = PBXGroup; - children = ( - ); - path = Login; - sourceTree = ""; - }; 02AE64E229363DBF005A4AF3 = { isa = PBXGroup; children = ( @@ -108,8 +103,8 @@ 02AE64ED29363DBF005A4AF3 /* BeReal */ = { isa = PBXGroup; children = ( + 02B334E2293A908800C45E31 /* Browse */, 02FFFD7929395DBF00306533 /* Extensions */, - 027F60592937662300467238 /* Login */, 02AE64EE29363DBF005A4AF3 /* BeRealApp.swift */, 02AE64F029363DBF005A4AF3 /* ContentView.swift */, 02AE64F229363DC1005A4AF3 /* Assets.xcassets */, @@ -143,6 +138,30 @@ path = BeRealUITests; sourceTree = ""; }; + 02B334E2293A908800C45E31 /* Browse */ = { + isa = PBXGroup; + children = ( + 02B334E6293A93CE00C45E31 /* Components */, + 02B334E5293A93C400C45E31 /* Views */, + ); + path = Browse; + sourceTree = ""; + }; + 02B334E5293A93C400C45E31 /* Views */ = { + isa = PBXGroup; + children = ( + ); + path = Views; + sourceTree = ""; + }; + 02B334E6293A93CE00C45E31 /* Components */ = { + isa = PBXGroup; + children = ( + 02B334E7293A93DC00C45E31 /* FolderItem.swift */, + ); + path = Components; + sourceTree = ""; + }; 02FFFD7929395DBF00306533 /* Extensions */ = { isa = PBXGroup; children = ( @@ -292,6 +311,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 02B334E8293A93DC00C45E31 /* FolderItem.swift in Sources */, 02AE64F129363DBF005A4AF3 /* ContentView.swift in Sources */, 02AE64EF29363DBF005A4AF3 /* BeRealApp.swift in Sources */, 02FFFD7B29395DD200306533 /* String+Constants.swift in Sources */, diff --git a/BeReal/Browse/Components/FolderItem.swift b/BeReal/Browse/Components/FolderItem.swift new file mode 100644 index 0000000..d712996 --- /dev/null +++ b/BeReal/Browse/Components/FolderItem.swift @@ -0,0 +1,74 @@ +// +// FolderItem.swift +// Browse +// +// Created by Javier Cicchelli on 02/12/2022. +// Copyright © 2022 Röck+Cöde. All rights reserved. +// + +import SwiftUI + +struct FolderItem: View { + + // MARK: Properties + + let name: String + + // MARK: Body + + var body: some View { + HStack(spacing: 16) { + Image.folder + .icon(size: 32) + .foregroundColor(.red) + + Text(name) + .font(.headline) + .foregroundColor(.primary) + .lineLimit(1) + .truncationMode(.middle) + .frame(maxWidth: .infinity, alignment: .leading) + + Image.chevronRight + .icon(size: 16) + .foregroundColor(.secondary) + .font(.headline) + } + .padding(16) + } + +} + +// MARK: - Image + +private extension Image { + + // MARK: Constants + + static let folder = Image(systemName: "folder.fill") + static let document = Image(systemName: "doc.fill") + static let chevronRight = Image(systemName: "chevron.right") + + // MARK: Functions + + func icon(size: CGFloat) -> some View { + self + .resizable() + .renderingMode(.template) + .scaledToFit() + .frame(width: size, height: size) + } + +} + +// MARK: - Previews + +struct BrowseItem_Previews: PreviewProvider { + static var previews: some View { + FolderItem(name: "Some folder name goes in here...") + .previewDisplayName("Browse item for folders") + + FolderItem(name: "Some very, extremely long folder name goes in here...") + .previewDisplayName("Browse item for folders with long name") + } +} From dafef542f1ce7ad904ec752f993b5c930259396b Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 06:56:38 +0100 Subject: [PATCH 2/9] Implemented the DocumentItem view component and also, moved some UI code to the Image+Helpers and Text+Helpers extensions. --- BeReal.xcodeproj/project.pbxproj | 20 ++++++ BeReal/Browse/Components/DocumentItem.swift | 71 ++++++++++++++++++++ BeReal/Browse/Components/FolderItem.swift | 27 ++------ BeReal/Browse/Extensions/Image+Helpers.swift | 24 +++++++ BeReal/Browse/Extensions/Text+Helpers.swift | 23 +++++++ 5 files changed, 142 insertions(+), 23 deletions(-) create mode 100644 BeReal/Browse/Components/DocumentItem.swift create mode 100644 BeReal/Browse/Extensions/Image+Helpers.swift create mode 100644 BeReal/Browse/Extensions/Text+Helpers.swift diff --git a/BeReal.xcodeproj/project.pbxproj b/BeReal.xcodeproj/project.pbxproj index dbb11e5..7cbebec 100644 --- a/BeReal.xcodeproj/project.pbxproj +++ b/BeReal.xcodeproj/project.pbxproj @@ -15,6 +15,9 @@ 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 */; }; 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 */ @@ -49,6 +52,9 @@ 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 = ""; }; 02FFFD7A29395DD200306533 /* String+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Constants.swift"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -141,6 +147,7 @@ 02B334E2293A908800C45E31 /* Browse */ = { isa = PBXGroup; children = ( + 02CE5555293B131D00730DC9 /* Extensions */, 02B334E6293A93CE00C45E31 /* Components */, 02B334E5293A93C400C45E31 /* Views */, ); @@ -158,10 +165,20 @@ 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 = ""; + }; 02FFFD7929395DBF00306533 /* Extensions */ = { isa = PBXGroup; children = ( @@ -313,6 +330,9 @@ files = ( 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 */, ); diff --git a/BeReal/Browse/Components/DocumentItem.swift b/BeReal/Browse/Components/DocumentItem.swift new file mode 100644 index 0000000..8b6f311 --- /dev/null +++ b/BeReal/Browse/Components/DocumentItem.swift @@ -0,0 +1,71 @@ +// +// DocumentItem.swift +// Browse +// +// Created by Javier Cicchelli on 03/12/2022. +// Copyright © 2022 Röck+Cöde. All rights reserved. +// + +import SwiftUI + +struct DocumentItem: View { + + // MARK: Properties + + let name: String + let lastModified: String + let fileSize: String + + // MARK: Body + + var body: some View { + HStack(spacing: 16) { + Image.document + .icon(size: 32) + .foregroundColor(.red) + + VStack { + Text(name) + .itemName() + + HStack { + Text(lastModified) + + Spacer() + + Text(fileSize) + } + .font(.subheadline) + .foregroundColor(.secondary) + } + } + .padding(16) + } + +} + +// MARK: - Image+Constants + +private extension Image { + static let document = Image(systemName: "doc.fill") +} + +// MARK: - Previews + +struct DocumentItem_Previews: PreviewProvider { + static var previews: some View { + DocumentItem( + name: "Some document name goes in here...", + lastModified: "Some few hours ago", + fileSize: "23,5 Mbytes" + ) + .previewDisplayName("Document item") + + DocumentItem( + name: "Some very, extremely long document name goes in here...", + lastModified: "Yesterday", + fileSize: "235,6 Kbytes" + ) + .previewDisplayName("Document item with long name") + } +} diff --git a/BeReal/Browse/Components/FolderItem.swift b/BeReal/Browse/Components/FolderItem.swift index d712996..bb1862b 100644 --- a/BeReal/Browse/Components/FolderItem.swift +++ b/BeReal/Browse/Components/FolderItem.swift @@ -23,11 +23,7 @@ struct FolderItem: View { .foregroundColor(.red) Text(name) - .font(.headline) - .foregroundColor(.primary) - .lineLimit(1) - .truncationMode(.middle) - .frame(maxWidth: .infinity, alignment: .leading) + .itemName() Image.chevronRight .icon(size: 16) @@ -39,26 +35,11 @@ struct FolderItem: View { } -// MARK: - Image +// MARK: - Image+Constants private extension Image { - - // MARK: Constants - static let folder = Image(systemName: "folder.fill") - static let document = Image(systemName: "doc.fill") static let chevronRight = Image(systemName: "chevron.right") - - // MARK: Functions - - func icon(size: CGFloat) -> some View { - self - .resizable() - .renderingMode(.template) - .scaledToFit() - .frame(width: size, height: size) - } - } // MARK: - Previews @@ -66,9 +47,9 @@ private extension Image { struct BrowseItem_Previews: PreviewProvider { static var previews: some View { FolderItem(name: "Some folder name goes in here...") - .previewDisplayName("Browse item for folders") + .previewDisplayName("Folder item") FolderItem(name: "Some very, extremely long folder name goes in here...") - .previewDisplayName("Browse item for folders with long name") + .previewDisplayName("Folder item with long name") } } diff --git a/BeReal/Browse/Extensions/Image+Helpers.swift b/BeReal/Browse/Extensions/Image+Helpers.swift new file mode 100644 index 0000000..8cf4ed6 --- /dev/null +++ b/BeReal/Browse/Extensions/Image+Helpers.swift @@ -0,0 +1,24 @@ +// +// Image+Helpers.swift +// Browse +// +// Created by Javier Cicchelli on 03/12/2022. +// Copyright © 2022 Röck+Cöde. All rights reserved. +// + +import SwiftUI + +extension Image { + + /// Resizes an image to a given size. + /// - Parameter size: A size to which an image will be resized. + /// - Returns: An resized image rendered as an erasured view. + func icon(size: CGFloat) -> some View { + self + .resizable() + .renderingMode(.template) + .scaledToFit() + .frame(width: size, height: size) + } + +} diff --git a/BeReal/Browse/Extensions/Text+Helpers.swift b/BeReal/Browse/Extensions/Text+Helpers.swift new file mode 100644 index 0000000..5fe430a --- /dev/null +++ b/BeReal/Browse/Extensions/Text+Helpers.swift @@ -0,0 +1,23 @@ +// +// Text+Helpers.swift +// BeReal +// +// Created by Javier Cicchelli on 03/12/2022. +// Copyright © 2022 Röck+Cöde. All rights reserved. +// + +import SwiftUI + +extension Text { + + /// Renders a text for the name of a folder or document item. + /// - Returns: A formatted text rendered as an erasured view. + func itemName() -> some View { + self + .font(.headline) + .lineLimit(1) + .truncationMode(.middle) + .foregroundColor(.primary) + .frame(maxWidth: .infinity, alignment: .leading) + } +} From e372641a58891a6f1d1ccdd056c548d7dfaf6d09 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 07:23:38 +0100 Subject: [PATCH 3/9] Implemented a BrowseView view with dummy data. --- BeReal.xcodeproj/project.pbxproj | 4 ++ BeReal/Browse/Components/DocumentItem.swift | 2 +- BeReal/Browse/Components/FolderItem.swift | 2 +- BeReal/Browse/Extensions/Text+Helpers.swift | 2 +- BeReal/Browse/Views/BrowseView.swift | 75 +++++++++++++++++++++ 5 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 BeReal/Browse/Views/BrowseView.swift diff --git a/BeReal.xcodeproj/project.pbxproj b/BeReal.xcodeproj/project.pbxproj index 7cbebec..e142b2f 100644 --- a/BeReal.xcodeproj/project.pbxproj +++ b/BeReal.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 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 */; }; 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 */ @@ -55,6 +56,7 @@ 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 = ""; }; 02FFFD7A29395DD200306533 /* String+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Constants.swift"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -157,6 +159,7 @@ 02B334E5293A93C400C45E31 /* Views */ = { isa = PBXGroup; children = ( + 02CE555A293B1D8400730DC9 /* BrowseView.swift */, ); path = Views; sourceTree = ""; @@ -328,6 +331,7 @@ 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 */, diff --git a/BeReal/Browse/Components/DocumentItem.swift b/BeReal/Browse/Components/DocumentItem.swift index 8b6f311..11ee561 100644 --- a/BeReal/Browse/Components/DocumentItem.swift +++ b/BeReal/Browse/Components/DocumentItem.swift @@ -39,7 +39,7 @@ struct DocumentItem: View { .foregroundColor(.secondary) } } - .padding(16) + .padding(.vertical, 8) } } diff --git a/BeReal/Browse/Components/FolderItem.swift b/BeReal/Browse/Components/FolderItem.swift index bb1862b..fd89e77 100644 --- a/BeReal/Browse/Components/FolderItem.swift +++ b/BeReal/Browse/Components/FolderItem.swift @@ -30,7 +30,7 @@ struct FolderItem: View { .foregroundColor(.secondary) .font(.headline) } - .padding(16) + .padding(.vertical, 8) } } diff --git a/BeReal/Browse/Extensions/Text+Helpers.swift b/BeReal/Browse/Extensions/Text+Helpers.swift index 5fe430a..1c0a9aa 100644 --- a/BeReal/Browse/Extensions/Text+Helpers.swift +++ b/BeReal/Browse/Extensions/Text+Helpers.swift @@ -1,6 +1,6 @@ // // Text+Helpers.swift -// BeReal +// Browse // // Created by Javier Cicchelli on 03/12/2022. // Copyright © 2022 Röck+Cöde. All rights reserved. diff --git a/BeReal/Browse/Views/BrowseView.swift b/BeReal/Browse/Views/BrowseView.swift new file mode 100644 index 0000000..2654010 --- /dev/null +++ b/BeReal/Browse/Views/BrowseView.swift @@ -0,0 +1,75 @@ +// +// BrowseView.swift +// Browse +// +// Created by Javier Cicchelli on 03/12/2022. +// Copyright © 2022 Röck+Cöde. All rights reserved. +// + +import SwiftUI + +struct BrowseView: View { + var body: some View { + List { + Group { + FolderItem(name: "Some folder #1 name") + FolderItem(name: "Some folder #2 name") + FolderItem(name: "Some folder #3 name") + FolderItem(name: "Some folder #4 name") + FolderItem(name: "Some folder #5 name") + FolderItem(name: "Some folder #6 name") + FolderItem(name: "Some folder #7 name") + } + Group { + DocumentItem( + name: "Some document #1 name", + lastModified: "3 months ago", + fileSize: "1,23 Mbytes" + ) + DocumentItem( + name: "Some document #2 name", + lastModified: "2 years ago", + fileSize: "123 Kbytes" + ) + DocumentItem( + name: "Some document #3 name", + lastModified: "13 days ago", + fileSize: "12 bytes" + ) + DocumentItem( + name: "Some document #4 name", + lastModified: "13 hours ago", + fileSize: "12,3 Gbytes" + ) + DocumentItem( + name: "Some document #5 name", + lastModified: "13 minutes ago", + fileSize: "123 Tbytes" + ) + DocumentItem( + name: "Some document #6 name", + lastModified: "13 seconds ago", + fileSize: "123 Tbytes" + ) + DocumentItem( + name: "Some document #7 name", + lastModified: "13 nanoseconds ago", + fileSize: "123 Tbytes" + ) + } + } + .listStyle(.inset) + .background(Color.red) + .navigationTitle("Folder name") + } +} + +// MARK: - Previews + +struct BrowseView_Previews: PreviewProvider { + static var previews: some View { + NavigationView { + BrowseView() + } + } +} From f8507d9d00cdabcb3a9fa52e3264f13e99c016e7 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 07:41:17 +0100 Subject: [PATCH 4/9] Added the profile button in the navigation toolbar of the BrowseView view. --- BeReal/Browse/Views/BrowseView.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/BeReal/Browse/Views/BrowseView.swift b/BeReal/Browse/Views/BrowseView.swift index 2654010..c655854 100644 --- a/BeReal/Browse/Views/BrowseView.swift +++ b/BeReal/Browse/Views/BrowseView.swift @@ -61,9 +61,25 @@ struct BrowseView: View { .listStyle(.inset) .background(Color.red) .navigationTitle("Folder name") + .toolbar { + ToolbarItem(placement: .primaryAction) { + Button { + // ... + } label: { + Image.profile + .foregroundColor(.red) + } + } + } } } +// MARK: - Image+Constants + +private extension Image { + static let profile = Image(systemName: "person.crop.circle.fill") +} + // MARK: - Previews struct BrowseView_Previews: PreviewProvider { From 7c5aed8b8cc0ab1fcdf4a0a4af2a38534b7f92f8 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 07:41:47 +0100 Subject: [PATCH 5/9] Integrated the BrowseView view into the ContentView view. --- BeReal/ContentView.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/BeReal/ContentView.swift b/BeReal/ContentView.swift index e9aef05..54fac04 100644 --- a/BeReal/ContentView.swift +++ b/BeReal/ContentView.swift @@ -11,13 +11,9 @@ import Login struct ContentView: View { var body: some View { - VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundColor(.accentColor) - Text("Hello, world!") + NavigationView { + BrowseView() } - .padding() .sheet(isPresented: .constant(true)) { LoginView() } From c9b148a2ff6203f849eda6bce8eafe43d876a8a7 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 08:19:48 +0100 Subject: [PATCH 6/9] Added swipe actions to all the dummy items in the BrowseView view. --- BeReal/Browse/Views/BrowseView.swift | 117 +++++++++++++++++---------- 1 file changed, 74 insertions(+), 43 deletions(-) diff --git a/BeReal/Browse/Views/BrowseView.swift b/BeReal/Browse/Views/BrowseView.swift index c655854..37f0882 100644 --- a/BeReal/Browse/Views/BrowseView.swift +++ b/BeReal/Browse/Views/BrowseView.swift @@ -12,50 +12,79 @@ struct BrowseView: View { var body: some View { List { Group { - FolderItem(name: "Some folder #1 name") - FolderItem(name: "Some folder #2 name") - FolderItem(name: "Some folder #3 name") - FolderItem(name: "Some folder #4 name") - FolderItem(name: "Some folder #5 name") - FolderItem(name: "Some folder #6 name") - FolderItem(name: "Some folder #7 name") + Group { + FolderItem(name: "Some folder #1 name") + FolderItem(name: "Some folder #2 name") + FolderItem(name: "Some folder #3 name") + FolderItem(name: "Some folder #4 name") + FolderItem(name: "Some folder #5 name") + FolderItem(name: "Some folder #6 name") + FolderItem(name: "Some folder #7 name") + } + Group { + DocumentItem( + name: "Some document #1 name", + lastModified: "3 months ago", + fileSize: "1,23 Mbytes" + ) + DocumentItem( + name: "Some document #2 name", + lastModified: "2 years ago", + fileSize: "123 Kbytes" + ) + DocumentItem( + name: "Some document #3 name", + lastModified: "13 days ago", + fileSize: "12 bytes" + ) + DocumentItem( + name: "Some document #4 name", + lastModified: "13 hours ago", + fileSize: "12,3 Gbytes" + ) + DocumentItem( + name: "Some document #5 name", + lastModified: "13 minutes ago", + fileSize: "123 Tbytes" + ) + DocumentItem( + name: "Some document #6 name", + lastModified: "13 seconds ago", + fileSize: "123 Tbytes" + ) + DocumentItem( + name: "Some document #7 name", + lastModified: "13 nanoseconds ago", + fileSize: "123 Tbytes" + ) + } } - Group { - DocumentItem( - name: "Some document #1 name", - lastModified: "3 months ago", - fileSize: "1,23 Mbytes" - ) - DocumentItem( - name: "Some document #2 name", - lastModified: "2 years ago", - fileSize: "123 Kbytes" - ) - DocumentItem( - name: "Some document #3 name", - lastModified: "13 days ago", - fileSize: "12 bytes" - ) - DocumentItem( - name: "Some document #4 name", - lastModified: "13 hours ago", - fileSize: "12,3 Gbytes" - ) - DocumentItem( - name: "Some document #5 name", - lastModified: "13 minutes ago", - fileSize: "123 Tbytes" - ) - DocumentItem( - name: "Some document #6 name", - lastModified: "13 seconds ago", - fileSize: "123 Tbytes" - ) - DocumentItem( - name: "Some document #7 name", - lastModified: "13 nanoseconds ago", - fileSize: "123 Tbytes" - ) + .swipeActions( + edge: .trailing, + allowsFullSwipe: true + ) { + Button { + // ... + } label: { + Label { + Text("Delete item") + } icon: { + Image.trash + } + } + .tint(.red) + + // TODO: allow download only if item is a file. + Button { + // ... + } label: { + Label { + Text("Download item") + } icon: { + Image.download + } + } + .tint(.orange) } } .listStyle(.inset) @@ -78,6 +107,8 @@ struct BrowseView: View { private extension Image { static let profile = Image(systemName: "person.crop.circle.fill") + static let trash = Image(systemName: "trash") + static let download = Image(systemName: "arrow.down.doc") } // MARK: - Previews From b6202c76af74396e3b6364f92edffdbe5a424c14 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 08:36:15 +0100 Subject: [PATCH 7/9] Added the add file and/or folder menu actions into the navigation toolbar in the BrowseView view. --- BeReal/Browse/Views/BrowseView.swift | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/BeReal/Browse/Views/BrowseView.swift b/BeReal/Browse/Views/BrowseView.swift index 37f0882..6c9e074 100644 --- a/BeReal/Browse/Views/BrowseView.swift +++ b/BeReal/Browse/Views/BrowseView.swift @@ -92,8 +92,39 @@ struct BrowseView: View { .navigationTitle("Folder name") .toolbar { ToolbarItem(placement: .primaryAction) { + Menu { + Button { + // TODO: Implement the creation of a new folder. + } label: { + Label { + Text("Create a new folder") + } icon: { + Image.newFolder + } + } + + Button { + // TODO: Implement the upload of a file from the device to the API. + } label: { + Label { + Text("Upload a file") + } icon: { + Image.newFile + } + } + } label: { + Label { + Text("Add file and/or folder") + } icon: { + Image.add + .foregroundColor(.red) + } + } + } + + ToolbarItem(placement: .navigationBarTrailing) { Button { - // ... + // TODO: Implement the show of the user profile. } label: { Image.profile .foregroundColor(.red) @@ -107,6 +138,9 @@ struct BrowseView: View { private extension Image { static let profile = Image(systemName: "person.crop.circle.fill") + static let add = Image(systemName: "plus.circle.fill") + static let newFolder = Image(systemName: "folder.badge.plus") + static let newFile = Image(systemName: "doc.badge.plus") static let trash = Image(systemName: "trash") static let download = Image(systemName: "arrow.down.doc") } From b81d846aa8888bd03e4b9f7d86f813749ad55e38 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 08:46:22 +0100 Subject: [PATCH 8/9] Moved the definition of the toolbar from the BrowseView view to its own file. --- BeReal.xcodeproj/project.pbxproj | 12 +++++ BeReal/Browse/Toolbars/BrowseToolbar.swift | 62 ++++++++++++++++++++++ BeReal/Browse/Views/BrowseView.swift | 48 ++--------------- 3 files changed, 77 insertions(+), 45 deletions(-) create mode 100644 BeReal/Browse/Toolbars/BrowseToolbar.swift diff --git a/BeReal.xcodeproj/project.pbxproj b/BeReal.xcodeproj/project.pbxproj index e142b2f..34c0285 100644 --- a/BeReal.xcodeproj/project.pbxproj +++ b/BeReal.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 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 */ @@ -57,6 +58,7 @@ 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 */ @@ -151,6 +153,7 @@ children = ( 02CE5555293B131D00730DC9 /* Extensions */, 02B334E6293A93CE00C45E31 /* Components */, + 02CE555C293B34CF00730DC9 /* Toolbars */, 02B334E5293A93C400C45E31 /* Views */, ); path = Browse; @@ -182,6 +185,14 @@ path = Extensions; sourceTree = ""; }; + 02CE555C293B34CF00730DC9 /* Toolbars */ = { + isa = PBXGroup; + children = ( + 02CE555D293B34E900730DC9 /* BrowseToolbar.swift */, + ); + path = Toolbars; + sourceTree = ""; + }; 02FFFD7929395DBF00306533 /* Extensions */ = { isa = PBXGroup; children = ( @@ -339,6 +350,7 @@ 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/Browse/Toolbars/BrowseToolbar.swift b/BeReal/Browse/Toolbars/BrowseToolbar.swift new file mode 100644 index 0000000..5508bf8 --- /dev/null +++ b/BeReal/Browse/Toolbars/BrowseToolbar.swift @@ -0,0 +1,62 @@ +// +// BrowseToolbar.swift +// BeReal +// +// Created by Javier Cicchelli on 03/12/2022. +// Copyright © 2022 Röck+Cöde. All rights reserved. +// + +import SwiftUI + +struct BrowseToolbar: ToolbarContent { + var body: some ToolbarContent { + ToolbarItem(placement: .primaryAction) { + Menu { + Button { + // TODO: Implement the creation of a new folder. + } label: { + Label { + Text("Create a new folder") + } icon: { + Image.newFolder + } + } + + Button { + // TODO: Implement the upload of a file from the device to the API. + } label: { + Label { + Text("Upload a file") + } icon: { + Image.newFile + } + } + } label: { + Label { + Text("Add file and/or folder") + } icon: { + Image.add + .foregroundColor(.red) + } + } + } + + ToolbarItem(placement: .navigationBarTrailing) { + Button { + // TODO: Implement the show of the user profile. + } label: { + Image.profile + .foregroundColor(.red) + } + } + } +} + +// MARK: - Image+Constants + +private extension Image { + static let profile = Image(systemName: "person.crop.circle.fill") + static let add = Image(systemName: "plus.circle.fill") + static let newFolder = Image(systemName: "folder.badge.plus") + static let newFile = Image(systemName: "doc.badge.plus") +} diff --git a/BeReal/Browse/Views/BrowseView.swift b/BeReal/Browse/Views/BrowseView.swift index 6c9e074..5fc1369 100644 --- a/BeReal/Browse/Views/BrowseView.swift +++ b/BeReal/Browse/Views/BrowseView.swift @@ -64,7 +64,7 @@ struct BrowseView: View { allowsFullSwipe: true ) { Button { - // ... + // TODO: Implement the removal of the item from the API. } label: { Label { Text("Delete item") @@ -76,7 +76,7 @@ struct BrowseView: View { // TODO: allow download only if item is a file. Button { - // ... + // TODO: Implement the downloading of the data of the item from the API into the device. } label: { Label { Text("Download item") @@ -91,45 +91,7 @@ struct BrowseView: View { .background(Color.red) .navigationTitle("Folder name") .toolbar { - ToolbarItem(placement: .primaryAction) { - Menu { - Button { - // TODO: Implement the creation of a new folder. - } label: { - Label { - Text("Create a new folder") - } icon: { - Image.newFolder - } - } - - Button { - // TODO: Implement the upload of a file from the device to the API. - } label: { - Label { - Text("Upload a file") - } icon: { - Image.newFile - } - } - } label: { - Label { - Text("Add file and/or folder") - } icon: { - Image.add - .foregroundColor(.red) - } - } - } - - ToolbarItem(placement: .navigationBarTrailing) { - Button { - // TODO: Implement the show of the user profile. - } label: { - Image.profile - .foregroundColor(.red) - } - } + BrowseToolbar() } } } @@ -137,10 +99,6 @@ struct BrowseView: View { // MARK: - Image+Constants private extension Image { - static let profile = Image(systemName: "person.crop.circle.fill") - static let add = Image(systemName: "plus.circle.fill") - static let newFolder = Image(systemName: "folder.badge.plus") - static let newFile = Image(systemName: "doc.badge.plus") static let trash = Image(systemName: "trash") static let download = Image(systemName: "arrow.down.doc") } From d0b39e66413c9d3b4584cbdc6beada002b638bee Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 3 Dec 2022 09:15:23 +0100 Subject: [PATCH 9/9] 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 }