Mercurial > public > lazybear
diff LazyBear/Views/Global Helpers/StockRectangleRow.swift @ 346:80bfa88c6b0f
Implementing Prop API
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 11 Apr 2021 19:55:47 +0200 |
parents | fde2b30c719e |
children | 5ccceb527178 |
line wrap: on
line diff
--- a/LazyBear/Views/Global Helpers/StockRectangleRow.swift Thu Apr 08 20:15:28 2021 +0200 +++ b/LazyBear/Views/Global Helpers/StockRectangleRow.swift Sun Apr 11 19:55:47 2021 +0200 @@ -9,13 +9,13 @@ struct StockRectangleRow: View { - var listType: String - var list: [CompanyQuoteModel] - var intradayPrices: [String: [IntradayPricesResult]] + var listName: String + var list: [QuoteModel] + var nestedIntradayPrices: [String: NestedIntradayPricesModel]? var body: some View { VStack(alignment: .leading) { - Text(adaptTitle(listType)) + Text(adaptTitle(listName)) .font(.title3) .fontWeight(.semibold) .padding([.top, .horizontal]) @@ -23,7 +23,11 @@ ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 20) { ForEach(list, id: \.self) { company in - StockItem(company: company, intradayPrices: self.intradayPrices[company.symbol]!) + if let intradayPrices = nestedIntradayPrices?[company.symbol.uppercased()] { + StockItem(company: company, intradayPrices: intradayPrices.nestedIntradayPrices) + } else { + StockItem(company: company, intradayPrices: nil) + } } } .padding() @@ -32,6 +36,12 @@ } .padding(.bottom) } + + private func testPrint(_ test: Any) -> Text { + print(test) + + return Text("") + } } private func adaptTitle(_ listType: String) -> String { @@ -45,6 +55,10 @@ struct StockRectangleRow_Previews: PreviewProvider { static var previews: some View { - StockRectangleRow(listType: "gainers", list: [CompanyQuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 120.30, changePercent: 0.034)], intradayPrices: ["aapl": [IntradayPricesResult(open: 130.3)]]) + StockRectangleRow( + listName: "mostactive", + list: [QuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 130.3, changePercent: 0.03)], + nestedIntradayPrices: ["AAPL": NestedIntradayPricesModel(nestedIntradayPrices: [IntradayPricesModel(marketOpen: 130.3)])] + ) } }