Mercurial > public > stock-charts
view Sources/StockCharts/CapsuleChart/CapsuleChartView.swift @ 110:b4901499ad40
Aligned Capsules
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sun, 04 Jul 2021 17:04:17 +0100 |
parents | 957989b1068d |
children | 5057c45046c1 |
line wrap: on
line source
// // CapsuleChartView.swift // StockCharts // // Created by Dennis Concepción Martín on 5/6/21. // import SwiftUI public struct CapsuleChartView: View { public var percentageOfWidth: CGFloat public var style: CapsuleChartStyle public init(percentageOfWidth: CGFloat, style: CapsuleChartStyle) { self.percentageOfWidth = percentageOfWidth self.style = style } public var body: some View { GeometryReader { proxy in ZStack(alignment: .leading) { Group { Capsule() .foregroundColor(Color.gray) .opacity(0.2) Capsule() .foregroundColor(style.capsuleColor) .frame(width: proxy.size.width * percentageOfWidth) } .frame(height: 10) } } } }