* Starting on filling in documentation. * First pass on most/all files * more descriptions filled in * Some documentation but TBH the author would be better suited to explain how this works! * more basic stuff filled in * Add a description and bunch of discussion text for most of the view `body` declarations * more explanations Co-authored-by: Dan Wood <danwood@users.noreply.github.com>
38 lines
1.1 KiB
Swift
38 lines
1.1 KiB
Swift
import SwiftUI
|
|
|
|
/// View containing data and some kind of chart content
|
|
public struct CardView<Content: View>: View, ChartBase {
|
|
public var chartData = ChartData()
|
|
let content: () -> Content
|
|
|
|
private var showShadow: Bool
|
|
|
|
@EnvironmentObject var style: ChartStyle
|
|
|
|
/// Initialize with view options and a nested `ViewBuilder`
|
|
/// - Parameters:
|
|
/// - showShadow: should card have a rounded-rectangle shadow around it
|
|
/// - content: <#content description#>
|
|
public init(showShadow: Bool = true, @ViewBuilder content: @escaping () -> Content) {
|
|
self.showShadow = showShadow
|
|
self.content = content
|
|
}
|
|
|
|
/// The content and behavior of the `CardView`.
|
|
///
|
|
///
|
|
public var body: some View {
|
|
ZStack{
|
|
if showShadow {
|
|
RoundedRectangle(cornerRadius: 20)
|
|
.fill(Color.white)
|
|
.shadow(color: Color.gray, radius: 8)
|
|
}
|
|
VStack {
|
|
self.content()
|
|
}
|
|
.clipShape(RoundedRectangle(cornerRadius: showShadow ? 20 : 0))
|
|
}
|
|
}
|
|
}
|