comparison LazyBear/Views/Company/CompanyView.swift @ 439:aa1f4b614b2b

Implementing CompanyView
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 20 Jun 2021 14:31:39 +0200
parents 7f2a24a774eb
children 01fa77358b82
comparison
equal deleted inserted replaced
438:7f2a24a774eb 439:aa1f4b614b2b
6 // 6 //
7 7
8 import SwiftUI 8 import SwiftUI
9 9
10 struct CompanyView: View { 10 struct CompanyView: View {
11 var symbol: String
12 var name: String
13
11 @ObservedObject var company = Company() 14 @ObservedObject var company = Company()
12 15
13 var body: some View { 16 var body: some View {
14 NavigationView { 17 if company.showView {
15 VStack { 18 NavigationView {
16 RowShape() 19 ScrollView {
20 VStack {
21 HStack {
22 Text(name.capitalized)
23 .font(.title)
24 .fontWeight(.semibold)
25 .lineLimit(1)
26
27 Spacer()
28 }
29 .padding(.horizontal)
30
31 ChartHelper(quote: company.data.quote, historicalPrices: company.data.historicalPrices)
32 KeyStatsHelper(keyStats: company.data.keyStats)
33 }
34 }
35 .background(Color(.systemGray6).edgesIgnoringSafeArea(.all))
36 .navigationTitle(symbol.uppercased())
17 } 37 }
38 } else {
39 ProgressView()
40 .onAppear {
41 company.request("https://api.lazybear.app/company/symbol=aapl", .initial)
42 }
18 } 43 }
19 } 44 }
20 } 45 }
21 46
22 struct CompanyView_Previews: PreviewProvider { 47 struct CompanyView_Previews: PreviewProvider {
23 static var previews: some View { 48 static var previews: some View {
24 CompanyView() 49 CompanyView(symbol: "aapl", name: "apple inc")
25 } 50 }
26 } 51 }