Implemented the FolderItem view component.
This commit is contained in:
parent
b790c03adf
commit
d108f17646
@ -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 = "<group>"; };
|
||||
02AE650B29363DC1005A4AF3 /* BeRealUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeRealUITestsLaunchTests.swift; sourceTree = "<group>"; };
|
||||
02B334E7293A93DC00C45E31 /* FolderItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderItem.swift; sourceTree = "<group>"; };
|
||||
02FFFD7A29395DD200306533 /* String+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Constants.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -76,13 +78,6 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
027F60592937662300467238 /* Login */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = Login;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
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 = "<group>";
|
||||
};
|
||||
02B334E2293A908800C45E31 /* Browse */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
02B334E6293A93CE00C45E31 /* Components */,
|
||||
02B334E5293A93C400C45E31 /* Views */,
|
||||
);
|
||||
path = Browse;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
02B334E5293A93C400C45E31 /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
02B334E6293A93CE00C45E31 /* Components */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
02B334E7293A93DC00C45E31 /* FolderItem.swift */,
|
||||
);
|
||||
path = Components;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
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 */,
|
||||
|
74
BeReal/Browse/Components/FolderItem.swift
Normal file
74
BeReal/Browse/Components/FolderItem.swift
Normal file
@ -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")
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user