瀏覽代碼

Refactor pulse

Jon Mårtensson 4 年之前
父節點
當前提交
e08f7309a1
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      FreeAPSWatch WatchKit Extension/Views/MainView.swift

+ 3 - 3
FreeAPSWatch WatchKit Extension/Views/MainView.swift

@@ -12,10 +12,10 @@ struct MainView: View {
     @State var isCarbsActive = false
     @State var isTargetsActive = false
     @State var isBolusActive = false
+    @State private var pulse = 0
 
     private var healthStore = HKHealthStore()
     let heartRateQuantity = HKUnit(from: "count/min")
-    @State private var value = 0
 
     var body: some View {
         ZStack(alignment: .topLeading) {
@@ -90,7 +90,7 @@ struct MainView: View {
                 Text(iobFormatter.string(from: (state.iob ?? 0) as NSNumber)!).font(.caption2)
                 Text("U").foregroundColor(.insulin)
                 Spacer()
-                Text("❤️" + " \(value)")
+                Text("❤️" + " \(pulse)")
                     .fontWeight(.regular)
                     .font(.system(size: 18)).foregroundColor(Color.red)
             }
@@ -180,7 +180,7 @@ struct MainView: View {
             if type == .heartRate {
                 lastHeartRate = sample.quantity.doubleValue(for: heartRateQuantity)
             }
-            value = Int(lastHeartRate)
+            pulse = Int(lastHeartRate)
         }
     }