Mercurial > public > lazybear
view LazyBear/Views/Global Helpers/PriceView.swift @ 398:933546fa5651
Implementing CompanyView
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 09 May 2021 00:07:44 +0200 |
parents | eb97439e46cd |
children | dc8dccd18e86 |
line wrap: on
line source
// // PriceView.swift // LazyBear // // Created by Dennis Concepción Martín on 3/4/21. // import SwiftUI struct PriceView: View { var latestPrice: Double var changePercent: Double var style: PriceViewStyle var body: some View { VStack(alignment: style.alignment) { Text("$\(latestPrice, specifier: "%.2f")") .foregroundColor(changePercent < 0 ? .red: .green) .font(style.priceFont) .fontWeight(style.priceFontWeight) Text("\(changePercent*100, specifier: "%.2f")%") .foregroundColor(changePercent < 0 ? .red: .green) .font(style.percentFont) .fontWeight(style.percentFontWeight) } } } struct PriceView_Previews: PreviewProvider { static var previews: some View { PriceView( latestPrice: 120.30, changePercent: 0.03, style: PriceViewStyle( alignment: .leading, priceFont: .body, priceFontWeight: .semibold, percentFont: .callout, percentFontWeight: .semibold ) ) } }