1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 14:50:32 +05:30
yattee/Apple TV/CoverSectionView.swift
2021-07-08 19:19:22 +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)
}
}