-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LOOP-1486: add suspend threshold information screen + editor #14
Changes from all commits
28c0916
2c67693
6515313
5c3ccc4
8d823e4
e37d939
d512942
9ba3927
fa1d0bf
0198d99
e7726cf
94c198f
82933e3
e719dff
5520b85
4bf68e4
a27fd30
41b36a1
5508179
fe28d53
8349362
f0adf19
24e0c21
a8052f0
8bfaceb
89ab963
eff80e9
107f81e
3d2c379
1f0413a
cb9b2d6
e85a9a4
01a76f9
aa0405e
45e3393
4970ba8
fda9362
673efbf
6304a95
74b2c51
9bd8522
7d7a254
cc569af
7e69d3e
3306532
d7345f5
8c7eddc
ccbd735
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ enum PrescriptionReviewScreen { | |
case correctionRangeEditor | ||
case correctionRangeOverrideInfo | ||
case correctionRangeOverrideEditor | ||
case suspendThresholdInfo | ||
case suspendThresholdEditor | ||
|
||
func next() -> PrescriptionReviewScreen? { | ||
switch self { | ||
|
@@ -32,6 +34,10 @@ enum PrescriptionReviewScreen { | |
case .correctionRangeOverrideInfo: | ||
return .correctionRangeOverrideEditor | ||
case .correctionRangeOverrideEditor: | ||
return .suspendThresholdInfo | ||
case .suspendThresholdInfo: | ||
return .suspendThresholdEditor | ||
case .suspendThresholdEditor: | ||
return nil | ||
} | ||
} | ||
|
@@ -124,6 +130,25 @@ class PrescriptionReviewUICoordinator: UINavigationController, CompletionNotifyi | |
let hostedView = DismissibleHostingController(rootView: view) | ||
hostedView.navigationItem.largeTitleDisplayMode = .never // TODO: hack to fix jumping, will be removed once editors have titles | ||
return hostedView | ||
case .suspendThresholdInfo: | ||
let exiting: (() -> Void) = { [weak self] in | ||
self?.stepFinished() | ||
} | ||
let view = SuspendThresholdInformationView(onExit: exiting) | ||
let hostedView = DismissibleHostingController(rootView: view) | ||
hostedView.navigationItem.largeTitleDisplayMode = .always // TODO: hack to fix jumping, will be removed once editors have titles | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious if this blocks the scrolls of the title up into the navigation bar? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
hostedView.title = LocalizedString("Suspend Threshold", comment: "Title for suspend threshold informational screen") | ||
return hostedView | ||
case .suspendThresholdEditor: | ||
guard let prescription = viewModel.prescription else { | ||
// Go back to code entry step if we don't have prescription | ||
let view = PrescriptionCodeEntryView(viewModel: viewModel) | ||
return DismissibleHostingController(rootView: view) | ||
} | ||
Comment on lines
+143
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is curious to me. Is this a possible entry point of the workflow or can the user just jump to this point? Just trying to understand how the user can get here without the needed information, which then bumps them to the start of the workflow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user shouldn't be able to get here without a prescription; this is primarily to unwrap it (since it's an optional in the view model) and to catch anything weird that could have happened with the Tidepool backend. |
||
let view = SuspendThresholdReview(model: viewModel, prescription: prescription) | ||
let hostedView = DismissibleHostingController(rootView: view) | ||
hostedView.navigationItem.largeTitleDisplayMode = .never // TODO: hack to fix jumping, will be removed once editors have titles | ||
return hostedView | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// SuspendThresholdReview.swift | ||
// TidepoolServiceKitUI | ||
// | ||
// Created by Anna Quinlan on 7/3/20. | ||
// Copyright © 2020 LoopKit Authors. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import LoopKitUI | ||
import LoopKit | ||
import HealthKit | ||
import TidepoolServiceKit | ||
|
||
|
||
struct SuspendThresholdReview: View { | ||
@ObservedObject var viewModel: PrescriptionReviewViewModel | ||
let prescription: MockPrescription | ||
|
||
init( | ||
model: PrescriptionReviewViewModel, | ||
prescription: MockPrescription | ||
) { | ||
self.viewModel = model | ||
self.prescription = prescription | ||
} | ||
|
||
var body: some View { | ||
SuspendThresholdEditor( | ||
value: prescription.therapySettings.suspendThreshold?.quantity, | ||
unit: prescription.bloodGlucoseUnit.hkUnit, | ||
maxValue: prescription.therapySettings.glucoseTargetRangeSchedule?.minLowerBound(), | ||
onSave: { newValue in | ||
let unit = self.prescription.bloodGlucoseUnit.hkUnit | ||
self.viewModel.saveSuspendThreshold(value: GlucoseThreshold(unit: unit, value: newValue.doubleValue(for: unit))) | ||
self.viewModel.didFinishStep() | ||
}, | ||
mode: .flow | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are to make
TherapySettings
be a subcomponent of a prescription