From 089a81800f797dd9562482420cef227529d1d020 Mon Sep 17 00:00:00 2001 From: AQ Date: Tue, 31 Mar 2020 10:31:40 -0700 Subject: [PATCH 1/2] Add alert for unconfigured pump --- .../View Controllers/SettingsTableViewController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Loop/View Controllers/SettingsTableViewController.swift b/Loop/View Controllers/SettingsTableViewController.swift index e806e7776b..de32dafa7f 100644 --- a/Loop/View Controllers/SettingsTableViewController.swift +++ b/Loop/View Controllers/SettingsTableViewController.swift @@ -522,6 +522,16 @@ final class SettingsTableViewController: UITableViewController { guard let pumpManager = dataManager.pumpManager else { // Not allowing basal schedule entry without a configured pump. tableView.deselectRow(at: indexPath, animated: true) + let alert = UIAlertController( + title: NSLocalizedString("Unconfigured Pump", comment: "Alert title for unconfigured pump"), + message: NSLocalizedString("Please configure a pump to view or edit scheduled basal rates.", comment: "Alert message for attempting to change basal rates before pump was configured."), + preferredStyle: .alert + ) + + let acknowledgeChange = UIAlertAction(title: NSLocalizedString("OK", comment: "Button text to dismiss unconfigured pump alert."), style: .default) { _ in } + alert.addAction(acknowledgeChange) + + present(alert, animated: true) return } let vc = BasalScheduleTableViewController(allowedBasalRates: pumpManager.supportedBasalRates, maximumScheduleItemCount: pumpManager.maximumBasalScheduleEntryCount, minimumTimeInterval: pumpManager.minimumBasalScheduleEntryDuration) From 364b9e4c31dd24d455f218b62ccccedc06c7bedb Mon Sep 17 00:00:00 2001 From: AQ Date: Tue, 31 Mar 2020 10:48:09 -0700 Subject: [PATCH 2/2] Fix ordering --- Loop/View Controllers/SettingsTableViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Loop/View Controllers/SettingsTableViewController.swift b/Loop/View Controllers/SettingsTableViewController.swift index de32dafa7f..d7b6c4bd4e 100644 --- a/Loop/View Controllers/SettingsTableViewController.swift +++ b/Loop/View Controllers/SettingsTableViewController.swift @@ -521,7 +521,6 @@ final class SettingsTableViewController: UITableViewController { case .basalRate: guard let pumpManager = dataManager.pumpManager else { // Not allowing basal schedule entry without a configured pump. - tableView.deselectRow(at: indexPath, animated: true) let alert = UIAlertController( title: NSLocalizedString("Unconfigured Pump", comment: "Alert title for unconfigured pump"), message: NSLocalizedString("Please configure a pump to view or edit scheduled basal rates.", comment: "Alert message for attempting to change basal rates before pump was configured."), @@ -532,6 +531,7 @@ final class SettingsTableViewController: UITableViewController { alert.addAction(acknowledgeChange) present(alert, animated: true) + tableView.deselectRow(at: indexPath, animated: true) return } let vc = BasalScheduleTableViewController(allowedBasalRates: pumpManager.supportedBasalRates, maximumScheduleItemCount: pumpManager.maximumBasalScheduleEntryCount, minimumTimeInterval: pumpManager.minimumBasalScheduleEntryDuration)