Implemented the ProfileView view with dummy data.

This commit is contained in:
Javier Cicchelli 2022-12-03 10:45:54 +01:00
parent a77e866ded
commit e24d3e115c
3 changed files with 179 additions and 0 deletions

View File

@ -14,6 +14,8 @@
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 */; };
02CE5562293B452E00730DC9 /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CE5561293B452E00730DC9 /* ProfileView.swift */; };
02CE5565293B517700730DC9 /* NameAndValueLabelStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CE5564293B517700730DC9 /* NameAndValueLabelStyle.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 +49,8 @@
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>"; };
02CE5561293B452E00730DC9 /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
02CE5564293B517700730DC9 /* NameAndValueLabelStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameAndValueLabelStyle.swift; sourceTree = "<group>"; };
02FFFD7A29395DD200306533 /* String+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Constants.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -101,6 +105,7 @@
02AE64ED29363DBF005A4AF3 /* BeReal */ = {
isa = PBXGroup;
children = (
02CE555F293B44C900730DC9 /* Profile */,
02FFFD7929395DBF00306533 /* Extensions */,
02AE64EE29363DBF005A4AF3 /* BeRealApp.swift */,
02AE64F029363DBF005A4AF3 /* ContentView.swift */,
@ -135,9 +140,34 @@
path = BeRealUITests;
sourceTree = "<group>";
};
02CE555F293B44C900730DC9 /* Profile */ = {
isa = PBXGroup;
children = (
);
path = Profile;
sourceTree = "<group>";
};
02CE5560293B452400730DC9 /* Views */ = {
isa = PBXGroup;
children = (
02CE5561293B452E00730DC9 /* ProfileView.swift */,
);
path = Views;
sourceTree = "<group>";
};
02CE5563293B516600730DC9 /* Styles */ = {
isa = PBXGroup;
children = (
02CE5564293B517700730DC9 /* NameAndValueLabelStyle.swift */,
);
path = Styles;
sourceTree = "<group>";
};
02FFFD7929395DBF00306533 /* Extensions */ = {
isa = PBXGroup;
children = (
02CE5563293B516600730DC9 /* Styles */,
02CE5560293B452400730DC9 /* Views */,
02FFFD7A29395DD200306533 /* String+Constants.swift */,
);
path = Extensions;
@ -284,8 +314,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
02CE5562293B452E00730DC9 /* ProfileView.swift in Sources */,
02AE64F129363DBF005A4AF3 /* ContentView.swift in Sources */,
02AE64EF29363DBF005A4AF3 /* BeRealApp.swift in Sources */,
02CE5565293B517700730DC9 /* NameAndValueLabelStyle.swift in Sources */,
02FFFD7B29395DD200306533 /* String+Constants.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@ -0,0 +1,38 @@
//
// NameAndValueLabelStyle.swift
// Profile
//
// Created by Javier Cicchelli on 03/12/2022.
// Copyright © 2022 Röck+Cöde. All rights reserved.
//
import SwiftUI
struct NameAndValueLabelStyle: LabelStyle {
func makeBody(configuration: Configuration) -> some View {
VStack(
alignment: .leading,
spacing: 0
) {
configuration.icon
.font(.subheadline)
.foregroundColor(.secondary)
configuration.title
.font(.headline)
.lineLimit(1)
.truncationMode(.middle)
.foregroundColor(.primary)
.frame(maxWidth: .infinity, alignment: .trailing)
}
.padding(.vertical, 8)
}
}
// MARK: - LabelStyle
extension LabelStyle where Self == NameAndValueLabelStyle {
static var nameAndValue: Self {
NameAndValueLabelStyle()
}
}

View File

@ -0,0 +1,109 @@
//
// ProfileView.swift
// BeReal
//
// Created by Javier Cicchelli on 03/12/2022.
// Copyright © 2022 Röck+Cöde. All rights reserved.
//
import SwiftUI
struct ProfileView: View {
var body: some View {
List {
Section {
Image.photo
.resizable()
.scaledToFit()
.frame(width: 160)
.frame(maxWidth: .infinity)
}
.listRowBackground(Color.clear)
Section {
Label {
Text("Javier")
} icon: {
Text("First name")
}
.labelStyle(.nameAndValue)
Label {
Text("Cicchelli")
} icon: {
Text("Last name")
}
.labelStyle(.nameAndValue)
} header: {
Text("Names")
}
Section {
Label {
Text("71207ee4c0573fde80b03643caafe62731406404")
} icon: {
Text("Identifier")
}
.labelStyle(.nameAndValue)
Label {
Text("Yes")
} icon: {
Text("Is a directory?")
}
.labelStyle(.nameAndValue)
Label {
Text("3 days ago")
} icon: {
Text("Last modified")
}
.labelStyle(.nameAndValue)
Label {
Text("My files")
} icon: {
Text("name")
}
.labelStyle(.nameAndValue)
} header: {
Text("Root item information")
}
Section {
Button {
// TODO: Log out the existing user.
} label: {
Text("Log out")
.fontWeight(.semibold)
.foregroundColor(.primary)
.frame(maxWidth: .infinity)
}
.tint(.orange)
.buttonStyle(.borderedProminent)
.buttonBorderShape(.roundedRectangle(radius: 8))
.controlSize(.large)
.padding(0)
}
.listRowBackground(Color.clear)
}
.background(Color.red)
.onAppear {
UITableView.appearance().backgroundColor = .clear
}
}
}
// MARK: - Images+Constants
private extension Image {
static let photo = Image(systemName: "person.crop.circle.fill")
}
// MARK: - Previews
struct ProfileView_Previews: PreviewProvider {
static var previews: some View {
ProfileView()
}
}