Mercurial > public > stock-charts
comparison Sources/StockCharts/CapsuleChart/CapsuleChartView.swift @ 108:f53d8b9ca92b
Custom style implemented
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sun, 04 Jul 2021 16:40:24 +0100 |
parents | 0c0d38dca6d8 |
children | 957989b1068d |
comparison
equal
deleted
inserted
replaced
107:b0c81b2e624d | 108:f53d8b9ca92b |
---|---|
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 | 13 |
13 public init(percentageOfWidth: CGFloat) { | 14 public init(percentageOfWidth: CGFloat, style: CapsuleChartStyle) { |
14 self.percentageOfWidth = percentageOfWidth | 15 self.percentageOfWidth = percentageOfWidth |
16 self.style = style | |
15 } | 17 } |
18 | |
16 public var body: some View { | 19 public var body: some View { |
17 ZStack { | 20 ZStack { |
18 GeometryReader { proxy in | 21 GeometryReader { proxy in |
19 Group { | 22 Group { |
20 Capsule() | 23 Capsule() |
21 .foregroundColor(Color.gray) | 24 .foregroundColor(Color.gray) |
22 .opacity(0.2) | 25 .opacity(0.2) |
23 | 26 |
24 Capsule() | 27 Capsule() |
25 .foregroundColor(Color.blue) | 28 .foregroundColor(style.capsuleColor) |
26 .frame(width: proxy.size.width * percentageOfWidth) | 29 .frame(width: proxy.size.width * percentageOfWidth) |
27 } | 30 } |
28 .frame(height: 10) | 31 .frame(height: 10) |
29 } | 32 } |
30 } | 33 } |