Implemented the ProfileSection UI component for the Profile module.
This commit is contained in:
parent
d7ec5aad47
commit
8b8f0d9f1f
75
Modules/Sources/Profile/UI/Components/ProfileSection.swift
Normal file
75
Modules/Sources/Profile/UI/Components/ProfileSection.swift
Normal file
@ -0,0 +1,75 @@
|
||||
//
|
||||
// ProfileSection.swift
|
||||
// Profile
|
||||
//
|
||||
// Created by Javier Cicchelli on 12/12/2022.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ProfileSection: View {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
let header: LocalizedStringKey
|
||||
let items: [Item]
|
||||
|
||||
// MARK: Body
|
||||
|
||||
var body: some View {
|
||||
Section {
|
||||
ForEach(items) { item in
|
||||
Label {
|
||||
Text(item.value)
|
||||
} icon: {
|
||||
Text(
|
||||
item.key,
|
||||
bundle: .module
|
||||
)
|
||||
}
|
||||
.labelStyle(.nameAndValue)
|
||||
}
|
||||
} header: {
|
||||
Text(
|
||||
header,
|
||||
bundle: .module
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Structs
|
||||
|
||||
extension ProfileSection {
|
||||
struct Item {
|
||||
let key: LocalizedStringKey
|
||||
let value: String
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Identifiable
|
||||
|
||||
extension ProfileSection.Item: Identifiable {
|
||||
var id: String { UUID().uuidString }
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct ProfileSection_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ProfileSection(
|
||||
header: "some-localised-header-key",
|
||||
items: [
|
||||
.init(
|
||||
key: "some-localized-key",
|
||||
value: "some value"
|
||||
),
|
||||
.init(
|
||||
key: "some-other-localised-key",
|
||||
value: "some other value"
|
||||
)
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user