CHResume/ResumeBuilder/Generic Elements/TitledSection.swift

35 lines
793 B
Swift
Raw Normal View History

2023-08-18 22:47:24 +02:00
import SwiftUI
struct TitledSection<Content>: View where Content: View {
private let content: Content
private let title: String
private let spacing: CGFloat
init(title: String, spacing: CGFloat, @ViewBuilder content: () -> Content) {
self.title = title
self.spacing = spacing
self.content = content()
}
var body: some View {
VStack(alignment: .leading, spacing: 0) {
Text(title)
.font(.title)
.fontWeight(.light)
.padding(.bottom, spacing)
content
}
}
}
struct TitledSection_Previews: PreviewProvider {
static var previews: some View {
TitledSection(title: "Title", spacing: 10) {
Text("Some more text")
}
}
}