Преглед изворни кода

Fix Type bug.
Uncomment the gray code if you want to display minutes ago for glucose on Watch app (kind of unnecesary as it normally should be same value as last loop minutes ago...)

Jon Mårtensson пре 2 година
родитељ
комит
7476aac93d

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

@@ -62,7 +62,6 @@ final class BaseWatchManager: NSObject, WatchManager, Injectable {
             self.state.delta = glucoseValues.delta
             self.state.delta = glucoseValues.delta
             self.state.trendRaw = readings.first?.direction ?? "↔︎"
             self.state.trendRaw = readings.first?.direction ?? "↔︎"
             self.state.glucoseDate = readings.first?.date ?? .distantPast
             self.state.glucoseDate = readings.first?.date ?? .distantPast
-            self.state.glucoseDateInterval = self.state.glucoseDate.map { UInt64($0.timeIntervalSince1970) }
             self.state.lastLoopDate = self.enactedSuggestion?.recieved == true ? self.enactedSuggestion?.deliverAt : self
             self.state.lastLoopDate = self.enactedSuggestion?.recieved == true ? self.enactedSuggestion?.deliverAt : self
                 .apsManager.lastLoopDate
                 .apsManager.lastLoopDate
             self.state.lastLoopDateInterval = self.state.lastLoopDate.map {
             self.state.lastLoopDateInterval = self.state.lastLoopDate.map {

+ 0 - 1
FreeAPSWatch WatchKit Extension/DataFlow.swift

@@ -6,7 +6,6 @@ struct WatchState: Codable {
     var trendRaw: String?
     var trendRaw: String?
     var delta: String?
     var delta: String?
     var glucoseDate: Date?
     var glucoseDate: Date?
-    var glucoseDateInterval: UInt64?
     var lastLoopDate: Date?
     var lastLoopDate: Date?
     var lastLoopDateInterval: UInt64?
     var lastLoopDateInterval: UInt64?
     var bolusIncrement: Decimal?
     var bolusIncrement: Decimal?

+ 12 - 1
FreeAPSWatch WatchKit Extension/Views/MainView.swift

@@ -80,7 +80,18 @@ struct MainView: View {
                             .scaledToFill()
                             .scaledToFill()
                             .minimumScaleFactor(0.5)
                             .minimumScaleFactor(0.5)
                     }
                     }
-                    Text(state.delta).font(.caption2).foregroundColor(.gray)
+                    /* IF YOU WANT TO DISPLAY MINUTES AGO, UNCOMMENT the gray code below
+                     let minutesAgo: TimeInterval = -1 * (state.glucoseDate ?? .distantPast).timeIntervalSinceNow / 60
+                     let minuteString = minutesAgo.formatted(.number.grouping(.never).rounded().precision(.fractionLength(0)))
+                     */
+                    HStack {
+                        /* if minutesAgo > 0 {
+                             Text(minuteString)
+                             Text("min")
+                         } */
+                        Text(state.delta)
+                    }
+                    .font(.caption2).foregroundColor(.gray)
                 }
                 }
                 Spacer()
                 Spacer()