Impressia/Vernissage/Widgets/LabelIcon.swift

33 lines
754 B
Swift
Raw Normal View History

2022-12-29 17:27:15 +01:00
//
// https://mczachurski.dev
// Copyright © 2022 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import SwiftUI
2023-01-03 14:09:22 +01:00
struct LabelIcon: View {
2022-12-29 17:27:15 +01:00
let iconName: String
2023-01-08 14:50:37 +01:00
let value: String?
2022-12-29 17:27:15 +01:00
var body: some View {
2023-01-08 14:50:37 +01:00
if let value {
HStack(alignment: .center) {
Image(systemName: iconName)
2023-02-19 12:18:06 +01:00
.frame(width: 24, alignment: .center)
2023-01-08 14:50:37 +01:00
Text(value)
.font(.footnote)
}
.padding(.vertical, 2)
} else {
EmptyView()
2022-12-29 17:27:15 +01:00
}
}
}
struct LabelIconView_Previews: PreviewProvider {
static var previews: some View {
2023-01-03 14:09:22 +01:00
LabelIcon(iconName: "camera", value: "Sony A7")
2022-12-29 17:27:15 +01:00
}
}