comparison LazyBear/Views/Company/Helpers/KeyStatsHelper.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
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 let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") 12 let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json")
13 @State private var showList = false
14 @Environment(\.colorScheme) private var colorScheme 13 @Environment(\.colorScheme) private var colorScheme
15 14
16 var body: some View { 15 var body: some View {
17 if let keyStats = keyStats { 16 if let keyStats = keyStats {
18 ScrollView(.horizontal, showsIndicators: false) { 17 ScrollView(.horizontal, showsIndicators: false) {
22 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
23 22
24 if let unwrappedValue = unwrapAnyOptional(value: child.value) { 23 if let unwrappedValue = unwrapAnyOptional(value: child.value) {
25 let label = String(child.label!) 24 let label = String(child.label!)
26 25
27 Button(action: { showList = true }) { 26 NavigationLink(destination: KeyStatsList(keyStats: keyStats)
27 .navigationTitle("Key Stats")
28 ) {
28 Capsule() 29 Capsule()
29 .frame(width: 250, height: 40) 30 .frame(width: 250, height: 40)
30 .foregroundColor(Color("customSecondaryBackground")) 31 .foregroundColor(Color("customSecondaryBackground"))
31 .if(colorScheme == .light) { content in 32 .if(colorScheme == .light) { content in
32 content.shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) 33 content.shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0)
50 } 51 }
51 } 52 }
52 } 53 }
53 .frame(height: 70) 54 .frame(height: 70)
54 .padding(.horizontal) 55 .padding(.horizontal)
55 }
56 .sheet(isPresented: $showList) {
57 KeyStatsList(keyStats: keyStats, isPresented: $showList)
58 } 56 }
59 } 57 }
60 } 58 }
61 59
62 /* 60 /*