From c9040e53003d934247a01dc672f25328e31c5036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sn=C3=A4llfot?= Date: Mon, 13 May 2024 08:23:11 +0200 Subject: [PATCH 01/17] replace , with . in notifications BG and delta --- LoopFollow/ViewControllers/SnoozeViewController.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/LoopFollow/ViewControllers/SnoozeViewController.swift b/LoopFollow/ViewControllers/SnoozeViewController.swift index a066a42f..02eede16 100644 --- a/LoopFollow/ViewControllers/SnoozeViewController.swift +++ b/LoopFollow/ViewControllers/SnoozeViewController.swift @@ -98,11 +98,15 @@ class SnoozeViewController: UIViewController, UNUserNotificationCenterDelegate { UNUserNotificationCenter.current().delegate = self + // Replace commas with periods in bgVal and deltaVal + let bgValUpdated = bgVal.replacingOccurrences(of: ",", with: ".") + let deltaValUpdated = deltaVal.replacingOccurrences(of: ",", with: ".") + let content = UNMutableNotificationContent() content.title = alertLabelVal - content.subtitle += bgVal + " " + content.subtitle += bgValUpdated + " " content.subtitle += directionVal + " " - content.subtitle += deltaVal + content.subtitle += deltaValUpdated content.categoryIdentifier = "category" // This is needed to trigger vibrate on watch and phone // TODO: From 11f05b412d038549a6c37a1056c6e3aaabd15b56 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Wed, 15 May 2024 19:24:35 +0200 Subject: [PATCH 02/17] add SOS-Warning-OK emojis to evBG on top of red-green-yellow text low-normal-high --- .../Application/Base.lproj/Main.storyboard | 18 ++++++------- .../Controllers/Nightscout/DeviceStatus.swift | 26 ++++++++----------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/LoopFollow/Application/Base.lproj/Main.storyboard b/LoopFollow/Application/Base.lproj/Main.storyboard index 9207e93e..7f533c35 100644 --- a/LoopFollow/Application/Base.lproj/Main.storyboard +++ b/LoopFollow/Application/Base.lproj/Main.storyboard @@ -80,13 +80,13 @@ @@ -1952,28 +1952,28 @@ - + - + - + - + - + - + - + diff --git a/LoopFollow/Controllers/Nightscout/DeviceStatus.swift b/LoopFollow/Controllers/Nightscout/DeviceStatus.swift index 554c52cd..41ad9b3d 100644 --- a/LoopFollow/Controllers/Nightscout/DeviceStatus.swift +++ b/LoopFollow/Controllers/Nightscout/DeviceStatus.swift @@ -483,35 +483,31 @@ extension MainViewController { } var predictionColor = UIColor.systemGray - PredictionLabel.textColor = predictionColor if let eventualData = lastLoopRecord["suggested"] as? [String: Any], - let eventualBGValue = eventualData["eventualBG"] as? NSNumber, - let loopYellow = UIColor(named: "LoopYellow"), - let loopRed = UIColor(named: "LoopRed"), - let loopGreen = UIColor(named: "LoopGreen") { - + let eventualBGValue = eventualData["eventualBG"] as? NSNumber, + let loopYellow = UIColor(named: "LoopYellow"), + let loopRed = UIColor(named: "LoopRed"), + let loopGreen = UIColor(named: "LoopGreen") { + let eventualBGFloatValue = eventualBGValue.floatValue // Convert NSNumber to Float let eventualBGStringValue = String(describing: eventualBGValue) let formattedBGString = bgUnits.toDisplayUnits(eventualBGStringValue).replacingOccurrences(of: ",", with: ".") - PredictionLabel.text = " Prognos ⇢ \(formattedBGString)" - - // Print statements for debugging - //print("eventualBGValue:", eventualBGFloatValue) - //print("High Line Value:", UserDefaultsRepository.highLine.value) - //print("Low Line Value:", UserDefaultsRepository.lowLine.value) if eventualBGFloatValue >= UserDefaultsRepository.highLine.value { + PredictionLabel.text = "⚠️ Prognos ⇢ \(formattedBGString)" + PredictionLabel.textColor = loopYellow predictionColor = loopYellow } else if eventualBGFloatValue <= UserDefaultsRepository.lowLine.value { + PredictionLabel.text = "🆘 Prognos ⇢ \(formattedBGString)" + PredictionLabel.textColor = loopRed predictionColor = loopRed } else if eventualBGFloatValue > UserDefaultsRepository.lowLine.value && eventualBGFloatValue < UserDefaultsRepository.highLine.value { + PredictionLabel.text = "✅ Prognos ⇢ \(formattedBGString)" + PredictionLabel.textColor = loopGreen predictionColor = loopGreen } - - // Debug print for the selected color - //print("Selected Prediction Color:", predictionColor) } // Update PredictionLabel with the new color From 53f75489a6920a77bf4b07f208e39dcd521c8100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sn=C3=A4llfot?= Date: Thu, 16 May 2024 13:28:28 +0200 Subject: [PATCH 03/17] Add scheduled basal as (x.xx) in Basal infotable --- LoopFollow/Controllers/Nightscout/Profile.swift | 3 +++ LoopFollow/Controllers/Nightscout/Treatments/Basals.swift | 6 +++--- LoopFollow/ViewControllers/MainViewController.swift | 1 + LoopFollow/repository/UserDefaults.swift | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/LoopFollow/Controllers/Nightscout/Profile.swift b/LoopFollow/Controllers/Nightscout/Profile.swift index b9e6c46c..c164692a 100644 --- a/LoopFollow/Controllers/Nightscout/Profile.swift +++ b/LoopFollow/Controllers/Nightscout/Profile.swift @@ -104,6 +104,9 @@ extension MainViewController { let startDot = basalGraphStruct(basalRate: basalSegments[i].basalRate, date: Double(timeStart + (60 * 5))) basalScheduleData.append(startDot) + basalNow = String(format:"%.2f", basalSegments[i].basalRate) + print("Basalnow \(basalNow)") + // set the enddot where the next one will start var endDate = basalSegments[i].endDate let endDot = basalGraphStruct(basalRate: basalSegments[i].basalRate, date: endDate) diff --git a/LoopFollow/Controllers/Nightscout/Treatments/Basals.swift b/LoopFollow/Controllers/Nightscout/Treatments/Basals.swift index 17432ae9..2b1d59b9 100644 --- a/LoopFollow/Controllers/Nightscout/Treatments/Basals.swift +++ b/LoopFollow/Controllers/Nightscout/Treatments/Basals.swift @@ -136,10 +136,10 @@ extension MainViewController { //if i == tempArray.count - 1 && dateTimeStamp + duration <= dateTimeUtils.getNowTimeIntervalUTC() { if i == tempArray.count - 1 && duration == 0.0 { lastEndDot = dateTimeStamp + (30 * 60) - latestBasal = String(format:"%.2f", basalRate) + " E/h" + latestBasal = String(format:"%.2f", basalRate) + " (" + basalNow + ") E/h" } else { lastEndDot = dateTimeStamp + (duration * 60) - latestBasal = String(format:"%.2f", basalRate) + " E/h" + latestBasal = String(format:"%.2f", basalRate) + " (" + basalNow + ") E/h" } // Double check for overlaps of incorrectly ended TBRs and sent it to end when the next one starts if it finds a discrepancy @@ -186,7 +186,7 @@ extension MainViewController { } } - latestBasal = String(format:"%.2f", scheduled) + " E/h" + latestBasal = String(format:"%.2f", scheduled) + " (" + basalNow + ") E/h" // Make the starting dot at the last ending dot let startDot = basalGraphStruct(basalRate: scheduled, date: Double(lastEndDot)) basalData.append(startDot) diff --git a/LoopFollow/ViewControllers/MainViewController.swift b/LoopFollow/ViewControllers/MainViewController.swift index 09678458..30debc09 100644 --- a/LoopFollow/ViewControllers/MainViewController.swift +++ b/LoopFollow/ViewControllers/MainViewController.swift @@ -141,6 +141,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele var latestLoopTime: Double = 0 var latestCOB = "" var latestBasal = "" + var basalNow = "" var latestPumpVolume: Double = 50.0 var latestIOB = "" var lastOverrideStartTime: TimeInterval = 0 diff --git a/LoopFollow/repository/UserDefaults.swift b/LoopFollow/repository/UserDefaults.swift index 215edb6e..ef5999bd 100644 --- a/LoopFollow/repository/UserDefaults.swift +++ b/LoopFollow/repository/UserDefaults.swift @@ -39,8 +39,8 @@ class UserDefaultsRepository { "Målvärde", //16 "Behov KH", //17 "Info uppdaterad"]) //18 - static let infoSort = UserDefaultsValue<[Int]>(key: "infoSort", default: [3,0,1,11,14,15,2,8,17,16,9,4,10,13,5,6,7,12,18]) - static let infoVisible = UserDefaultsValue<[Bool]>(key: "infoVisible", default: [true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false, true]) + static let infoSort = UserDefaultsValue<[Int]>(key: "infoSort", default: [3,11,14,15,2,0,1,8,17,4,9,16,13,10,5,7,6,18,12]) + static let infoVisible = UserDefaultsValue<[Bool]>(key: "infoVisible", default: [true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false]) static let hideInfoTable = UserDefaultsValue(key: "hideInfoTable", default: false) // Nightscout Settings From 6b3a7c1608ebacf99e990bc3ccfca5a6801a70c7 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Thu, 16 May 2024 15:04:31 +0200 Subject: [PATCH 04/17] Added "Show detailed info" toggle (right now just used for showing both temp and scheduled basal, but could be applied elsewhere) --- .../Nightscout/Treatments/Basals.swift | 18 +++++++++++++++--- .../AdvancedSettingsViewController.swift | 8 ++++++++ LoopFollow/repository/UserDefaults.swift | 1 + 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/LoopFollow/Controllers/Nightscout/Treatments/Basals.swift b/LoopFollow/Controllers/Nightscout/Treatments/Basals.swift index 2b1d59b9..e6b855d2 100644 --- a/LoopFollow/Controllers/Nightscout/Treatments/Basals.swift +++ b/LoopFollow/Controllers/Nightscout/Treatments/Basals.swift @@ -136,10 +136,18 @@ extension MainViewController { //if i == tempArray.count - 1 && dateTimeStamp + duration <= dateTimeUtils.getNowTimeIntervalUTC() { if i == tempArray.count - 1 && duration == 0.0 { lastEndDot = dateTimeStamp + (30 * 60) - latestBasal = String(format:"%.2f", basalRate) + " (" + basalNow + ") E/h" + if UserDefaultsRepository.showDetails.value { + latestBasal = String(format:"%.2f", basalRate) + " (" + basalNow + ") E/h" + } else { + latestBasal = String(format:"%.2f", basalRate) + " E/h" + } } else { lastEndDot = dateTimeStamp + (duration * 60) - latestBasal = String(format:"%.2f", basalRate) + " (" + basalNow + ") E/h" + if UserDefaultsRepository.showDetails.value { + latestBasal = String(format:"%.2f", basalRate) + " (" + basalNow + ") E/h" + } else { + latestBasal = String(format:"%.2f", basalRate) + " E/h" + } } // Double check for overlaps of incorrectly ended TBRs and sent it to end when the next one starts if it finds a discrepancy @@ -186,7 +194,11 @@ extension MainViewController { } } - latestBasal = String(format:"%.2f", scheduled) + " (" + basalNow + ") E/h" + if UserDefaultsRepository.showDetails.value { + latestBasal = String(format:"%.2f", scheduled) + " (" + basalNow + ") E/h" + } else { + latestBasal = String(format:"%.2f", scheduled) + " E/h" + } // Make the starting dot at the last ending dot let startDot = basalGraphStruct(basalRate: scheduled, date: Double(lastEndDot)) basalData.append(startDot) diff --git a/LoopFollow/ViewControllers/AdvancedSettingsViewController.swift b/LoopFollow/ViewControllers/AdvancedSettingsViewController.swift index 71f88708..f646159c 100644 --- a/LoopFollow/ViewControllers/AdvancedSettingsViewController.swift +++ b/LoopFollow/ViewControllers/AdvancedSettingsViewController.swift @@ -75,6 +75,14 @@ class AdvancedSettingsViewController: FormViewController { guard let value = row.value else { return } UserDefaultsRepository.graphOtherTreatments.value = value } + + <<< SwitchRow("showDetails"){ row in + row.title = "Show Detailed Info" + row.value = UserDefaultsRepository.showDetails.value + }.onChange { [weak self] row in + guard let value = row.value else { return } + UserDefaultsRepository.showDetails.value = value + } <<< StepperRow("bgUpdateDelay") { row in row.title = "BG Update Delay (Sec)" row.cell.stepper.stepValue = 1 diff --git a/LoopFollow/repository/UserDefaults.swift b/LoopFollow/repository/UserDefaults.swift index ef5999bd..97e7c4a0 100644 --- a/LoopFollow/repository/UserDefaults.swift +++ b/LoopFollow/repository/UserDefaults.swift @@ -118,6 +118,7 @@ class UserDefaultsRepository { static let alwaysDownloadAllBG = UserDefaultsValue(key: "alwaysDownloadAllBG", default: true) static let bgUpdateDelay = UserDefaultsValue(key: "bgUpdateDelay", default: 10) static let downloadDays = UserDefaultsValue(key: "downloadDays", default: 1) + static let showDetails = UserDefaultsValue(key: "showDetails", default: true) // Watch Calendar Settings From bc20656963aebb43135fb4cace4ca80e2b4251dd Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Thu, 16 May 2024 20:36:25 +0200 Subject: [PATCH 05/17] test openaps-enacte-received false for indicating yellow loop also change loop follow default loop symbols to loop rings in different colors --- .../Application/Base.lproj/Main.storyboard | 28 +++++++++---------- .../Controllers/Nightscout/DeviceStatus.swift | 26 ++++++++++++----- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/LoopFollow/Application/Base.lproj/Main.storyboard b/LoopFollow/Application/Base.lproj/Main.storyboard index 7f533c35..f6bfe1da 100644 --- a/LoopFollow/Application/Base.lproj/Main.storyboard +++ b/LoopFollow/Application/Base.lproj/Main.storyboard @@ -36,27 +36,27 @@ - + - + - + - + - + - + @@ -1952,28 +1952,28 @@ - + - + - + - + - + - + - + From d07f040b0b82111a2760fa2a23523f1282253185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sn=C3=A4llfot?= Date: Fri, 17 May 2024 09:27:30 +0200 Subject: [PATCH 08/17] =?UTF-8?q?Fix=20"/"=20entry=20in=20https://=20URL?= =?UTF-8?q?=20Bj=C3=B6rkerts=20commit=20c9d285e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LoopFollow/ViewControllers/SettingsViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LoopFollow/ViewControllers/SettingsViewController.swift b/LoopFollow/ViewControllers/SettingsViewController.swift index d9b7792f..17e35129 100644 --- a/LoopFollow/ViewControllers/SettingsViewController.swift +++ b/LoopFollow/ViewControllers/SettingsViewController.swift @@ -159,7 +159,7 @@ class SettingsViewController: FormViewController { // Further clean-up: Remove trailing slashes var cleanURL = filtered - while cleanURL.last == "/" { + while cleanURL.count > 8 && cleanURL.last == "/" { cleanURL = String(cleanURL.dropLast()) } From 951f7d3b4e6b4e3e779da8ac2c81b4e61e5d4e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sn=C3=A4llfot?= Date: Fri, 17 May 2024 10:18:27 +0200 Subject: [PATCH 09/17] =?UTF-8?q?Remove=20Download=20Loop/iAPS=20Data=20to?= =?UTF-8?q?ggle=20Bj=C3=B6rkerts=20commit=205c57460?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LoopFollow/Controllers/Timers.swift | 6 +++--- LoopFollow/ViewControllers/AlarmViewController.swift | 2 +- .../ViewControllers/GraphSettingsViewController.swift | 2 +- LoopFollow/ViewControllers/MainViewController.swift | 2 +- .../ViewControllers/SettingsViewController.swift | 11 +---------- .../ViewControllers/WatchSettingsViewController.swift | 2 +- LoopFollow/repository/UserDefaults.swift | 1 - 7 files changed, 8 insertions(+), 18 deletions(-) diff --git a/LoopFollow/Controllers/Timers.swift b/LoopFollow/Controllers/Timers.swift index deb4b6bc..a73de571 100644 --- a/LoopFollow/Controllers/Timers.swift +++ b/LoopFollow/Controllers/Timers.swift @@ -188,7 +188,7 @@ extension MainViewController { @objc func deviceStatusTimerDidEnd(_ timer:Timer) { // reset timer to 1 minute if settings aren't entered - if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value { + if UserDefaultsRepository.url.value == "" { startDeviceStatusTimer(time: 60) return } @@ -213,7 +213,7 @@ extension MainViewController { // reset timer to 1 minute if settings aren't entered - if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value { + if UserDefaultsRepository.url.value == "" { startTreatmentsTimer(time: 60) return } @@ -238,7 +238,7 @@ extension MainViewController { @objc func profileTimerDidEnd(_ timer:Timer) { // reset timer to 1 minute if settings aren't entered - if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value { + if UserDefaultsRepository.url.value == "" { startProfileTimer(time: 60) return } diff --git a/LoopFollow/ViewControllers/AlarmViewController.swift b/LoopFollow/ViewControllers/AlarmViewController.swift index cdb26c72..e2cdad8e 100644 --- a/LoopFollow/ViewControllers/AlarmViewController.swift +++ b/LoopFollow/ViewControllers/AlarmViewController.swift @@ -436,7 +436,7 @@ class AlarmViewController: FormViewController { func showHideNSDetails() { var isHidden = false var isEnabled = true - if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value { + if UserDefaultsRepository.url.value == "" { isHidden = true isEnabled = false } diff --git a/LoopFollow/ViewControllers/GraphSettingsViewController.swift b/LoopFollow/ViewControllers/GraphSettingsViewController.swift index ddd331ef..43c86ce4 100644 --- a/LoopFollow/ViewControllers/GraphSettingsViewController.swift +++ b/LoopFollow/ViewControllers/GraphSettingsViewController.swift @@ -29,7 +29,7 @@ class GraphSettingsViewController: FormViewController { func showHideNSDetails() { var isHidden = false var isEnabled = true - if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value { + if UserDefaultsRepository.url.value == "" { isHidden = true isEnabled = false } diff --git a/LoopFollow/ViewControllers/MainViewController.swift b/LoopFollow/ViewControllers/MainViewController.swift index 30debc09..c80dcc92 100644 --- a/LoopFollow/ViewControllers/MainViewController.swift +++ b/LoopFollow/ViewControllers/MainViewController.swift @@ -485,7 +485,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele func showHideNSDetails() { var isHidden = false var isEnabled = true - if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value { + if UserDefaultsRepository.url.value == "" { isHidden = true isEnabled = false } diff --git a/LoopFollow/ViewControllers/SettingsViewController.swift b/LoopFollow/ViewControllers/SettingsViewController.swift index 17e35129..8063e6f8 100644 --- a/LoopFollow/ViewControllers/SettingsViewController.swift +++ b/LoopFollow/ViewControllers/SettingsViewController.swift @@ -20,7 +20,7 @@ class SettingsViewController: FormViewController { var isHidden = false var isEnabled = true var isLoopHidden = false; - if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value { + if UserDefaultsRepository.url.value == "" { isHidden = true isEnabled = false } @@ -202,15 +202,6 @@ class SettingsViewController: FormViewController { statusLabelRow = row row.hidden = "$showNS == false" } - <<< SwitchRow("loopUser"){ row in - row.title = "Download Loop/iAPS Data" - row.tag = "loopUser" - row.value = UserDefaultsRepository.loopUser.value - row.hidden = "$showNS == false" - }.onChange { row in - guard let value = row.value else { return } - UserDefaultsRepository.loopUser.value = value - } <<< SwitchRow("showDex"){ row in row.title = "Show Dexcom Settings" diff --git a/LoopFollow/ViewControllers/WatchSettingsViewController.swift b/LoopFollow/ViewControllers/WatchSettingsViewController.swift index 70d58a23..bce0c7ba 100644 --- a/LoopFollow/ViewControllers/WatchSettingsViewController.swift +++ b/LoopFollow/ViewControllers/WatchSettingsViewController.swift @@ -36,7 +36,7 @@ class WatchSettingsViewController: FormViewController { func showHideNSDetails() { var isHidden = false var isEnabled = true - if UserDefaultsRepository.url.value == "" || !UserDefaultsRepository.loopUser.value { + if UserDefaultsRepository.url.value == "" { isHidden = true isEnabled = false } diff --git a/LoopFollow/repository/UserDefaults.swift b/LoopFollow/repository/UserDefaults.swift index 97e7c4a0..446e9231 100644 --- a/LoopFollow/repository/UserDefaults.swift +++ b/LoopFollow/repository/UserDefaults.swift @@ -48,7 +48,6 @@ class UserDefaultsRepository { static let url = UserDefaultsValue(key: "url", default: "") static let token = UserDefaultsValue(key: "token", default: "") static let units = UserDefaultsValue(key: "units", default: "mg/dL") - static let loopUser = UserDefaultsValue(key: "loopUser", default: false) // Dexcom Share Settings static let showDex = UserDefaultsValue(key: "showDex", default: false) From ee9ead8b3984908f0d40707e5643787e27018885 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Sun, 26 May 2024 09:14:57 +0200 Subject: [PATCH 10/17] adjust m sedan --- LoopFollow/Application/Base.lproj/Main.storyboard | 6 +++--- LoopFollow/Controllers/Timers.swift | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/LoopFollow/Application/Base.lproj/Main.storyboard b/LoopFollow/Application/Base.lproj/Main.storyboard index fe1e25be..92632ac0 100644 --- a/LoopFollow/Application/Base.lproj/Main.storyboard +++ b/LoopFollow/Application/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -63,7 +63,7 @@ - + diff --git a/LoopFollow/Controllers/Timers.swift b/LoopFollow/Controllers/Timers.swift index a73de571..f97b6fb0 100644 --- a/LoopFollow/Controllers/Timers.swift +++ b/LoopFollow/Controllers/Timers.swift @@ -56,20 +56,20 @@ extension MainViewController { let formatter = DateComponentsFormatter() formatter.unitsStyle = .positional // Use the appropriate positioning for the current locale - if secondsAgo >= 720 { // 720 seconds = 12 minutes + //if secondsAgo >= 720 { // 720 seconds = 12 minutes formatter.allowedUnits = [.minute] // Only show minutes after 12 minutes have passed /*} else if secondsAgo < 0 { // Less than 4.5 minutes //Daniel: ALways show minutes and seconds formatter.allowedUnits = [.minute] // Show only minutes if less than 4.5 minutes*/ - } else { + //} else { formatter.allowedUnits = [.minute, .second] // Show minutes and seconds otherwise - } + //} let formattedDuration = formatter.string(from: secondsAgo) ?? "" let minAgoDisplayText: String if secondsAgo > 60 { - minAgoDisplayText = formattedDuration + " sedan" + minAgoDisplayText = formattedDuration + " m sedan" } else { minAgoDisplayText = formattedDuration + " s sedan" } From 7d931126cdc203b8b2a21ff471cacfbe3d6e83e7 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Tue, 28 May 2024 13:51:00 +0200 Subject: [PATCH 11/17] COuntdown instead of count up for SAGE and CAGE in infotable --- LoopFollow/Controllers/Nightscout/CAge.swift | 63 ++++++++------ LoopFollow/Controllers/Nightscout/SAge.swift | 82 +++++++++++-------- .../ViewControllers/MainViewController.swift | 4 +- 3 files changed, 91 insertions(+), 58 deletions(-) diff --git a/LoopFollow/Controllers/Nightscout/CAge.swift b/LoopFollow/Controllers/Nightscout/CAge.swift index f7952df6..b7e13d90 100644 --- a/LoopFollow/Controllers/Nightscout/CAge.swift +++ b/LoopFollow/Controllers/Nightscout/CAge.swift @@ -1,12 +1,5 @@ -// -// CAge.swift -// LoopFollow -// -// Created by Jonas Björkert on 2023-10-05. -// Copyright © 2023 Jon Fawcett. All rights reserved. -// - import Foundation + extension MainViewController { // NS Cage Web Call func webLoadNSCage() { @@ -44,28 +37,50 @@ extension MainViewController { .withTime, .withDashSeparatorInDate, .withColonSeparatorInTime] - UserDefaultsRepository.alertCageInsertTime.value = formatter.date(from: (lastCageString))?.timeIntervalSince1970 as! TimeInterval - if let cageTime = formatter.date(from: (lastCageString))?.timeIntervalSince1970 { + if let cageTime = formatter.date(from: lastCageString)?.timeIntervalSince1970 { + UserDefaultsRepository.alertCageInsertTime.value = cageTime + let now = dateTimeUtils.getNowTimeIntervalUTC() let secondsAgo = now - cageTime - //let days = 24 * 60 * 60 - let formatter = DateComponentsFormatter() - formatter.unitsStyle = .positional // Use the appropriate positioning for the current locale - formatter.allowedUnits = [ .day, .hour ] // Units to display in the formatted string - formatter.zeroFormattingBehavior = [ .pad ] // Pad with zeroes where appropriate for the locale - - // Set maximumUnitCount to 0 to include all available units - formatter.maximumUnitCount = 0 + let oldFormatter = DateComponentsFormatter() + oldFormatter.unitsStyle = .positional + oldFormatter.allowedUnits = [.day, .hour] + oldFormatter.zeroFormattingBehavior = [.pad] + oldFormatter.maximumUnitCount = 0 - if let formattedDuration = formatter.string(from: secondsAgo) { - // Manually add spaces between the number and units - let spacedDuration = formattedDuration - .replacingOccurrences(of: "d", with: " d") - .replacingOccurrences(of: "h", with: " h") + if let formattedDuration = oldFormatter.string(from: secondsAgo) { + let spacedDuration = formattedDuration + .replacingOccurrences(of: "d", with: " d") + .replacingOccurrences(of: "h", with: " h") - tableData[7].value = spacedDuration + //tableData[7].value = spacedDuration + } + + // Add 3 days to cageTime + let threeDaysLater = cageTime + 3 * 24 * 60 * 60 + + // Calculate the remaining time + let timeRemaining = threeDaysLater - now + + // Extract the components + let daysRemaining = Int(timeRemaining / (24 * 60 * 60)) + let hoursRemaining = Int((timeRemaining.truncatingRemainder(dividingBy: 24 * 60 * 60)) / (60 * 60)) + let minutesRemaining = Int((timeRemaining.truncatingRemainder(dividingBy: 60 * 60)) / 60) + + // Construct the string manually + var spacedRemainingDuration = "" + if daysRemaining > 0 { + spacedRemainingDuration += "\(daysRemaining)d " + } + if hoursRemaining > 0 || daysRemaining > 0 { + spacedRemainingDuration += "\(hoursRemaining)h " + } + if daysRemaining == 0 { + spacedRemainingDuration += "\(minutesRemaining)m" } + // Update tableData[70].value with the remaining duration + tableData[7].value = spacedRemainingDuration } infoTable.reloadData() } diff --git a/LoopFollow/Controllers/Nightscout/SAge.swift b/LoopFollow/Controllers/Nightscout/SAge.swift index 7f058e14..418d5a37 100644 --- a/LoopFollow/Controllers/Nightscout/SAge.swift +++ b/LoopFollow/Controllers/Nightscout/SAge.swift @@ -1,12 +1,5 @@ -// -// SAGE.swift -// LoopFollow -// -// Created by Jonas Björkert on 2023-10-05. -// Copyright © 2023 Jon Fawcett. All rights reserved. -// - import Foundation + extension MainViewController { // NS Sage Web Call func webLoadNSSage() { @@ -40,45 +33,70 @@ extension MainViewController { return } currentSage = data[0] - var lastSageString = data[0].created_at + let lastSageString = data[0].created_at let formatter = ISO8601DateFormatter() formatter.formatOptions = [.withFullDate, .withTime, .withDashSeparatorInDate, .withColonSeparatorInTime] - UserDefaultsRepository.alertSageInsertTime.value = formatter.date(from: (lastSageString))?.timeIntervalSince1970 as! TimeInterval - - if UserDefaultsRepository.alertAutoSnoozeCGMStart.value && (dateTimeUtils.getNowTimeIntervalUTC() - UserDefaultsRepository.alertSageInsertTime.value < 7200){ - let snoozeTime = Date(timeIntervalSince1970: UserDefaultsRepository.alertSageInsertTime.value + 7200) - UserDefaultsRepository.alertSnoozeAllTime.value = snoozeTime - UserDefaultsRepository.alertSnoozeAllIsSnoozed.value = true - guard let alarms = self.tabBarController!.viewControllers?[1] as? AlarmViewController else { return } - alarms.reloadIsSnoozed(key: "alertSnoozeAllIsSnoozed", value: true) - alarms.reloadSnoozeTime(key: "alertSnoozeAllTime", setNil: false, value: snoozeTime) - } - - if let sageTime = formatter.date(from: (lastSageString as! String))?.timeIntervalSince1970 { + if let sageTime = formatter.date(from: lastSageString)?.timeIntervalSince1970 { + UserDefaultsRepository.alertSageInsertTime.value = sageTime + + if UserDefaultsRepository.alertAutoSnoozeCGMStart.value && (dateTimeUtils.getNowTimeIntervalUTC() - UserDefaultsRepository.alertSageInsertTime.value < 7200) { + let snoozeTime = Date(timeIntervalSince1970: UserDefaultsRepository.alertSageInsertTime.value + 7200) + UserDefaultsRepository.alertSnoozeAllTime.value = snoozeTime + UserDefaultsRepository.alertSnoozeAllIsSnoozed.value = true + guard let alarms = self.tabBarController!.viewControllers?[1] as? AlarmViewController else { return } + alarms.reloadIsSnoozed(key: "alertSnoozeAllIsSnoozed", value: true) + alarms.reloadSnoozeTime(key: "alertSnoozeAllTime", setNil: false, value: snoozeTime) + } + let now = dateTimeUtils.getNowTimeIntervalUTC() let secondsAgo = now - sageTime let days = 24 * 60 * 60 - let formatter = DateComponentsFormatter() - formatter.unitsStyle = .positional // Use the appropriate positioning for the current locale - formatter.allowedUnits = [ .day, .hour] // Units to display in the formatted string - formatter.zeroFormattingBehavior = [ .pad ] // Pad with zeroes where appropriate for the locale + let oldFormatter = DateComponentsFormatter() + oldFormatter.unitsStyle = .positional // Use the appropriate positioning for the current locale + oldFormatter.allowedUnits = [ .day, .hour] // Units to display in the formatted string + oldFormatter.zeroFormattingBehavior = [ .pad ] // Pad with zeroes where appropriate for the locale // Set maximumUnitCount to 0 to include all available units - formatter.maximumUnitCount = 0 + oldFormatter.maximumUnitCount = 0 - if let formattedDuration = formatter.string(from: secondsAgo) { - // Manually add spaces between the number and units - let spacedDuration = formattedDuration - .replacingOccurrences(of: "d", with: " d") - .replacingOccurrences(of: "h", with: " h") + if let formattedDuration = oldFormatter.string(from: secondsAgo) { + // Manually add spaces between the number and units + let spacedDuration = formattedDuration + .replacingOccurrences(of: "d", with: " d") + .replacingOccurrences(of: "h", with: " h") - tableData[6].value = spacedDuration + //tableData[6].value = spacedDuration + } + + // Add 10 days to sageTime + let tenDaysLater = sageTime + 10 * 24 * 60 * 60 + + // Calculate the remaining time + let timeRemaining = tenDaysLater - now + + // Extract the components + let daysRemaining = Int(timeRemaining / (24 * 60 * 60)) + let hoursRemaining = Int((timeRemaining.truncatingRemainder(dividingBy: 24 * 60 * 60)) / (60 * 60)) + let minutesRemaining = Int((timeRemaining.truncatingRemainder(dividingBy: 60 * 60)) / 60) + + // Construct the string manually + var spacedRemainingDuration = "" + if daysRemaining > 0 { + spacedRemainingDuration += "\(daysRemaining)d " + } + if hoursRemaining > 0 || daysRemaining > 0 { + spacedRemainingDuration += "\(hoursRemaining)h " + } + if daysRemaining == 0 { + spacedRemainingDuration += "\(minutesRemaining)m" } + // Update tableData[60].value with the remaining duration + tableData[6].value = spacedRemainingDuration } infoTable.reloadData() } diff --git a/LoopFollow/ViewControllers/MainViewController.swift b/LoopFollow/ViewControllers/MainViewController.swift index c80dcc92..4af1bf35 100644 --- a/LoopFollow/ViewControllers/MainViewController.swift +++ b/LoopFollow/ViewControllers/MainViewController.swift @@ -178,8 +178,8 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele UserDefaultsRepository.infoNames.value.append("Override") UserDefaultsRepository.infoNames.value.append("Looptelefon") UserDefaultsRepository.infoNames.value.append("Reservoar") - UserDefaultsRepository.infoNames.value.append("Sensorbyte") - UserDefaultsRepository.infoNames.value.append("Poddbyte") + UserDefaultsRepository.infoNames.value.append("Sensorbyte om") + UserDefaultsRepository.infoNames.value.append("Poddbyte om") UserDefaultsRepository.infoNames.value.append("Behov Insulin") UserDefaultsRepository.infoNames.value.append("Min-Max") UserDefaultsRepository.infoNames.value.append("Kh idag") From 0e6831538b836f31fd1d7913ed64f2714ce25e14 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Sun, 2 Jun 2024 12:10:05 +0200 Subject: [PATCH 12/17] =?UTF-8?q?Revert=20Sensor=20Change=20to=20Sensor=20?= =?UTF-8?q?Start=20Healthlog->H=C3=A4lsologgning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LoopFollow/Controllers/Graphs.swift | 8 ++++---- LoopFollow/Controllers/NightScout.swift | 4 ++-- LoopFollow/Controllers/Nightscout/Treatments.swift | 12 ++++++------ .../Nightscout/Treatments/SensorStart.swift | 8 ++++---- LoopFollow/ViewControllers/MainViewController.swift | 2 +- .../ViewControllers/RemoteViewController.swift | 2 +- LoopFollow/helpers/NightscoutUtils.swift | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/LoopFollow/Controllers/Graphs.swift b/LoopFollow/Controllers/Graphs.swift index cf1c6565..84760e02 100644 --- a/LoopFollow/Controllers/Graphs.swift +++ b/LoopFollow/Controllers/Graphs.swift @@ -349,7 +349,7 @@ extension MainViewController { lineResume.drawValuesEnabled = false - // Sensor Change + // Sensor Start var chartEntrySensor = [ChartDataEntry]() let lineSensor = LineChartDataSet(entries:chartEntrySensor, label: "") lineSensor.circleRadius = CGFloat(globalVariables.dotOther) @@ -1369,11 +1369,11 @@ extension MainViewController { } } - func updateSensorChange() { + func updateSensorStart() { var dataIndex = 10 BGChart.lineData?.dataSets[dataIndex].clear() BGChartFull.lineData?.dataSets[dataIndex].clear() - let thisData = sensorChangeGraphData + let thisData = sensorStartGraphData for i in 0.. 0 { - processSensorChange(entries: cgmSensorChange) + processSage(entries: cgmSensorStart) + if cgmSensorStart.count > 0 { + processSensorStart(entries: cgmSensorStart) } else { - if sensorChangeGraphData.count > 0 { + if sensorStartGraphData.count > 0 { clearOldSensor() } } diff --git a/LoopFollow/Controllers/Nightscout/Treatments/SensorStart.swift b/LoopFollow/Controllers/Nightscout/Treatments/SensorStart.swift index da402631..9ee927b9 100644 --- a/LoopFollow/Controllers/Nightscout/Treatments/SensorStart.swift +++ b/LoopFollow/Controllers/Nightscout/Treatments/SensorStart.swift @@ -19,8 +19,8 @@ extension MainViewController { } // NS Sensor Change Response Processor - func processSensorChange(entries: [sageData]) { - sensorChangeGraphData.removeAll() + func processSensorStart(entries: [sageData]) { + sensorStartGraphData.removeAll() var lastFoundIndex = 0 for entry in entries { let date = entry.created_at @@ -32,14 +32,14 @@ extension MainViewController { if dateTimeStamp < (dateTimeUtils.getNowTimeIntervalUTC() + (60 * 60)) { let dot = DataStructs.timestampOnlyStruct(date: Double(dateTimeStamp), sgv: Int(sgv.sgv)) - sensorChangeGraphData.append(dot) + sensorStartGraphData.append(dot) } } else { print("Failed to parse date") } } if UserDefaultsRepository.graphOtherTreatments.value { - updateSensorChange() + updateSensorStart() } } } diff --git a/LoopFollow/ViewControllers/MainViewController.swift b/LoopFollow/ViewControllers/MainViewController.swift index 4af1bf35..115fcb2a 100644 --- a/LoopFollow/ViewControllers/MainViewController.swift +++ b/LoopFollow/ViewControllers/MainViewController.swift @@ -128,7 +128,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele var bgCheckData: [ShareGlucoseData] = [] var suspendGraphData: [DataStructs.timestampOnlyStruct] = [] var resumeGraphData: [DataStructs.timestampOnlyStruct] = [] - var sensorChangeGraphData: [DataStructs.timestampOnlyStruct] = [] + var sensorStartGraphData: [DataStructs.timestampOnlyStruct] = [] var pumpChangeGraphData: [DataStructs.timestampOnlyStruct] = [] var noteGraphData: [DataStructs.noteStruct] = [] var chartData = LineChartData() diff --git a/LoopFollow/ViewControllers/RemoteViewController.swift b/LoopFollow/ViewControllers/RemoteViewController.swift index 258eb877..b205d913 100644 --- a/LoopFollow/ViewControllers/RemoteViewController.swift +++ b/LoopFollow/ViewControllers/RemoteViewController.swift @@ -64,7 +64,7 @@ class RemoteViewController: UIViewController { } @IBAction func calendarButtonTapped(_ sender: Any) { - let urlString = "shortcuts://run-shortcut?name=Healthlog" + let urlString = "shortcuts://run-shortcut?name=Hälsologgning" if let url = URL(string: urlString) { UIApplication.shared.open(url, options: [:], completionHandler: nil) } diff --git a/LoopFollow/helpers/NightscoutUtils.swift b/LoopFollow/helpers/NightscoutUtils.swift index 80645631..240515b1 100644 --- a/LoopFollow/helpers/NightscoutUtils.swift +++ b/LoopFollow/helpers/NightscoutUtils.swift @@ -22,7 +22,7 @@ class NightscoutUtils { enum EventType: String { case cage = "Site Change" case carbsToday = "Carb Correction" - case sage = "Sensor Change" + case sage = "Sensor Start" case sgv case profile case treatments From 074bf6bd53559af3e0b2a44064acfc1dd8fbaf67 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:02:14 +0200 Subject: [PATCH 13/17] small adjustments dot colors --- LoopFollow/Controllers/Graphs.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LoopFollow/Controllers/Graphs.swift b/LoopFollow/Controllers/Graphs.swift index 84760e02..988bb904 100644 --- a/LoopFollow/Controllers/Graphs.swift +++ b/LoopFollow/Controllers/Graphs.swift @@ -383,10 +383,10 @@ extension MainViewController { let chartEntryNote = [ChartDataEntry]() let lineNote = LineChartDataSet(entries:chartEntryNote, label: "") lineNote.circleRadius = CGFloat(globalVariables.dotOther) - lineNote.circleColors = [NSUIColor.white.withAlphaComponent(0.75)] + lineNote.circleColors = [NSUIColor.systemGray2.withAlphaComponent(0.75)] lineNote.drawCircleHoleEnabled = false lineNote.setDrawHighlightIndicators(false) - lineNote.setColor(NSUIColor.white, alpha: 1.0) + lineNote.setColor(NSUIColor.systemGray2, alpha: 1.0) lineNote.drawCirclesEnabled = true lineNote.lineWidth = 0 lineNote.highlightEnabled = true @@ -1719,10 +1719,10 @@ extension MainViewController { var chartEntryNote = [ChartDataEntry]() let lineNote = LineChartDataSet(entries:chartEntryNote, label: "") lineNote.circleRadius = 2 - lineNote.circleColors = [NSUIColor.systemGray.withAlphaComponent(0.75)] + lineNote.circleColors = [NSUIColor.systemGray2.withAlphaComponent(0.75)] lineNote.drawCircleHoleEnabled = false lineNote.setDrawHighlightIndicators(false) - lineNote.setColor(NSUIColor.systemGray3, alpha: 1.0) + lineNote.setColor(NSUIColor.systemGray2, alpha: 1.0) lineNote.drawCirclesEnabled = true lineNote.lineWidth = 0 lineNote.highlightEnabled = false From a17d3c59e1bac1327d220b24f124f7a0eec1c377 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:26:42 +0200 Subject: [PATCH 14/17] Improved UX: Next-button in keyboard and tapable labels meal view --- .../Application/Base.lproj/Main.storyboard | 19 ++-- .../ViewControllers/MealViewController.swift | 95 ++++++++++++++++++- 2 files changed, 104 insertions(+), 10 deletions(-) diff --git a/LoopFollow/Application/Base.lproj/Main.storyboard b/LoopFollow/Application/Base.lproj/Main.storyboard index 92632ac0..1e4a2337 100644 --- a/LoopFollow/Application/Base.lproj/Main.storyboard +++ b/LoopFollow/Application/Base.lproj/Main.storyboard @@ -1287,20 +1287,25 @@ + + + + + @@ -1952,28 +1957,28 @@ - + - + - + - + - + - + - + diff --git a/LoopFollow/ViewControllers/MealViewController.swift b/LoopFollow/ViewControllers/MealViewController.swift index 3734b1a8..6c6f7482 100644 --- a/LoopFollow/ViewControllers/MealViewController.swift +++ b/LoopFollow/ViewControllers/MealViewController.swift @@ -22,10 +22,15 @@ class MealViewController: UIViewController, UITextFieldDelegate, TwilioRequestab @IBOutlet weak var bolusCalcStack: UIStackView! @IBOutlet weak var bolusCalculated: UITextField! @IBOutlet weak var sendMealButton: UIButton! + @IBOutlet weak var carbLabel: UILabel! @IBOutlet weak var carbGrams: UITextField! + @IBOutlet weak var fatLabel: UILabel! @IBOutlet weak var fatGrams: UITextField! + @IBOutlet weak var proteinLabel: UILabel! @IBOutlet weak var proteinGrams: UITextField! + @IBOutlet weak var mealNotesLabel: UILabel! @IBOutlet weak var mealNotes: UITextField! + @IBOutlet weak var bolusLabel: UILabel! @IBOutlet weak var bolusUnits: UITextField! @IBOutlet weak var CRValue: UITextField! @IBOutlet weak var minPredBGValue: UITextField! @@ -53,8 +58,15 @@ class MealViewController: UIViewController, UITextFieldDelegate, TwilioRequestab carbsEntryField.delegate = self fatEntryField.delegate = self proteinEntryField.delegate = self + notesEntryField.delegate = self + bolusEntryField.delegate = self + + setupInputAccessoryView() self.focusCarbsEntryField() + // Add tap gesture recognizers to labels + addGestureRecognizers() + //Bolus calculation preperations //Carb ratio @@ -119,6 +131,83 @@ class MealViewController: UIViewController, UITextFieldDelegate, TwilioRequestab } } + func setupInputAccessoryView() { + let toolbar = UIToolbar() + toolbar.sizeToFit() + + let nextButton = UIBarButtonItem(title: "Nästa", style: .plain, target: self, action: #selector(nextTapped)) + //let doneButton = UIBarButtonItem(title: "Done", style: .plain, target: self, action: #selector(doneTapped)) + let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) + + //toolbar.setItems([flexSpace, nextButton, doneButton], animated: false) + toolbar.setItems([flexSpace, nextButton], animated: false) + + carbsEntryField.inputAccessoryView = toolbar + fatEntryField.inputAccessoryView = toolbar + proteinEntryField.inputAccessoryView = toolbar + notesEntryField.inputAccessoryView = toolbar + bolusEntryField.inputAccessoryView = toolbar + } + + @objc func nextTapped() { + if carbsEntryField.isFirstResponder { + fatEntryField.becomeFirstResponder() + } else if fatEntryField.isFirstResponder { + proteinEntryField.becomeFirstResponder() + } else if proteinEntryField.isFirstResponder { + notesEntryField.becomeFirstResponder() + } else if notesEntryField.isFirstResponder { + bolusEntryField.becomeFirstResponder() + } + } + + /*@objc func doneTapped() { + view.endEditing(true) + }*/ + + // Add tap gesture recognizers to labels + func addGestureRecognizers() { + let carbLabelTap = UITapGestureRecognizer(target: self, action: #selector(focusCarbsEntryField)) + carbLabel.addGestureRecognizer(carbLabelTap) + carbLabel.isUserInteractionEnabled = true + + let fatLabelTap = UITapGestureRecognizer(target: self, action: #selector(focusFatEntryField)) + fatLabel.addGestureRecognizer(fatLabelTap) + fatLabel.isUserInteractionEnabled = true + + let proteinLabelTap = UITapGestureRecognizer(target: self, action: #selector(focusProteinEntryField)) + proteinLabel.addGestureRecognizer(proteinLabelTap) + proteinLabel.isUserInteractionEnabled = true + + let mealNotesLabelTap = UITapGestureRecognizer(target: self, action: #selector(focusNotesEntryField)) + mealNotesLabel.addGestureRecognizer(mealNotesLabelTap) + mealNotesLabel.isUserInteractionEnabled = true + + let bolusLabelTap = UITapGestureRecognizer(target: self, action: #selector(focusBolusEntryField)) + bolusLabel.addGestureRecognizer(bolusLabelTap) + bolusLabel.isUserInteractionEnabled = true + } + + @objc func focusCarbsEntryField() { + self.carbsEntryField.becomeFirstResponder() + } + + @objc func focusFatEntryField() { + self.fatEntryField.becomeFirstResponder() + } + + @objc func focusProteinEntryField() { + self.proteinEntryField.becomeFirstResponder() + } + + @objc func focusNotesEntryField() { + self.notesEntryField.becomeFirstResponder() + } + + @objc func focusBolusEntryField() { + self.bolusEntryField.becomeFirstResponder() + } + // Function to calculate the suggested bolus value based on CR and check for maxCarbs func calculateBolus() { guard let carbsText = carbsEntryField.text, @@ -207,9 +296,9 @@ class MealViewController: UIViewController, UITextFieldDelegate, TwilioRequestab return formattedString } - func focusCarbsEntryField() { - self.carbsEntryField.becomeFirstResponder() - } + //func focusCarbsEntryField() { + // self.carbsEntryField.becomeFirstResponder() + //} func sendMealorMealandBolus() { let attributes: [NSAttributedString.Key: Any] = [ From 262d92649598a5f7b4d420987489801f09c22e58 Mon Sep 17 00:00:00 2001 From: dsnallfot <72826201+dsnallfot@users.noreply.github.com> Date: Sun, 2 Jun 2024 22:32:32 +0200 Subject: [PATCH 15/17] add iso8601 date string to remote meals --- .../Application/Base.lproj/Main.storyboard | 137 ++++++++++++------ .../ViewControllers/MealViewController.swift | 46 +++--- 2 files changed, 118 insertions(+), 65 deletions(-) diff --git a/LoopFollow/Application/Base.lproj/Main.storyboard b/LoopFollow/Application/Base.lproj/Main.storyboard index 1e4a2337..69bcd49c 100644 --- a/LoopFollow/Application/Base.lproj/Main.storyboard +++ b/LoopFollow/Application/Base.lproj/Main.storyboard @@ -822,16 +822,16 @@ - + - + - + - + - + @@ -851,7 +851,7 @@ @@ -880,19 +880,19 @@ - + - + - + - + - + - + @@ -913,7 +913,7 @@ - + - + - + - + - + @@ -974,7 +974,7 @@ - + - + - + - + @@ -1051,17 +1051,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + @@ -1073,7 +1113,7 @@ - + @@ -1086,10 +1126,10 @@ - + - + @@ -1100,7 +1140,7 @@ - + @@ -1111,7 +1151,7 @@ - + @@ -1124,10 +1164,10 @@ - + - + @@ -1136,7 +1176,7 @@ - + @@ -1147,7 +1187,7 @@ - + @@ -1156,7 +1196,7 @@ @@ -1176,16 +1216,16 @@ - + - + - + - + - + @@ -1209,7 +1249,7 @@