Skip to content

Commit 0a61a8a

Browse files
authored
Merge pull request #3 from tidepool-org/basal-picker
Use new basal picker interface
2 parents 8de3796 + 9591ddf commit 0a61a8a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Loop/View Controllers/SettingsTableViewController.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,18 +493,23 @@ final class SettingsTableViewController: UITableViewController {
493493

494494
show(vc, sender: sender)
495495
case .basalRate:
496-
let vc = SingleValueScheduleTableViewController(style: .grouped)
496+
guard let pumpManager = dataManager.pumpManager else {
497+
// Not allowing basal schedule entry without a configured pump.
498+
tableView.deselectRow(at: indexPath, animated: true)
499+
return
500+
}
501+
let vc = BasalScheduleTableViewController(allowedBasalRates: pumpManager.supportedBasalRates, maximumScheduleItemCount: pumpManager.maximumBasalScheduleEntryCount, minimumTimeInterval: pumpManager.minimumBasalScheduleEntryDuration)
497502

498503
if let profile = dataManager.loopManager.basalRateSchedule {
499504
vc.scheduleItems = profile.items
500505
vc.timeZone = profile.timeZone
501-
} else if let timeZone = dataManager.pumpManager?.status.timeZone {
502-
vc.timeZone = timeZone
506+
} else {
507+
vc.timeZone = pumpManager.status.timeZone
503508
}
504509

505510
vc.title = NSLocalizedString("Basal Rates", comment: "The title of the basal rate profile screen")
506511
vc.delegate = self
507-
vc.syncSource = dataManager.pumpManager
512+
vc.syncSource = pumpManager
508513

509514
show(vc, sender: sender)
510515
}
@@ -648,7 +653,7 @@ extension SettingsTableViewController: DailyValueScheduleTableViewControllerDele
648653
dataManager.loopManager.settings.glucoseTargetRangeSchedule = GlucoseRangeSchedule(unit: controller.unit, dailyItems: controller.scheduleItems, timeZone: controller.timeZone, overrideRanges: controller.overrideRanges, override: dataManager.loopManager.settings.glucoseTargetRangeSchedule?.override)
649654
}
650655
case .basalRate:
651-
if let controller = controller as? SingleValueScheduleTableViewController {
656+
if let controller = controller as? BasalScheduleTableViewController {
652657
dataManager.loopManager.basalRateSchedule = BasalRateSchedule(dailyItems: controller.scheduleItems, timeZone: controller.timeZone)
653658
}
654659
case let row:

0 commit comments

Comments
 (0)