diff 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
line wrap: on
line diff
--- a/LazyBear/Views/Company/Helpers/KeyStatsHelper.swift	Sun Jun 20 14:31:39 2021 +0200
+++ b/LazyBear/Views/Company/Helpers/KeyStatsHelper.swift	Sun Jun 20 16:58:36 2021 +0200
@@ -9,8 +9,8 @@
 
 struct KeyStatsHelper: View {
     var keyStats: KeyStatsModel?
-    
     let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json")
+    @State private var showList = false
     
     var body: some View {
         if let keyStats = keyStats {
@@ -23,30 +23,36 @@
                         if let unwrappedValue = unwrapAnyOptional(value: child.value) {
                             let label = String(child.label!)
                             
-                            Capsule()
-                                .frame(width: 250, height: 40)
-                                .foregroundColor(.white)
-                                .shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0)
-                                .overlay(
-                                    HStack {
-                                        Text("\(displayWords.keyStats[label]!):")
-                                            .font(.callout)
-                                            .fontWeight(.semibold)
-                                            .lineLimit(1)
-                                        
-                                        Spacer()
-                                        Text(unwrappedValue)
-                                            .font(.callout)
-                                            .lineLimit(1)
-                                    }
-                                    .padding()
-                                )
+                            Button(action: { showList = true }) {
+                                Capsule()
+                                    .frame(width: 250, height: 40)
+                                    .foregroundColor(.white)
+                                    .shadow(color: Color(.systemGray).opacity(0.25), radius: 10, x: 0.0, y: 0.0)
+                                    .overlay(
+                                        HStack {
+                                            Text("\(displayWords.keyStats[label]!):")
+                                                .font(.callout)
+                                                .fontWeight(.semibold)
+                                                .lineLimit(1)
+                                            
+                                            Spacer()
+                                            Text(unwrappedValue)
+                                                .font(.callout)
+                                                .lineLimit(1)
+                                        }
+                                        .padding()
+                                    )
+                            }
+                            .buttonStyle(PlainButtonStyle())
                         }
                     }
                 }
                 .frame(height: 80)
                 .padding(.horizontal)
             }
+            .sheet(isPresented: $showList) {
+                KeyStatsList(keyStats: keyStats)
+            }
         }
     }