mirror of
https://github.com/yattee/yattee.git
synced 2024-11-14 01:58:24 +00:00
49 lines
1.1 KiB
Swift
49 lines
1.1 KiB
Swift
import SwiftUI
|
|
|
|
struct CoverSectionView<Content: View>: View {
|
|
let title: String?
|
|
|
|
let actionsView: Content
|
|
let divider: Bool
|
|
let inline: Bool
|
|
|
|
init(_ title: String? = nil, divider: Bool = true, inline: Bool = false, @ViewBuilder actionsView: @escaping () -> Content) {
|
|
self.title = title
|
|
self.divider = divider
|
|
self.inline = inline
|
|
self.actionsView = actionsView()
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
if inline {
|
|
HStack {
|
|
if title != nil {
|
|
sectionTitle
|
|
}
|
|
|
|
Spacer()
|
|
actionsView
|
|
}
|
|
} else if title != nil {
|
|
sectionTitle
|
|
}
|
|
|
|
if !inline {
|
|
actionsView
|
|
}
|
|
}
|
|
|
|
if divider {
|
|
Divider()
|
|
.padding(.vertical)
|
|
}
|
|
}
|
|
|
|
var sectionTitle: some View {
|
|
Text(title ?? "")
|
|
.font(.title3)
|
|
.padding(.bottom)
|
|
}
|
|
}
|