Mercurial > public > lazybear
comparison LazyBear/Views/Global Helpers/StockRectangleRow.swift @ 349:5ccceb527178
Implementing new internal API
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 14 Apr 2021 23:08:26 +0200 |
parents | 80bfa88c6b0f |
children |
comparison
equal
deleted
inserted
replaced
348:0abb8d5c12ec | 349:5ccceb527178 |
---|---|
11 struct StockRectangleRow: View { | 11 struct StockRectangleRow: View { |
12 var listName: String | 12 var listName: String |
13 var list: [QuoteModel] | 13 var list: [QuoteModel] |
14 var nestedIntradayPrices: [String: NestedIntradayPricesModel]? | 14 var nestedIntradayPrices: [String: NestedIntradayPricesModel]? |
15 | 15 |
16 @State private var showExtensiveList = false | |
17 | |
16 var body: some View { | 18 var body: some View { |
17 VStack(alignment: .leading) { | 19 VStack(alignment: .leading) { |
18 Text(adaptTitle(listName)) | 20 HStack(alignment: .bottom) { |
19 .font(.title3) | 21 VStack(alignment: .leading) { |
20 .fontWeight(.semibold) | 22 Text(adaptTitle(listName)) |
21 .padding([.top, .horizontal]) | 23 .font(.title3) |
24 .fontWeight(.semibold) | |
25 .padding([.top, .horizontal]) | |
26 | |
27 Text("Real-time quotes") | |
28 .font(.caption) | |
29 .opacity(0.5) | |
30 .padding(.horizontal) | |
31 } | |
32 | |
33 Spacer() | |
34 Button("See all", action: { self.showExtensiveList = true }) | |
35 .buttonStyle(BorderlessButtonStyle()) | |
36 .padding(.horizontal) | |
37 } | |
22 | 38 |
23 ScrollView(.horizontal, showsIndicators: false) { | 39 ScrollView(.horizontal, showsIndicators: false) { |
24 HStack(spacing: 20) { | 40 HStack(spacing: 20) { |
25 ForEach(list, id: \.self) { company in | 41 ForEach(list, id: \.self) { company in |
26 if let intradayPrices = nestedIntradayPrices?[company.symbol.uppercased()] { | 42 if let intradayPrices = nestedIntradayPrices?[company.symbol.uppercased()] { |
33 .padding() | 49 .padding() |
34 } | 50 } |
35 .frame(height: 250) | 51 .frame(height: 250) |
36 } | 52 } |
37 .padding(.bottom) | 53 .padding(.bottom) |
38 } | 54 .sheet(isPresented: $showExtensiveList) { |
39 | 55 ExtensiveList(listName: adaptTitle(listName), list: list, nestedIntradayPrices: nestedIntradayPrices, latestCurrencies: nil) |
40 private func testPrint(_ test: Any) -> Text { | 56 } |
41 print(test) | |
42 | |
43 return Text("") | |
44 } | 57 } |
45 } | 58 } |
46 | 59 |
47 private func adaptTitle(_ listType: String) -> String { | 60 private func adaptTitle(_ listType: String) -> String { |
48 if listType == "mostactive" { | 61 if listType == "mostactive" { |
56 struct StockRectangleRow_Previews: PreviewProvider { | 69 struct StockRectangleRow_Previews: PreviewProvider { |
57 static var previews: some View { | 70 static var previews: some View { |
58 StockRectangleRow( | 71 StockRectangleRow( |
59 listName: "mostactive", | 72 listName: "mostactive", |
60 list: [QuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 130.3, changePercent: 0.03)], | 73 list: [QuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 130.3, changePercent: 0.03)], |
61 nestedIntradayPrices: ["AAPL": NestedIntradayPricesModel(nestedIntradayPrices: [IntradayPricesModel(marketOpen: 130.3)])] | 74 nestedIntradayPrices: ["AAPL": NestedIntradayPricesModel(nestedIntradayPrices: [IntradayPricesModel(open: 130.3)])] |
62 ) | 75 ) |
63 } | 76 } |
64 } | 77 } |