Files
SwiftUI-Kit-mirror/Shared/SectionView.swift
2020-07-11 21:30:46 -04:00

45 lines
1.0 KiB
Swift

//
// SectionView.swift
// SwiftUI Kit
//
// Created by Jordan Singer on 7/10/20.
//
import SwiftUI
struct SectionView<Content: View>: View {
var title: String?
var description: String
let content: () -> Content
var body: some View {
Group {
#if os(iOS)
Section(footer: Text(description)) {
if let title = title {
Text(title)
.font(.headline)
}
content()
}
#else
Group {
if let title = title {
Text(title).font(.title3).bold()
}
content()
Text(description).font(.body).foregroundColor(.secondary)
Divider()
}
#endif
}
}
}
struct SectionView_Previews: PreviewProvider {
static var previews: some View {
SectionView(title: "Section", description: "Description", content: { Text("Content") })
.previewLayout(.sizeThatFits)
}
}