Mercurial > public > lazybear
comparison LazyBear/Views/Company/Helpers/StatsView.swift @ 417:5f21f7c23c5e
Add comments and clean code
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Fri, 11 Jun 2021 11:37:42 +0200 |
parents | 1662a41e2c1a |
children | 6dd97877f575 |
comparison
equal
deleted
inserted
replaced
416:1662a41e2c1a | 417:5f21f7c23c5e |
---|---|
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct StatsView: View { | 10 struct StatsView: View { |
11 var keyStats: KeyStatsModel | 11 var keyStats: KeyStatsModel |
12 | |
12 @Environment(\.presentationMode) private var presentationStatsView | 13 @Environment(\.presentationMode) private var presentationStatsView |
14 | |
13 let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") | 15 let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") |
14 | 16 |
15 var body: some View { | 17 var body: some View { |
16 NavigationView { | 18 NavigationView { |
17 Form { | 19 Form { |
18 let mirror = Mirror(reflecting: keyStats) | 20 let mirror = Mirror(reflecting: keyStats) |
19 ForEach(Array(mirror.children), id: \.label) { child in | 21 ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class |
20 if let unwrappedValue = unwrapAnyOptional(value: child.value) { | 22 if let unwrappedValue = unwrapAnyOptional(value: child.value) { |
21 HStack { | 23 HStack { |
22 let label = String(child.label!) | 24 let label = String(child.label!) |
23 Text("\(displayWords.keyStats[label]!):") | 25 Text("\(displayWords.keyStats[label]!):") |
24 .font(.callout) | 26 .font(.callout) |
60 | 62 |
61 | 63 |
62 struct StatsView_Previews: PreviewProvider { | 64 struct StatsView_Previews: PreviewProvider { |
63 static var previews: some View { | 65 static var previews: some View { |
64 StatsView(keyStats: | 66 StatsView(keyStats: |
65 KeyStatsModel( | 67 KeyStatsModel( |
66 companyName: "Apple inc", | 68 companyName: "Apple inc", |
67 employees: 123, | 69 employees: 123, |
68 marketcap: 123, | 70 marketcap: 123, |
69 float: 123, | 71 float: 123, |
70 sharesOutstanding: 123, | 72 sharesOutstanding: 123, |
71 beta: 123.12, | 73 beta: 123.12, |
72 peRatio: 123.4, | 74 peRatio: 123.4, |
73 dividendYield: 123.4, | 75 dividendYield: 123.4, |
74 ttmDividendRate: 123.4, | 76 ttmDividendRate: 123.4, |
75 ttmEPS: 123.4, | 77 ttmEPS: 123.4, |
76 avg10Volume: 123, | 78 avg10Volume: 123, |
77 avg30Volume: 123, | 79 avg30Volume: 123, |
78 day50MovingAvg: 123.4, | 80 day50MovingAvg: 123.4, |
79 day200MovingAvg: 123.4, | 81 day200MovingAvg: 123.4, |
80 week52Change: 123.4, | 82 week52Change: 123.4, |
81 week52High: 123.4, | 83 week52High: 123.4, |
82 week52Low: 123.4, | 84 week52Low: 123.4, |
83 week52HighSplitAdjustOnly: 123.4, | 85 week52HighSplitAdjustOnly: 123.4, |
84 week52LowSplitAdjustOnly: 123.4, | 86 week52LowSplitAdjustOnly: 123.4, |
85 maxChangePercent: 123.4, | 87 maxChangePercent: 123.4, |
86 ytdChangePercent: 123.4, | 88 ytdChangePercent: 123.4, |
87 day5ChangePercent: 123.4, | 89 day5ChangePercent: 123.4, |
88 day30ChangePercent: 123.4, | 90 day30ChangePercent: 123.4, |
89 month1ChangePercent: 123.4, | 91 month1ChangePercent: 123.4, |
90 month3ChangePercent: 123.4, | 92 month3ChangePercent: 123.4, |
91 month6ChangePercent: 123.4, | 93 month6ChangePercent: 123.4, |
92 year1ChangePercent: 123.4, | 94 year1ChangePercent: 123.4, |
93 year2ChangePercent: 123.4, | 95 year2ChangePercent: 123.4, |
94 year5ChangePercent: 123.4, | 96 year5ChangePercent: 123.4, |
95 exDividendDate: "2020-01-01", | 97 exDividendDate: "2020-01-01", |
96 nextDividendDate: "2020-01-01", | 98 nextDividendDate: "2020-01-01", |
97 nextEarningsDate: "2020-01-01" | 99 nextEarningsDate: "2020-01-01" |
98 ) | 100 ) |
99 ) | 101 ) |
100 } | 102 } |
101 } | 103 } |