comparison LazyBear/Views/Home/Helpers/StockSheet.swift @ 424:6dd97877f575

Improve code, reorganize files
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sun, 13 Jun 2021 19:40:42 +0200
parents
children 4effac4733b0
comparison
equal deleted inserted replaced
423:bdfdf3a1b34e 424:6dd97877f575
1 //
2 // StockSheet.swift
3 // LazyBear
4 //
5 // Created by Dennis Concepción Martín on 13/6/21.
6 //
7
8 import SwiftUI
9
10 struct StockSheet: View {
11 var listName: String
12 var companies: [String: QuoteModel]
13 var intradayPrices: [String: [Double]]?
14
15 @Environment(\.presentationMode) private var stockSheetPresentation
16
17 var body: some View {
18 NavigationView {
19 VStack {
20 List(Array(companies.keys.sorted()), id: \.self) { symbol in
21 NavigationLink(destination: CompanyView(symbol: symbol)) {
22 StockSheetRow(symbol: symbol, company: companies[symbol]!, intradayPrices: intradayPrices![symbol]!)
23 }
24 }
25 }
26 .navigationTitle(listName)
27 .navigationBarTitleDisplayMode(.inline)
28 .toolbar {
29 ToolbarItem(placement: .navigationBarLeading) {
30 Button(action: {stockSheetPresentation.wrappedValue.dismiss()}) {
31 Image(systemName: "multiply")
32 }
33 }
34 }
35 }
36 }
37 }
38
39 struct StockSheet_Previews: PreviewProvider {
40 static var previews: some View {
41 StockSheet(listName: "Most active", companies: ["aapl": QuoteModel(changePercent: 0.03, companyName: "Apple Inc", latestPrice: 120.3)])
42 }
43 }