Mercurial > public > lazybear
comparison LazyBear/Views/Company/CompanyView.swift @ 434:277197ce1416
Delete CompanyView and Helpers
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sun, 20 Jun 2021 12:36:55 +0200 |
parents | 5f21f7c23c5e |
children | 7f2a24a774eb |
comparison
equal
deleted
inserted
replaced
433:95abeedbad38 | 434:277197ce1416 |
---|---|
1 // | 1 // |
2 // CompanyView.swift | 2 // CompanyView.swift |
3 // LazyBear | 3 // LazyBear |
4 // | 4 // |
5 // Created by Dennis Concepción Martín on 8/5/21. | 5 // Created by Dennis Concepción Martín on 20/6/21. |
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 import StockCharts | |
10 | 9 |
11 struct CompanyView: View { | 10 struct CompanyView: View { |
12 var symbol: String | |
13 @ObservedObject var company = Company() | |
14 @State private var showViewSelector = false | |
15 | |
16 /* | |
17 Views | |
18 */ | |
19 @State private var showChartView = true | |
20 @State private var showInsiderView = false | |
21 | |
22 var body: some View { | 11 var body: some View { |
23 ScrollView { | 12 Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) |
24 VStack { | |
25 CompanyHeader(symbol: symbol, showViewSelector: $showViewSelector) | |
26 .padding(.bottom) | |
27 | |
28 if showChartView { | |
29 Chart(company: company, symbol: symbol) | |
30 } else if showInsiderView { | |
31 Insiders(company: company, symbol: symbol) | |
32 } | |
33 } | |
34 .padding() | |
35 } | |
36 .actionSheet(isPresented: $showViewSelector) { | |
37 ActionSheet(title: Text("Select an option"), buttons: [ | |
38 .default(Text("Chart & News")) { resetViews(); showChartView = true }, | |
39 .default(Text("Insiders")) { resetViews(); showInsiderView = true }, | |
40 .cancel() | |
41 ]) | |
42 } | |
43 } | |
44 | |
45 /* | |
46 Hide all views to show the one selected by user | |
47 */ | |
48 private func resetViews() { | |
49 showChartView = false | |
50 showInsiderView = false | |
51 } | 13 } |
52 } | 14 } |
53 | 15 |
54 struct CompanyView_Previews: PreviewProvider { | 16 struct CompanyView_Previews: PreviewProvider { |
55 static var previews: some View { | 17 static var previews: some View { |
56 CompanyView(symbol: "AAPL") | 18 CompanyView() |
57 } | 19 } |
58 } | 20 } |