comparison LazyBear/Views/Global Helpers/StockRectangleRow.swift @ 343:ab909fc9ce55

Implement batch requests HomeView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Tue, 06 Apr 2021 11:04:21 +0200
parents
children fde2b30c719e
comparison
equal deleted inserted replaced
342:a6c49f1409f3 343:ab909fc9ce55
1 //
2 // StockRectangleRow.swift
3 // LazyBear
4 //
5 // Created by Dennis Concepción Martín on 28/3/21.
6 //
7
8 import SwiftUI
9
10
11 struct StockRectangleRow: View {
12 var listType: String
13 var list: [CompanyQuoteModel]
14 var intradayPrices: [String: [IntradayPricesResult]]
15
16 var body: some View {
17 VStack(alignment: .leading) {
18 Text(adaptTitle(listType))
19 .font(.title3)
20 .fontWeight(.semibold)
21 .padding([.top, .horizontal])
22
23 ScrollView(.horizontal, showsIndicators: false) {
24 HStack(spacing: 20) {
25 ForEach(list, id: \.self) { company in
26 StockItem(company: company, intradayPrices: self.intradayPrices[company.symbol]!)
27 }
28 }
29 .padding()
30 }
31 .frame(height: 250)
32 }
33 .padding(.bottom)
34 }
35 }
36
37 private func adaptTitle(_ listType: String) -> String {
38 if listType == "mostactive" {
39 return "Most active"
40 } else {
41 return listType.capitalized
42 }
43 }
44
45
46 //struct StockRectangleRow_Previews: PreviewProvider {
47 // static var previews: some View {
48 // StockRectangleRow(listType: "gainers", list: [CompanyQuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 120.30, changePercent: 0.034)])
49 // }
50 //}