comparison LazyBear/Views/Company/Helpers/KeyStatsHelper.swift @ 441:417148200aaf

Change background color and minor UI updates
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 20 Jun 2021 19:52:21 +0200
parents 01fa77358b82
children 6eae10397501
comparison
equal deleted inserted replaced
440:01fa77358b82 441:417148200aaf
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 13 @State private var showList = false
14 @Environment(\.colorScheme) private var colorScheme
14 15
15 var body: some View { 16 var body: some View {
16 if let keyStats = keyStats { 17 if let keyStats = keyStats {
17 ScrollView(.horizontal, showsIndicators: false) { 18 ScrollView(.horizontal, showsIndicators: false) {
18 HStack(spacing: 40) { 19 HStack(spacing: 20) {
19 20
20 let mirror = Mirror(reflecting: keyStats) 21 let mirror = Mirror(reflecting: keyStats)
21 ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class 22 ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class
22 23
23 if let unwrappedValue = unwrapAnyOptional(value: child.value) { 24 if let unwrappedValue = unwrapAnyOptional(value: child.value) {
24 let label = String(child.label!) 25 let label = String(child.label!)
25 26
26 Button(action: { showList = true }) { 27 Button(action: { showList = true }) {
27 Capsule() 28 Capsule()
28 .frame(width: 250, height: 40) 29 .frame(width: 250, height: 40)
29 .foregroundColor(.white) 30 .foregroundColor(Color("customSecondaryBackground"))
30 .shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0) 31 .if(colorScheme == .light) { content in
32 content.shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0)
33 }
31 .overlay( 34 .overlay(
32 HStack { 35 HStack {
33 Text("\(displayWords.keyStats[label]!):") 36 Text("\(displayWords.keyStats[label]!):")
34 .font(.callout) 37 .font(.callout)
35 .fontWeight(.semibold) 38 .fontWeight(.semibold)