CHResume/ResumeBuilder/Generic Elements/LeftImageLabel.swift

29 lines
671 B
Swift
Raw Normal View History

2023-08-18 22:47:24 +02:00
import SwiftUI
import SFSafeSymbols
2023-11-10 11:22:49 +01:00
struct LeftImageLabel<Content>: View where Content: View {
2023-08-18 22:47:24 +02:00
let systemSymbol: SFSymbol
2023-11-10 11:22:49 +01:00
let content: Content
2023-08-18 22:47:24 +02:00
2023-11-10 11:22:49 +01:00
init(systemSymbol: SFSymbol, @ViewBuilder content: () -> Content) {
2023-08-18 22:47:24 +02:00
self.systemSymbol = systemSymbol
2023-11-10 11:22:49 +01:00
self.content = content()
2023-08-18 22:47:24 +02:00
}
var body: some View {
2023-11-10 11:22:49 +01:00
HStack(alignment: .center, spacing: 0) {
content
2023-08-18 22:47:24 +02:00
Image(systemSymbol: systemSymbol)
.frame(width: 20)
}
}
}
struct LeftImageLabel_Previews: PreviewProvider {
static var previews: some View {
2023-11-10 11:22:49 +01:00
LeftImageLabel(systemSymbol: .house) { Text("Home address") }
2023-08-18 22:47:24 +02:00
}
}