annotate LazyBear/Views/Company/CompanyView.swift @ 400:6055a867d2b6

Implementing Historical Prices in Company.swift
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 15 May 2021 19:54:20 +0200
parents 5c99883c7964
children 8357b101df67
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
398
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
1 //
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
2 // CompanyView.swift
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
3 // LazyBear
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
4 //
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
5 // Created by Dennis Concepción Martín on 8/5/21.
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
6 //
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
7
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
8 import SwiftUI
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
9 import StockCharts
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
10
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
11 struct CompanyView: View {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
12 var symbol: String
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
13
399
5c99883c7964 Implementing networking in CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 398
diff changeset
14 @ObservedObject var company = Company()
398
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
15 @State private var showViewSelector = false
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
16
400
6055a867d2b6 Implementing Historical Prices in Company.swift
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 399
diff changeset
17 // Views
6055a867d2b6 Implementing Historical Prices in Company.swift
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 399
diff changeset
18 @State private var showChartView = true
399
5c99883c7964 Implementing networking in CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 398
diff changeset
19
398
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
20 var body: some View {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
21 NavigationView {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
22 ScrollView {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
23 VStack {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
24 CompanyHeader(symbol: symbol, showViewSelector: $showViewSelector)
399
5c99883c7964 Implementing networking in CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 398
diff changeset
25
400
6055a867d2b6 Implementing Historical Prices in Company.swift
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 399
diff changeset
26 // Chart View
6055a867d2b6 Implementing Historical Prices in Company.swift
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 399
diff changeset
27 if showChartView {
6055a867d2b6 Implementing Historical Prices in Company.swift
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 399
diff changeset
28 Chart(company: company, symbol: symbol)
399
5c99883c7964 Implementing networking in CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 398
diff changeset
29 }
398
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
30 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
31 .padding()
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
32 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
33 .navigationTitle("Apple inc")
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
34 .navigationBarTitleDisplayMode(.inline)
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
35 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
36 .actionSheet(isPresented: $showViewSelector) {
399
5c99883c7964 Implementing networking in CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 398
diff changeset
37 ActionSheet(title: Text("Select an option"), buttons: [
400
6055a867d2b6 Implementing Historical Prices in Company.swift
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 399
diff changeset
38 .default(Text("Chart & News")) { showChartView = true },
398
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
39 .cancel()
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
40 ])
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
41 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
42 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
43 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
44
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
45 struct CompanyView_Previews: PreviewProvider {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
46 static var previews: some View {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
47 CompanyView(symbol: "AAPL")
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
48 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
49 }