comparison LazyBear/Views/Company/Helpers/KeyStatsList.swift @ 447:8621ba6fd457

Fixes #48
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Wed, 23 Jun 2021 10:54:47 +0200
parents 7d1c4dc8d1d8
children f71761f166f2
comparison
equal deleted inserted replaced
446:9cc0455bc46f 447:8621ba6fd457
7 7
8 import SwiftUI 8 import SwiftUI
9 9
10 struct KeyStatsList: View { 10 struct KeyStatsList: View {
11 var keyStats: KeyStatsModel 11 var keyStats: KeyStatsModel
12 @Binding var isPresented: Bool
13 let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") 12 let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json")
14 13
15 var body: some View { 14 var body: some View {
16 NavigationView { 15 Form {
17 Form { 16 let mirror = Mirror(reflecting: keyStats)
18 let mirror = Mirror(reflecting: keyStats) 17 ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class
19 ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class 18 if let unwrappedValue = unwrapAnyOptional(value: child.value) {
20 if let unwrappedValue = unwrapAnyOptional(value: child.value) { 19 let label = String(child.label!)
21 let label = String(child.label!) 20 HStack {
22 HStack { 21 Text("\(displayWords.keyStats[label]!):")
23 Text("\(displayWords.keyStats[label]!):") 22 .font(.callout)
24 .font(.callout) 23 .fontWeight(.semibold)
25 .fontWeight(.semibold) 24 .lineLimit(1)
26 .lineLimit(1) 25
27 26 Spacer()
28 Spacer() 27 Text(unwrappedValue)
29 Text(unwrappedValue) 28 .font(.callout)
30 .font(.callout) 29 .lineLimit(1)
31 .lineLimit(1)
32 }
33 } 30 }
34 }
35 }
36 .navigationTitle("Key Stats")
37 .toolbar {
38 ToolbarItem(placement: .navigationBarLeading) {
39 Button(action: { self.isPresented.toggle() }) {
40 Image(systemName: "multiply")
41 }
42
43 } 31 }
44 } 32 }
45 } 33 }
46 } 34 }
47 35
94 year5ChangePercent: 123.4, 82 year5ChangePercent: 123.4,
95 exDividendDate: "2020-01-01", 83 exDividendDate: "2020-01-01",
96 nextDividendDate: "2020-01-01", 84 nextDividendDate: "2020-01-01",
97 nextEarningsDate: "2020-01-01" 85 nextEarningsDate: "2020-01-01"
98 ) 86 )
99 , isPresented: .constant(true)
100 ) 87 )
101 } 88 }
102 } 89 }