Mercurial > public > lazybear
comparison LazyBear/Views/Company/Helpers/StatsView.swift @ 415:34f9e408b861
Minor UI Updates and tests
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 09 Jun 2021 12:49:17 +0200 |
parents | |
children | 1662a41e2c1a |
comparison
equal
deleted
inserted
replaced
414:b93172662988 | 415:34f9e408b861 |
---|---|
1 // | |
2 // StatsView.swift | |
3 // LazyBear | |
4 // | |
5 // Created by Dennis Concepción Martín on 9/6/21. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 struct StatsView: View { | |
11 var keyStats: KeyStatsModel | |
12 @Environment(\.presentationMode) private var presentationStatsView | |
13 | |
14 var body: some View { | |
15 NavigationView { | |
16 Form { | |
17 let mirror = Mirror(reflecting: keyStats) | |
18 ForEach(Array(mirror.children), id: \.label) { child in | |
19 HStack { | |
20 let label = String(child.label!) | |
21 | |
22 Text("\(label)".capitalized) | |
23 .fontWeight(.semibold) | |
24 | |
25 // Unwrap optional value | |
26 if let doubleValue = child.value as? Double { | |
27 Text("\(doubleValue)") | |
28 } else if let intValue = child.value as? Int { | |
29 Text("\(intValue)") | |
30 } else if let stringValue = child.value as? String { | |
31 Text("\(stringValue)") | |
32 } else { | |
33 Text("NaN") | |
34 } | |
35 } | |
36 } | |
37 } | |
38 .navigationTitle("Key statistics") | |
39 .navigationBarTitleDisplayMode(.inline) | |
40 .toolbar { | |
41 ToolbarItem(placement: .navigationBarLeading) { | |
42 Button(action: { presentationStatsView.wrappedValue.dismiss() }) { | |
43 Image(systemName: "multiply") | |
44 .imageScale(.large) | |
45 } | |
46 } | |
47 } | |
48 } | |
49 } | |
50 } | |
51 | |
52 | |
53 struct StatsView_Previews: PreviewProvider { | |
54 static var previews: some View { | |
55 StatsView(keyStats: | |
56 KeyStatsModel(avg10Volume: 123, | |
57 avg30Volume: 123, | |
58 beta: 123.12, | |
59 companyName: "Apple inc", | |
60 day200MovingAvg: 123.4, | |
61 day30ChangePercent: 123.4, | |
62 day50MovingAvg: 123.4, | |
63 day5ChangePercent: 123.4, | |
64 dividendYield: 123.4, | |
65 employees: 123, | |
66 exDividendDate: "2020-01-01", | |
67 float: 123, | |
68 marketcap: 123, | |
69 maxChangePercent: 123.4, | |
70 month1ChangePercent: 123.4, | |
71 month3ChangePercent: 123.4, | |
72 month6ChangePercent: 123.4, | |
73 nextDividendDate: "2020-01-01", | |
74 nextEarningsDate: "2020-01-01", | |
75 peRatio: 123.4, | |
76 sharesOutstanding: 123, | |
77 ttmDividendRate: 123.4, | |
78 ttmEPS: 123.4, | |
79 week52Change: 123.4, | |
80 week52High: 123.4, | |
81 week52HighSplitAdjustOnly: 123.4, | |
82 week52Low: 123.4, | |
83 week52LowSplitAdjustOnly: 123.4, | |
84 year1ChangePercent: 123.4, | |
85 year2ChangePercent: 123.4, | |
86 year5ChangePercent: 123.4, | |
87 ytdChangePercent: 123.4 | |
88 ) | |
89 ) | |
90 } | |
91 } |