Mercurial > public > lazybear
view LazyBear/Views/Global Helpers/PriceView.swift @ 409:dc8dccd18e86
Minor UI changes
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 06 Jun 2021 19:07:21 +0200 |
parents | 933546fa5651 |
children | 2984d8946342 |
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 ) ) } }