Kaynağa Gözat

Function Added
1) Recommended Bolus
2) Saving scaleX
3) infoData display settings
4) main display enhancements

Jose Paredes 6 yıl önce
ebeveyn
işleme
07876aca71

+ 10 - 2
LoopFollow.xcodeproj/project.pbxproj

@@ -8,7 +8,9 @@
 
 /* Begin PBXBuildFile section */
 		3F1335F351590E573D8E6962 /* Pods_LoopFollow.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7D55B42A22051DAD69E89D0 /* Pods_LoopFollow.framework */; };
+		DD152D3B24C01B2300361FA2 /* InfoDisplaySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD152D3A24C01B2300361FA2 /* InfoDisplaySettingsViewController.swift */; };
 		DD98F54424BCEFEE0007425A /* ShareClientExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD98F54324BCEFEE0007425A /* ShareClientExtension.swift */; };
+		DDCF979424C0D380002C9752 /* UIViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCF979324C0D380002C9752 /* UIViewExtension.swift */; };
 		FC16A97A24996673003D6245 /* NightScout.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC16A97924996673003D6245 /* NightScout.swift */; };
 		FC16A97B249966A3003D6245 /* AlarmSound.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC7CE589248ABEA3001F83B8 /* AlarmSound.swift */; };
 		FC16A97D24996747003D6245 /* Alarms.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC16A97C24996747003D6245 /* Alarms.swift */; };
@@ -163,7 +165,9 @@
 /* Begin PBXFileReference section */
 		059B0FA59AABFE72FE13DDDA /* Pods-LoopFollow.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LoopFollow.release.xcconfig"; path = "Target Support Files/Pods-LoopFollow/Pods-LoopFollow.release.xcconfig"; sourceTree = "<group>"; };
 		A7D55B42A22051DAD69E89D0 /* Pods_LoopFollow.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LoopFollow.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		DD152D3A24C01B2300361FA2 /* InfoDisplaySettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoDisplaySettingsViewController.swift; sourceTree = "<group>"; };
 		DD98F54324BCEFEE0007425A /* ShareClientExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareClientExtension.swift; sourceTree = "<group>"; };
+		DDCF979324C0D380002C9752 /* UIViewExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewExtension.swift; sourceTree = "<group>"; };
 		ECA3EFB4037410B4973BB632 /* Pods-LoopFollow.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LoopFollow.debug.xcconfig"; path = "Target Support Files/Pods-LoopFollow/Pods-LoopFollow.debug.xcconfig"; sourceTree = "<group>"; };
 		FC16A97924996673003D6245 /* NightScout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NightScout.swift; sourceTree = "<group>"; };
 		FC16A97C24996747003D6245 /* Alarms.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alarms.swift; sourceTree = "<group>"; };
@@ -356,6 +360,7 @@
 			isa = PBXGroup;
 			children = (
 				DD98F54324BCEFEE0007425A /* ShareClientExtension.swift */,
+				DDCF979324C0D380002C9752 /* UIViewExtension.swift */,
 			);
 			path = Extensions;
 			sourceTree = "<group>";
@@ -589,6 +594,7 @@
 				FCFEECA1248857A600402A7F /* SettingsViewController.swift */,
 				FCC6884F248935D800A0279D /* AlarmViewController.swift */,
 				FC7CE59E248D8D23001F83B8 /* SnoozeViewController.swift */,
+				DD152D3A24C01B2300361FA2 /* InfoDisplaySettingsViewController.swift */,
 			);
 			path = ViewControllers;
 			sourceTree = "<group>";
@@ -844,10 +850,12 @@
 				FC16A97B249966A3003D6245 /* AlarmSound.swift in Sources */,
 				FCFEECA2248857A600402A7F /* SettingsViewController.swift in Sources */,
 				FCFEECA02488157B00402A7F /* Chart.swift in Sources */,
+				DDCF979424C0D380002C9752 /* UIViewExtension.swift in Sources */,
 				FCEF87AC24A141A700AE6FA0 /* bgUnits.swift in Sources */,
 				FC1BDD3224A2585C001B652C /* DataStructs.swift in Sources */,
 				FCC6886524898EEE00A0279D /* UserDefaults.swift in Sources */,
 				FC16A97F249969E2003D6245 /* Graphs.swift in Sources */,
+				DD152D3B24C01B2300361FA2 /* InfoDisplaySettingsViewController.swift in Sources */,
 				FC97881C2485969B00A7906C /* MainViewController.swift in Sources */,
 				FCC0FAC224922A22003E610E /* DictionaryKeyPath.swift in Sources */,
 				FC9788182485969B00A7906C /* AppDelegate.swift in Sources */,
@@ -1010,7 +1018,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_ENTITLEMENTS = "LoopFollow/Loop Follow.entitlements";
 				CODE_SIGN_STYLE = Automatic;
-				DEVELOPMENT_TEAM = "";
+				DEVELOPMENT_TEAM = 9W476TGJ4S;
 				INFOPLIST_FILE = LoopFollow/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1031,7 +1039,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_ENTITLEMENTS = "LoopFollow/Loop Follow.entitlements";
 				CODE_SIGN_STYLE = Automatic;
-				DEVELOPMENT_TEAM = "";
+				DEVELOPMENT_TEAM = 9W476TGJ4S;
 				INFOPLIST_FILE = LoopFollow/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",

+ 22 - 4
LoopFollow/Controllers/Graphs.swift

@@ -27,9 +27,22 @@ extension MainViewController {
             //BGChartFull.highlightValue(x: Double(currentMatrix.tx), y: Double(currentMatrix.ty), dataSetIndex: 0)
         }
     }
+    
+    func chartScaled(_ chartView: ChartViewBase, scaleX: CGFloat, scaleY: CGFloat) {
+        print("Chart Scaled: \(BGChart.scaleX), \(BGChart.scaleY)")
+      
+        // dont store huge values
+        var scale: Float = Float(BGChart.scaleX)
+        if(scale > 18.0 ) {
+            scale = 18.0
+        }
+        UserDefaultsRepository.chartScaleX.value = Float(scale)
+    }
+    
 
     func createGraph(){
         self.BGChart.clear()
+        
         // Create the BG Graph Data
         let entries = bgData
         var bgChartEntry = [ChartDataEntry]()
@@ -211,11 +224,12 @@ extension MainViewController {
         BGChart.scaleYEnabled = false
         BGChart.drawGridBackgroundEnabled = false
         //BGChart.gridBackgroundColor = NSUIColor.secondarySystemBackground
+      
         
         BGChart.data = data
         BGChart.setExtraOffsets(left: 10, top: 10, right: 10, bottom: 10)
         BGChart.setVisibleXRangeMinimum(10)
-       
+        //BGChart.setVisibleXRangeMaximum(18)
         
     }
     
@@ -293,7 +307,6 @@ extension MainViewController {
         }
         
         
-        
         // Set Colors
         let lineBG = BGChart.lineData!.dataSets[dataIndex] as! LineChartDataSet
 
@@ -315,7 +328,6 @@ extension MainViewController {
         
         BGChart.rightAxis.axisMaximum = Double(maxBG)
        
-        
         BGChart.data?.dataSets[dataIndex].notifyDataSetChanged()
         BGChart.data?.notifyDataChanged()
         BGChart.notifyDataSetChanged()
@@ -324,7 +336,13 @@ extension MainViewController {
         BGChartFull.notifyDataSetChanged()
         
         if firstGraphLoad {
-            BGChart.zoom(scaleX: 18, scaleY: 1, x: 1, y: 1)
+            var scaleX = CGFloat(UserDefaultsRepository.chartScaleX.value)
+            print("Scale: \(scaleX)")
+            if( scaleX > 18 ) {
+                scaleX = 18
+                UserDefaultsRepository.chartScaleX.value = 18
+            }
+            BGChart.zoom(scaleX: scaleX, scaleY: 1, x: 1, y: 1)
             firstGraphLoad = false
         }
         if BGChart.chartXMax > dateTimeUtils.getNowTimeIntervalUTC() {

+ 6 - 1
LoopFollow/Controllers/NightScout.swift

@@ -339,6 +339,7 @@ extension MainViewController {
         
         // Loop
         if let lastLoopRecord = lastDeviceStatus?["loop"] as! [String : AnyObject]? {
+            print("Loop: \(lastLoopRecord)")
             if let lastLoopTime = formatter.date(from: (lastLoopRecord["timestamp"] as! String))?.timeIntervalSince1970  {
                 UserDefaultsRepository.alertLastLoopTime.value = lastLoopTime
                 if UserDefaultsRepository.debugLog.value { self.writeDebugLog(value: "lastLoopTime: " + String(lastLoopTime)) }
@@ -352,7 +353,7 @@ extension MainViewController {
                         if UserDefaultsRepository.debugLog.value { self.writeDebugLog(value: "Loop: Was Enacted") }
                         wasEnacted = true
                         if let lastTempBasal = enacted["rate"] as? Double {
-                            // tableData[2].value = String(format:"%.1f", lastTempBasal)
+                            //tableData[2].value = String(format:"%.1f", lastTempBasal)
                         }
                     }
                     if let iobdata = lastLoopRecord["iob"] as? [String:AnyObject] {
@@ -383,6 +384,9 @@ extension MainViewController {
                             updatePredictionGraph()
                         }
                     }
+                    if let recBolus = lastLoopRecord["recommendedBolus"] as? Double {
+                        tableData[8].value = String(format:"%.2fU", recBolus)
+                    }
                     if let loopStatus = lastLoopRecord["recommendedTempBasal"] as? [String:AnyObject] {
                         if let tempBasalTime = formatter.date(from: (loopStatus["timestamp"] as! String))?.timeIntervalSince1970 {
                             var lastBGTime = lastLoopTime
@@ -953,6 +957,7 @@ extension MainViewController {
         if UserDefaultsRepository.graphBasal.value {
             updateBasalGraph()
         }
+        infoTable.reloadData()
     }
     
     // NS Bolus Web Call

+ 29 - 0
LoopFollow/Extensions/UIViewExtension.swift

@@ -0,0 +1,29 @@
+//
+//  UIViewExtension.swift
+//  LoopFollow
+//
+//  Created by Jose Paredes on 7/16/20.
+//  Copyright © 2020 Jon Fawcett. All rights reserved.
+//
+
+import Foundation
+import UIKit
+
+extension UIView {
+    enum ViewSide {
+        case Left, Right, Top, Bottom
+    }
+    
+    func addBorder(toSide side: ViewSide, withColor color: CGColor, andThickness thickness: CGFloat) {
+       let border = CALayer()
+       border.backgroundColor = color
+       
+       switch side {
+          case .Left: border.frame = CGRect(x:0, y: 0, width: thickness, height: frame.height); break
+          case .Right: border.frame = CGRect(x: frame.width-thickness, y: 0, width: thickness, height: frame.height); break
+          case .Top: border.frame = CGRect(x: 0, y: 0, width: frame.width, height: thickness); break
+          case .Bottom: border.frame = CGRect(x: 0, y: frame.height-thickness, width: frame.width, height: thickness); break
+       }
+       layer.addSublayer(border)
+    }
+}

+ 118 - 0
LoopFollow/ViewControllers/InfoDisplaySettingsViewController.swift

@@ -0,0 +1,118 @@
+//
+//  InfoDisplaySettingsViewController.swift
+//  LoopFollow
+//
+//  Created by Jose Paredes on 7/16/20.
+//  Copyright © 2020 Jon Fawcett. All rights reserved.
+//
+
+import UIKit
+import Eureka
+import EventKit
+import EventKitUI
+
+class InfoDisplaySettingsViewController: FormViewController {
+
+    var infoNames:   [String] = []
+    var infoSort:    [Int]    = []
+    var infoVisible: [Bool]   = []
+    
+    override func viewDidLoad() {
+        print("Display Load")
+        super.viewDidLoad()
+        if UserDefaultsRepository.forceDarkMode.value {
+            overrideUserInterfaceStyle = .dark
+        }
+         
+        // get the info table
+        let userDefaults = UserDefaults.standard
+
+        // names
+        self.infoNames = userDefaults.stringArray(forKey:InfoNames) ?? [String]()
+        if(self.infoNames.count == 0) {
+            self.infoNames = DefaultInfoNames
+            userDefaults.set(self.infoNames, forKey:InfoNames)
+        }
+        
+        // sort
+        self.infoSort = userDefaults.array(forKey:InfoSort) as? [Int] ?? [Int]()
+        if(self.infoSort.count != self.infoNames.count) {
+            self.infoSort = []
+            for i in 0..<self.infoNames.count {
+                self.infoSort.append(i)
+            }
+            userDefaults.set(self.infoSort, forKey:InfoSort)
+        }
+        // visible
+        self.infoVisible = userDefaults.array(forKey:InfoVisible) as? [Bool] ?? [Bool]()
+        if(self.infoVisible.count != self.infoNames.count) {
+            self.infoVisible = []
+            for _ in 0..<self.infoNames.count {
+                self.infoVisible.append(true)
+            }
+            userDefaults.set(self.infoVisible, forKey:InfoVisible)
+        }
+        createForm()
+    }
+    
+    func createForm() {
+        form
+        +++ MultivaluedSection(multivaluedOptions: .Reorder, header: "Display Configuration", footer: "Arrage/Enable Information Desired") {
+        
+           // TODO: add the other display values
+           $0.tag = "InfoDisplay"
+           
+            for i in 0..<self.infoNames.count {
+              $0 <<< TextRow() { row in
+                if(self.infoVisible[self.infoSort[i]]) {
+                    row.title = "\u{2713}\t\(self.infoNames[self.infoSort[i]])"
+                 } else {
+                    row.title = "\u{2001}\t\(self.infoNames[self.infoSort[i]])"
+                 }
+              }.onCellSelection{(cell, row) in
+                let i = row.indexPath!.row
+                self.infoVisible[self.infoSort[i]] = !self.infoVisible[self.infoSort[i]]
+                
+                // save info visible
+                UserDefaults.standard.set(self.infoVisible, forKey:InfoVisible)
+                
+                self.tableView.reloadData()
+                
+                //print("\(row.title)")
+                //print("\(row.indexPath?.row)")
+              }.cellSetup { (cell, row) in
+                 cell.textField.isUserInteractionEnabled = false
+              }.cellUpdate{ (cell, row) in
+                 if(self.infoVisible[self.infoSort[i]]) {
+                    row.title = "\u{2713}\t\(self.infoNames[self.infoSort[i]])"
+                 } else {
+                    row.title = "\u{2001}\t\(self.infoNames[self.infoSort[i]])"
+                 }
+              }
+           }
+       }
+    
+       +++ ButtonRow() {
+          $0.title = "DONE"
+       }.onCellSelection { (row, arg)  in
+          self.dismiss(animated:true, completion: nil)
+       }
+    }
+    
+    override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
+        //let view = tableView
+        let sourceIndex = sourceIndexPath.row
+        let destIndex = destinationIndexPath.row
+        
+        // new sort
+        let tmpVal = self.infoSort[sourceIndex]
+        self.infoSort.remove(at:sourceIndex)
+        self.infoSort.insert(tmpVal, at:destIndex)
+       
+        // save to defaults
+        UserDefaults.standard.set(self.infoSort, forKey:InfoSort)
+        
+        print("Source Row: \(sourceIndexPath.row); Source Section: \(sourceIndexPath.section)")
+        print("Destination Row: \(destinationIndexPath.row); Destination Section: \(destinationIndexPath.section)")
+    }
+ }

+ 91 - 23
LoopFollow/ViewControllers/MainViewController.swift

@@ -11,6 +11,20 @@ import Charts
 import EventKit
 import ShareClient
 
+let DefaultInfoNames = [
+   "IOB",
+   "COB",
+   "Basal",
+   "Override",
+   "Battery",
+   "Pump",
+   "SAGE",
+   "CAGE",
+   "Rec. Bolus"
+]
+let InfoNames = "infoNames"
+let InfoSort = "infoSort"
+let InfoVisible = "infoVisible"
 
 class MainViewController: UIViewController, UITableViewDataSource, ChartViewDelegate, UNUserNotificationCenterDelegate {
     
@@ -32,12 +46,15 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
     @IBOutlet weak var statsAvgBG: UILabel!
     @IBOutlet weak var statsEstA1C: UILabel!
     @IBOutlet weak var statsStdDev: UILabel!
-    
-    
-    // Data Table Struct
-    struct infoData {
-        var name: String
-        var value: String
+        
+    // Data Table class
+    class infoData {
+        public var name: String
+        public var value: String
+        init(name: String, value: String) {
+            self.name = name
+            self.value = value
+        }
     }
 
     // Variables for BG Charts
@@ -77,17 +94,11 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
     var calTimer = Timer()
     
     // Info Table Setup
-    // TODO: make this selectable
-    var tableData = [
-        infoData(name: "IOB", value: ""), //0
-        infoData(name: "COB", value: ""), //1
-        infoData(name: "Basal", value: ""), //2
-        infoData(name: "Override", value: ""), //3
-        infoData(name: "Battery", value: ""), //4
-        infoData(name: "Pump", value: ""), //5
-        infoData(name: "SAGE", value: ""), //6
-        infoData(name: "CAGE", value: "") //7
-    ]
+    var infoNames : [String] = []
+    var infoSort : [Int] = []
+    var infoVisible: [Bool] = []
+    var tableData : [infoData] = []
+    var derivedTableData: [infoData] = []
     
     var bgData: [DataStructs.sgvData] = []
     var basalProfile: [basalProfileStruct] = []
@@ -122,7 +133,34 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
     
     override func viewDidLoad() {
         super.viewDidLoad()
+
         
+        // table view
+        //infoTable.layer.borderColor = UIColor.darkGray.cgColor
+        //infoTable.layer.borderWidth = 1.0
+        //infoTable.layer.cornerRadius = 6
+        infoTable.rowHeight = 24
+        infoTable.dataSource = self
+        infoTable.tableFooterView = UIView(frame: .zero) // get rid of extra rows
+        infoTable.bounces = false
+        infoTable.addBorder(toSide: .Left, withColor: UIColor.darkGray.cgColor, andThickness: 2)
+      
+        // get the info table
+        let userDefaults = UserDefaults.standard
+
+        // names
+        self.infoNames = userDefaults.stringArray(forKey:InfoNames) ?? [String]()
+        if(self.infoNames.count == 0) {
+            self.infoNames = DefaultInfoNames
+            userDefaults.set(self.infoNames, forKey:InfoNames)
+        }
+        
+        // initialize the tableData
+        self.tableData = []
+        for i in 0..<self.infoNames.count {
+            self.tableData.append(infoData(name:self.infoNames[i], value:""))
+        }
+      
         // TODO: look for username and password in the UserDefaultsRepo ?
         // TODO: need non-us server ?
         let shareUserName = UserDefaultsRepository.shareUserName.value
@@ -162,10 +200,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
         let notificationCenter = NotificationCenter.default
             notificationCenter.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
             notificationCenter.addObserver(self, selector: #selector(appCameToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
-        
-        //Bind info data
-        infoTable.rowHeight = 25
-        infoTable.dataSource = self
+    
         
         // Setup the Graph
         if firstGraphLoad {
@@ -193,16 +228,47 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
         // set screen lock
         UIApplication.shared.isIdleTimerDisabled = UserDefaultsRepository.screenlockSwitchState.value;
         
+        // get the info table
+        let userDefaults = UserDefaults.standard
+
+        // sort
+        self.infoSort = userDefaults.array(forKey:InfoSort) as? [Int] ?? [Int]()
+        if(self.infoSort.count != self.infoNames.count) {
+            self.infoSort = []
+            for i in 0..<self.infoNames.count {
+                self.infoSort.append(i)
+            }
+            userDefaults.set(self.infoSort, forKey:InfoSort)
+        }
+        // visible
+        infoVisible = userDefaults.array(forKey:InfoVisible) as? [Bool] ?? [Bool]()
+        if(self.infoVisible.count != self.infoNames.count) {
+            self.infoVisible = []
+            for _ in 0..<self.infoNames.count {
+                self.infoVisible.append(true)
+            }
+            userDefaults.set(self.infoVisible, forKey:InfoVisible)
+        }
+        
+        self.derivedTableData = []
+        for i in 0..<self.tableData.count {
+            if(self.infoVisible[self.infoSort[i]]) {
+                self.derivedTableData.append(self.tableData[self.infoSort[i]])
+            }
+        }
+        infoTable.reloadData()
     }
     
     // Info Table Functions
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return tableData.count
+        //return tableData.count
+        return derivedTableData.count
+        
     }
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier: "LabelCell", for: indexPath)
-        let values = tableData[indexPath.row]
+        let values = derivedTableData[indexPath.row]
         cell.textLabel?.text = values.name
         cell.detailTextLabel?.text = values.value
         return cell
@@ -341,9 +407,11 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
     
     //Clear the info data before next pull. This ensures we aren't displaying old data if something fails.
     func clearLastInfoData(){
+        // var tmpData = tableData[2]
         for i in 0..<tableData.count{
             tableData[i].value = ""
         }
+        // tableData[2] = tmpData
     }
 
     func stringFromTimeInterval(interval: TimeInterval) -> String {

+ 12 - 7
LoopFollow/ViewControllers/SettingsViewController.swift

@@ -17,16 +17,13 @@ class SettingsViewController: FormViewController {
         var title: String
         var identifier: String
     }
-
     
     override func viewDidLoad() {
         super.viewDidLoad()
         if UserDefaultsRepository.forceDarkMode.value {
             overrideUserInterfaceStyle = .dark
         }
-        
-        
-        
+                        
         form
         +++ Section(header: "Nightscout Settings", footer: "Changing Nightscout settings requires an app restart.")
         <<< TextRow(){ row in
@@ -102,6 +99,17 @@ class SettingsViewController: FormViewController {
             UserDefaultsRepository.shareServer.value = value
         }
         
+        +++ Section("Information Display Settings")
+        <<< ButtonRow() {
+           $0.title = "Configure Information Display"
+           $0.presentationMode = .show(
+               controllerProvider: .callback(builder: {
+                  let controller = InfoDisplaySettingsViewController()
+                  return controller
+               }
+           ), onDismiss: nil)
+            
+        }
         
         buildGeneralSettings()
        // buildAlarmSettings()
@@ -109,9 +117,6 @@ class SettingsViewController: FormViewController {
         buildWatchSettings()
         buildDebugSettings()
         
-        
-        
-        
     }
     
     func buildGeneralSettings() {

+ 4 - 2
LoopFollow/repository/UserDefaults.swift

@@ -10,7 +10,9 @@ import Foundation
 import UIKit
 
 class UserDefaultsRepository {
-    
+
+    // DisplayValues total
+    static let infoDataTotal = UserDefaultsValue<Int>(key: "infoDataTotal", default: 0)
     
     //Nightscout Settings
     static let url = UserDefaultsValue<String>(key: "url", default: "")
@@ -23,6 +25,7 @@ class UserDefaultsRepository {
     static let shareServer = UserDefaultsValue<String>(key: "shareServer", default: "US")
     
     // Graph Settings
+    static let chartScaleX = UserDefaultsValue<Float>(key: "chartScaleX", default: 18.0)
     static let showDots = UserDefaultsValue<Bool>(key: "showDots", default: true)
     static let showLines = UserDefaultsValue<Bool>(key: "showLines", default: true)
     static let offsetCarbsBolus = UserDefaultsValue<Bool>(key: "offsetCarbsBolus", default: true)
@@ -89,7 +92,6 @@ class UserDefaultsRepository {
     static let alertCageInsertTime = UserDefaultsValue<TimeInterval>(key: "alertCageInsertTime", default: 0)
     static let alertSageInsertTime = UserDefaultsValue<TimeInterval>(key: "alertSageInsertTime", default: 0)
     
-    
     static let alertSnoozeAllTime = UserDefaultsValue<Date?>(key: "alertSnoozeAllTime", default: nil)
     static let alertSnoozeAllIsSnoozed = UserDefaultsValue<Bool>(key: "alertSnoozeAllIsSnoozed", default: false)