Kaynağa Gözat

%Override% on watch calendar entry

Jon Fawcett 6 yıl önce
ebeveyn
işleme
f4acb60927

+ 8 - 7
LoopFollow/Controllers/NightScout.swift

@@ -337,7 +337,7 @@ extension MainViewController {
           }
           
           var oText = "" as String
-                 
+            currentOverride = 1.0
                  if let lastOverride = lastDeviceStatus?["override"] as! [String : AnyObject]? {
                      if let lastOverrideTime = formatter.date(from: (lastOverride["timestamp"] as! String))?.timeIntervalSince1970  {
                      }
@@ -345,12 +345,13 @@ extension MainViewController {
                          
                          let lastCorrection  = lastOverride["currentCorrectionRange"] as! [String: AnyObject]
                          if let multiplier = lastOverride["multiplier"] as? Double {
-                                                oText += String(format:"%.1f", multiplier*100)
-                                            }
-                                            else
-                                            {
-                                                oText += String(format:"%.1f", 100)
-                                            }
+                            currentOverride = multiplier
+                            oText += String(format:"%.1f", multiplier*100)
+                        }
+                        else
+                        {
+                            oText += String(format:"%.1f", 100)
+                        }
                          oText += "% ("
                          let minValue = lastCorrection["minValue"] as! Double
                          let maxValue = lastCorrection["maxValue"] as! Double

+ 7 - 0
LoopFollow/ViewControllers/MainViewController.swift

@@ -70,6 +70,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
     var firstGraphLoad: Bool = true
     var firstBasalGraphLoad: Bool = true
     var minAgoBG: Double = 0.0
+    var currentOverride = 0.0
     
     // Vars for NS Pull
     var graphHours:Int=24
@@ -324,6 +325,12 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
             eventTitle = eventTitle.replacingOccurrences(of: "%BG%", with: String(self.bgData[self.bgData.count - 1].sgv))
             eventTitle = eventTitle.replacingOccurrences(of: "%DIRECTION%", with: direction)
             eventTitle = eventTitle.replacingOccurrences(of: "%DELTA%", with: deltaString)
+            if self.currentOverride != 1.0 {
+                let val = Int( self.currentOverride*100)
+               // let overrideText = String(format:"%f1", self.currentOverride*100)
+                let text = String(val) + "%"
+                eventTitle = eventTitle.replacingOccurrences(of: "%OVERRIDE%", with: text)
+            }
             var minAgo = ""
             if deltaTime > 5 {
                 // write old BG reading and continue pushing out end date to show last entry

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
LoopFollow/ViewControllers/SettingsViewController.swift