comparison Sources/StockCharts/CapsuleChart/CapsuleChartView.swift @ 116:5057c45046c1

Add default initializers
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Mon, 09 Aug 2021 16:32:45 +0100
parents b4901499ad40
children
comparison
equal deleted inserted replaced
115:f90a675e5e95 116:5057c45046c1
7 7
8 import SwiftUI 8 import SwiftUI
9 9
10 public struct CapsuleChartView: View { 10 public struct CapsuleChartView: View {
11 public var percentageOfWidth: CGFloat 11 public var percentageOfWidth: CGFloat
12 public var style: CapsuleChartStyle 12 public var capsuleChartStyle: CapsuleChartStyle
13 13
14 public init(percentageOfWidth: CGFloat, style: CapsuleChartStyle) { 14 public init(percentageOfWidth: CGFloat, style: CapsuleChartStyle) {
15 self.percentageOfWidth = percentageOfWidth 15 self.percentageOfWidth = percentageOfWidth
16 self.style = style 16 self.capsuleChartStyle = style
17 } 17 }
18 18
19 public var body: some View { 19 public var body: some View {
20 GeometryReader { proxy in 20 GeometryReader { proxy in
21 ZStack(alignment: .leading) { 21 ZStack(alignment: .leading) {
23 Capsule() 23 Capsule()
24 .foregroundColor(Color.gray) 24 .foregroundColor(Color.gray)
25 .opacity(0.2) 25 .opacity(0.2)
26 26
27 Capsule() 27 Capsule()
28 .foregroundColor(style.capsuleColor) 28 .foregroundColor(capsuleChartStyle.capsuleColor)
29 .frame(width: proxy.size.width * percentageOfWidth) 29 .frame(width: proxy.size.width * percentageOfWidth)
30 } 30 }
31 .frame(height: 10) 31 .frame(height: 10)
32 } 32 }
33 } 33 }