ソースを参照

Better format for Apple Watch Home View.

Have same size for HR as other items. Longpress the Heart for 1 seconds to make the heart and HR font bigger size. Long press again to reduce to before.
Align Loop Circle and min ago with BG and delta BG horisontally.
Remove inverted logic.
Jon Mårtensson 3 年 前
コミット
ba4b0e6a92

+ 1 - 1
FreeAPS/Sources/Services/WatchManager/WatchManager.swift

@@ -80,7 +80,7 @@ final class BaseWatchManager: NSObject, WatchManager, Injectable {
                 }
             self.state.bolusAfterCarbs = !self.settingsManager.settings.skipBolusScreenAfterCarbs
 
-            self.state.displayHR = !self.settingsManager.settings.displayHR
+            self.state.displayHR = self.settingsManager.settings.displayHR
 
             self.state.eventualBG = self.evetualBGStraing()
 

+ 42 - 5
FreeAPSWatch WatchKit Extension/Views/MainView.swift

@@ -14,6 +14,9 @@ struct MainView: View {
     @State var isBolusActive = false
     @State private var pulse = 0
 
+    @GestureState var isDetectingLongPress = false
+    @State var completedLongPress = false
+
     private var healthStore = HKHealthStore()
     let heartRateQuantity = HKUnit(from: "count/min")
 
@@ -73,7 +76,7 @@ struct MainView: View {
 
                 VStack(spacing: 0) {
                     HStack {
-                        Circle().stroke(color, lineWidth: 6).frame(width: 30, height: 30).padding(10)
+                        Circle().stroke(color, lineWidth: 5).frame(width: 26, height: 26).padding(10)
                     }
 
                     if state.lastLoopDate != nil {
@@ -108,12 +111,33 @@ struct MainView: View {
                     .foregroundColor(.loopGreen)
                     .minimumScaleFactor(0.5)
 
-                if !state.displayHR {
+                if state.displayHR {
                     Spacer()
                     HStack {
-                        Text("❤️" + " \(pulse)")
-                            .fontWeight(.regular)
-                            .font(.system(size: 18)).foregroundColor(Color.white)
+                        if completedLongPress {
+                            HStack {
+                                Text("❤️" + " \(pulse)")
+                                    .fontWeight(.regular)
+                                    .font(.custom("activated", size: 22))
+                                    .scaledToFill()
+                                    .foregroundColor(.white)
+                                    .minimumScaleFactor(0.5)
+                            }
+                            .scaleEffect(isDetectingLongPress ? 3 : 1)
+                            .gesture(longPress)
+
+                        } else {
+                            HStack {
+                                Text("❤️" + " \(pulse)")
+                                    .fontWeight(.regular)
+                                    .font(.caption2)
+                                    .scaledToFill()
+                                    .foregroundColor(.white)
+                                    .minimumScaleFactor(0.5)
+                            }
+                            .scaleEffect(isDetectingLongPress ? 3 : 1)
+                            .gesture(longPress)
+                        }
                     }
 
                 } else if let eventualBG = state.eventualBG.nonEmpty {
@@ -132,6 +156,19 @@ struct MainView: View {
         }.padding()
     }
 
+    var longPress: some Gesture {
+        LongPressGesture(minimumDuration: 1)
+            .updating($isDetectingLongPress) { currentState, gestureState,
+                _ in
+                gestureState = currentState
+            }
+            .onEnded { _ in
+                if completedLongPress {
+                    completedLongPress = false
+                } else { completedLongPress = true }
+            }
+    }
+
     var buttons: some View {
         HStack(alignment: .center) {
             NavigationLink(isActive: $state.isCarbsViewActive) {