76 lines
1.5 KiB
Swift
76 lines
1.5 KiB
Swift
//
|
|
// 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"
|
|
)
|
|
]
|
|
)
|
|
}
|
|
}
|