Implemented the dismiss button in the ProfileView view for the Profile module.
This commit is contained in:
parent
f324b59601
commit
3d50979d4b
@ -10,10 +10,9 @@
|
||||
"profile.sections.names.label.first_name.text" = "First name";
|
||||
"profile.sections.names.label.last_name.text" = "Last name";
|
||||
|
||||
"profile.sections.root_info.header.text" = "Root item information";
|
||||
"profile.sections.root_info.header.text" = "Root folder";
|
||||
"profile.sections.root_info.label.identifier.text" = "Identifier";
|
||||
"profile.sections.root_info.label.is_directory.text" = "Is a directory?";
|
||||
"profile.sections.root_info.label.last_modified.text" = "Last modified";
|
||||
"profile.sections.root_info.label.name.text" = "Name";
|
||||
"profile.sections.root_info.label.last_modified.text" = "Last modified";
|
||||
|
||||
"profile.button.log_out.text" = "Log out";
|
||||
|
@ -11,6 +11,10 @@ import SwiftUI
|
||||
|
||||
public struct ProfileView: View {
|
||||
|
||||
// MARK: Environments
|
||||
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private let user: User?
|
||||
@ -32,68 +36,85 @@ public struct ProfileView: View {
|
||||
// MARK: Body
|
||||
|
||||
public var body: some View {
|
||||
ClearBackgroundList {
|
||||
Section {
|
||||
Image.photo
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 160)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.listRowBackground(Color.clear)
|
||||
|
||||
ProfileSection(
|
||||
header: "profile.sections.names.header.text",
|
||||
items: [
|
||||
.init(
|
||||
key: "profile.sections.names.label.first_name.text",
|
||||
value: stringAdapter(value: user?.profile.firstName)
|
||||
),
|
||||
.init(
|
||||
key: "profile.sections.names.label.last_name.text",
|
||||
value: stringAdapter(value: user?.profile.lastName)
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
ProfileSection(
|
||||
header: "profile.sections.root_info.header.text",
|
||||
items: [
|
||||
.init(
|
||||
key: "profile.sections.root_info.label.identifier.text",
|
||||
value: stringAdapter(value: user?.rootFolder.id)
|
||||
),
|
||||
.init(
|
||||
key: "profile.sections.root_info.label.name.text",
|
||||
value: stringAdapter(value: user?.rootFolder.name)
|
||||
),
|
||||
.init(
|
||||
key: "profile.sections.root_info.label.last_modified.text",
|
||||
value: dateAdapter(value: user?.rootFolder.lastModifiedAt)
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
Section {
|
||||
Button {
|
||||
logout()
|
||||
} label: {
|
||||
Text(
|
||||
"profile.button.log_out.text",
|
||||
bundle: .module
|
||||
)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.primary)
|
||||
.frame(maxWidth: .infinity)
|
||||
ZStack {
|
||||
ClearBackgroundList {
|
||||
Section {
|
||||
Image.photo
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 160)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.tint(.orange)
|
||||
.buttonStyle(.borderedProminent)
|
||||
.buttonBorderShape(.roundedRectangle(radius: 8))
|
||||
.controlSize(.large)
|
||||
.listRowBackground(Color.clear)
|
||||
|
||||
ProfileSection(
|
||||
header: "profile.sections.names.header.text",
|
||||
items: [
|
||||
.init(
|
||||
key: "profile.sections.names.label.first_name.text",
|
||||
value: stringAdapter(value: user?.profile.firstName)
|
||||
),
|
||||
.init(
|
||||
key: "profile.sections.names.label.last_name.text",
|
||||
value: stringAdapter(value: user?.profile.lastName)
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
ProfileSection(
|
||||
header: "profile.sections.root_info.header.text",
|
||||
items: [
|
||||
.init(
|
||||
key: "profile.sections.root_info.label.identifier.text",
|
||||
value: stringAdapter(value: user?.rootFolder.id)
|
||||
),
|
||||
.init(
|
||||
key: "profile.sections.root_info.label.name.text",
|
||||
value: stringAdapter(value: user?.rootFolder.name)
|
||||
),
|
||||
.init(
|
||||
key: "profile.sections.root_info.label.last_modified.text",
|
||||
value: dateAdapter(value: user?.rootFolder.lastModifiedAt)
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
Section {
|
||||
Button {
|
||||
logout()
|
||||
} label: {
|
||||
Text(
|
||||
"profile.button.log_out.text",
|
||||
bundle: .module
|
||||
)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.primary)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.tint(.orange)
|
||||
.buttonStyle(.borderedProminent)
|
||||
.buttonBorderShape(.roundedRectangle(radius: 8))
|
||||
.controlSize(.large)
|
||||
}
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
.listRowBackground(Color.clear)
|
||||
.background(Color.red)
|
||||
|
||||
VStack {
|
||||
Button {
|
||||
dismiss()
|
||||
} label: {
|
||||
Image.close
|
||||
.resizable()
|
||||
.frame(width: 32, height: 32)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
.padding([.top, .trailing], 24)
|
||||
}
|
||||
.background(Color.red)
|
||||
}
|
||||
|
||||
}
|
||||
@ -101,6 +122,7 @@ public struct ProfileView: View {
|
||||
// MARK: - Images+Constants
|
||||
|
||||
private extension Image {
|
||||
static let close = Image(systemName: "xmark.circle.fill")
|
||||
static let photo = Image(systemName: "person.crop.circle.fill")
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user