| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import SwiftUI
- import Swinject
- extension ManualTempBasal {
- struct RootView: BaseView {
- let resolver: Resolver
- @StateObject var state = StateModel()
- private var formatter: NumberFormatter {
- let formatter = NumberFormatter()
- formatter.numberStyle = .decimal
- formatter.maximumFractionDigits = 2
- return formatter
- }
- var body: some View {
- Form {
- Section {
- HStack {
- Text("Amount")
- Spacer()
- TextFieldWithToolBar(
- text: $state.rate,
- placeholder: "0",
- shouldBecomeFirstResponder: true,
- numberFormatter: formatter
- )
- Text("U/hr").foregroundColor(.secondary)
- }
- Picker(selection: $state.durationIndex, label: Text("Duration")) {
- ForEach(0 ..< state.durationValues.count) { index in
- Text(
- String(
- format: "%.0f h %02.0f min",
- state.durationValues[index] / 60 - 0.1,
- state.durationValues[index].truncatingRemainder(dividingBy: 60)
- )
- ).tag(index)
- }
- }
- }
- Section {
- Button { state.enact() }
- label: { Text("Enact") }
- Button { state.cancel() }
- label: { Text("Cancel Temp Basal") }
- }
- }
- .onAppear(perform: configureView)
- .navigationTitle("Manual Temp Basal")
- .navigationBarTitleDisplayMode(.automatic)
- .navigationBarItems(leading: Button("Close", action: state.hideModal))
- }
- }
- }
|