annotate LazyBear/Views/Company/CompanyView.swift @ 402:8357b101df67

Implementing CompanyView in NavigationLinks
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Fri, 21 May 2021 23:39:40 +0200
parents 6055a867d2b6
children c804ce7a1560
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 {
402
8357b101df67 Implementing CompanyView in NavigationLinks
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 400
diff changeset
21 ScrollView {
8357b101df67 Implementing CompanyView in NavigationLinks
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 400
diff changeset
22 VStack {
8357b101df67 Implementing CompanyView in NavigationLinks
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 400
diff changeset
23 CompanyHeader(symbol: symbol, showViewSelector: $showViewSelector)
8357b101df67 Implementing CompanyView in NavigationLinks
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 400
diff changeset
24
8357b101df67 Implementing CompanyView in NavigationLinks
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 400
diff changeset
25 // Chart View
8357b101df67 Implementing CompanyView in NavigationLinks
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 400
diff changeset
26 if showChartView {
8357b101df67 Implementing CompanyView in NavigationLinks
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 400
diff changeset
27 Chart(company: company, symbol: symbol)
398
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
28 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
29 }
402
8357b101df67 Implementing CompanyView in NavigationLinks
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 400
diff changeset
30 .padding()
398
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
31 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
32 .actionSheet(isPresented: $showViewSelector) {
399
5c99883c7964 Implementing networking in CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents: 398
diff changeset
33 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
34 .default(Text("Chart & News")) { showChartView = true },
398
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
35 .cancel()
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
36 ])
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
37 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
38 }
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
39 }
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 struct CompanyView_Previews: PreviewProvider {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
42 static var previews: some View {
933546fa5651 Implementing CompanyView
Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
parents:
diff changeset
43 CompanyView(symbol: "AAPL")
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 }