comparison LazyBear/Views/Company/Helpers/KeyStatsHelper.swift @ 440:01fa77358b82

Fixes #47
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 20 Jun 2021 16:58:36 +0200
parents aa1f4b614b2b
children 417148200aaf
comparison
equal deleted inserted replaced
439:aa1f4b614b2b 440:01fa77358b82
7 7
8 import SwiftUI 8 import SwiftUI
9 9
10 struct KeyStatsHelper: View { 10 struct KeyStatsHelper: View {
11 var keyStats: KeyStatsModel? 11 var keyStats: KeyStatsModel?
12
13 let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") 12 let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json")
13 @State private var showList = false
14 14
15 var body: some View { 15 var body: some View {
16 if let keyStats = keyStats { 16 if let keyStats = keyStats {
17 ScrollView(.horizontal, showsIndicators: false) { 17 ScrollView(.horizontal, showsIndicators: false) {
18 HStack(spacing: 40) { 18 HStack(spacing: 40) {
21 ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class 21 ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class
22 22
23 if let unwrappedValue = unwrapAnyOptional(value: child.value) { 23 if let unwrappedValue = unwrapAnyOptional(value: child.value) {
24 let label = String(child.label!) 24 let label = String(child.label!)
25 25
26 Capsule() 26 Button(action: { showList = true }) {
27 .frame(width: 250, height: 40) 27 Capsule()
28 .foregroundColor(.white) 28 .frame(width: 250, height: 40)
29 .shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) 29 .foregroundColor(.white)
30 .overlay( 30 .shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0)
31 HStack { 31 .overlay(
32 Text("\(displayWords.keyStats[label]!):") 32 HStack {
33 .font(.callout) 33 Text("\(displayWords.keyStats[label]!):")
34 .fontWeight(.semibold) 34 .font(.callout)
35 .lineLimit(1) 35 .fontWeight(.semibold)
36 36 .lineLimit(1)
37 Spacer() 37
38 Text(unwrappedValue) 38 Spacer()
39 .font(.callout) 39 Text(unwrappedValue)
40 .lineLimit(1) 40 .font(.callout)
41 } 41 .lineLimit(1)
42 .padding() 42 }
43 ) 43 .padding()
44 )
45 }
46 .buttonStyle(PlainButtonStyle())
44 } 47 }
45 } 48 }
46 } 49 }
47 .frame(height: 80) 50 .frame(height: 80)
48 .padding(.horizontal) 51 .padding(.horizontal)
52 }
53 .sheet(isPresented: $showList) {
54 KeyStatsList(keyStats: keyStats)
49 } 55 }
50 } 56 }
51 } 57 }
52 58
53 /* 59 /*