Mercurial > public > lazybear
view LazyBear/Views/Global Helpers/StockRectangleRow.swift @ 345:fde2b30c719e
Implementing Networking in ProfileView
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Thu, 08 Apr 2021 20:15:28 +0200 |
parents | ab909fc9ce55 |
children | 80bfa88c6b0f |
line wrap: on
line source
// // StockRectangleRow.swift // LazyBear // // Created by Dennis Concepción Martín on 28/3/21. // import SwiftUI struct StockRectangleRow: View { var listType: String var list: [CompanyQuoteModel] var intradayPrices: [String: [IntradayPricesResult]] var body: some View { VStack(alignment: .leading) { Text(adaptTitle(listType)) .font(.title3) .fontWeight(.semibold) .padding([.top, .horizontal]) ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 20) { ForEach(list, id: \.self) { company in StockItem(company: company, intradayPrices: self.intradayPrices[company.symbol]!) } } .padding() } .frame(height: 250) } .padding(.bottom) } } private func adaptTitle(_ listType: String) -> String { if listType == "mostactive" { return "Most active" } else { return listType.capitalized } } 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)]]) } }