Mercurial > public > lazybear
comparison LazyBear/Views/Home/Helpers/StockSheet.swift @ 425:4effac4733b0
Changing keys from API responses
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 16 Jun 2021 13:46:01 +0200 |
parents | 6dd97877f575 |
children | ffbb1dbab531 |
comparison
equal
deleted
inserted
replaced
424:6dd97877f575 | 425:4effac4733b0 |
---|---|
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct StockSheet: View { | 10 struct StockSheet: View { |
11 var listName: String | 11 var listName: String |
12 var companies: [String: QuoteModel] | 12 var companies: [CompanyModel] |
13 var intradayPrices: [String: [Double]]? | |
14 | 13 |
15 @Environment(\.presentationMode) private var stockSheetPresentation | 14 @Environment(\.presentationMode) private var stockSheetPresentation |
16 | 15 |
17 var body: some View { | 16 var body: some View { |
18 NavigationView { | 17 NavigationView { |
19 VStack { | 18 VStack { |
20 List(Array(companies.keys.sorted()), id: \.self) { symbol in | 19 List(companies, id: \.self) { company in |
21 NavigationLink(destination: CompanyView(symbol: symbol)) { | 20 StockSheetRow(company: company) |
22 StockSheetRow(symbol: symbol, company: companies[symbol]!, intradayPrices: intradayPrices![symbol]!) | |
23 } | |
24 } | 21 } |
25 } | 22 } |
26 .navigationTitle(listName) | 23 .navigationTitle(listName) |
27 .navigationBarTitleDisplayMode(.inline) | 24 .navigationBarTitleDisplayMode(.inline) |
28 .toolbar { | 25 .toolbar { |
36 } | 33 } |
37 } | 34 } |
38 | 35 |
39 struct StockSheet_Previews: PreviewProvider { | 36 struct StockSheet_Previews: PreviewProvider { |
40 static var previews: some View { | 37 static var previews: some View { |
41 StockSheet(listName: "Most active", companies: ["aapl": QuoteModel(changePercent: 0.03, companyName: "Apple Inc", latestPrice: 120.3)]) | 38 StockSheet( |
39 listName: "Most active", | |
40 companies: [CompanyModel(symbol: "aapl", companyName: "Apple Inc", latestPrice: 120.3, changePercent: 0.03, intradayPrices: [120.3])] | |
41 ) | |
42 } | 42 } |
43 } | 43 } |