yattee/tvOS/CoverSectionView.swift
2021-08-03 00:30:39 +02:00

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)
}
}