1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 23:00:32 +05:30
yattee/Apple TV/CoverSectionView.swift

49 lines
1.1 KiB
Swift
Raw Normal View History

2021-07-08 04:09:18 +05:30
import SwiftUI
2021-07-08 20:44:54 +05:30
struct CoverSectionView<Content: View>: View {
2021-07-08 04:09:18 +05:30
let title: String?
2021-07-08 22:48:36 +05:30
let actionsView: Content
2021-07-08 04:09:18 +05:30
let divider: Bool
2021-07-08 22:48:36 +05:30
let inline: Bool
2021-07-08 04:09:18 +05:30
2021-07-08 22:48:36 +05:30
init(_ title: String? = nil, divider: Bool = true, inline: Bool = false, @ViewBuilder actionsView: @escaping () -> Content) {
2021-07-08 04:09:18 +05:30
self.title = title
self.divider = divider
2021-07-08 22:48:36 +05:30
self.inline = inline
self.actionsView = actionsView()
2021-07-08 04:09:18 +05:30
}
var body: some View {
VStack(alignment: .leading) {
2021-07-08 22:48:36 +05:30
if inline {
HStack {
if title != nil {
sectionTitle
}
Spacer()
actionsView
}
} else if title != nil {
2021-07-08 04:09:18 +05:30
sectionTitle
}
2021-07-08 22:48:36 +05:30
if !inline {
actionsView
}
2021-07-08 04:09:18 +05:30
}
if divider {
Divider()
.padding(.vertical)
}
}
var sectionTitle: some View {
Text(title ?? "")
.font(.title3)
.padding(.bottom)
}
}