Mercurial > public > lazybear
diff LazyBear/Views/Global Helpers/StockItem.swift @ 379:a7e2c5a7b4f6
Implement onDelete in watchlists
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Thu, 22 Apr 2021 23:44:20 +0200 |
parents | f3cb5bdea8e5 |
children | 6303385b3629 |
line wrap: on
line diff
--- a/LazyBear/Views/Global Helpers/StockItem.swift Wed Apr 21 23:12:56 2021 +0200 +++ b/LazyBear/Views/Global Helpers/StockItem.swift Thu Apr 22 23:44:20 2021 +0200 @@ -16,12 +16,13 @@ var company: QuoteModel var intradayPrices: [IntradayPriceModel]? var orientation: OrientationView + var hidePriceView: Bool? var body: some View { if orientation == .vertical { return AnyView(VerticalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices)) } else { - return AnyView(HorizontalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices)) + return AnyView(HorizontalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices, hidePriceView: hidePriceView ?? false)) } } } @@ -85,6 +86,7 @@ var symbol: String var company: QuoteModel var intradayPrices: [IntradayPriceModel]? + var hidePriceView: Bool var body: some View { HStack { @@ -100,17 +102,19 @@ } Spacer() - if let prices = intradayPrices?.compactMap { $0.open } { - LineView(data: prices) - .foregroundColor(company.changePercent < 0 ? .red: .green) - .frame(width: 80) - .padding(.vertical, 10) - .padding(.leading) + if !hidePriceView { + if let prices = intradayPrices?.compactMap { $0.open } { + LineView(data: prices) + .foregroundColor(company.changePercent < 0 ? .red: .green) + .frame(width: 80) + .padding(.vertical, 10) + .padding(.leading) + } + + PriceView(latestPrice: company.latestPrice, changePercent: company.changePercent, align: .trailing) + // Center PriceView with the other rows + .frame(minWidth: 80, alignment: .trailing) } - - PriceView(latestPrice: company.latestPrice, changePercent: company.changePercent, align: .trailing) - // Avoid moving LineView along the HStack when numbers increases - .frame(minWidth: 80, alignment: .trailing) } .padding(5) }