|
|
@@ -102,72 +102,6 @@ struct EditTempTargetForm: View {
|
|
|
}.listRowBackground(Color.chart)
|
|
|
|
|
|
Section {
|
|
|
- DatePicker("Date", selection: $date)
|
|
|
- .onChange(of: date) { hasChanges = true }
|
|
|
- }.listRowBackground(Color.chart)
|
|
|
-
|
|
|
- Section {
|
|
|
- VStack {
|
|
|
- HStack {
|
|
|
- Text("Duration")
|
|
|
- Spacer()
|
|
|
- Text(formatHrMin(Int(duration)))
|
|
|
- .foregroundColor(!displayPickerDuration ? .primary : .accentColor)
|
|
|
- }
|
|
|
- .onTapGesture {
|
|
|
- displayPickerDuration = toggleScrollWheel(displayPickerDuration)
|
|
|
- }
|
|
|
- .onChange(of: duration) { hasChanges = true }
|
|
|
-
|
|
|
- if displayPickerDuration {
|
|
|
- HStack {
|
|
|
- Picker(
|
|
|
- selection: Binding(
|
|
|
- get: {
|
|
|
- Int(truncating: duration as NSNumber) / 60
|
|
|
- },
|
|
|
- set: {
|
|
|
- let minutes = Int(truncating: duration as NSNumber) % 60
|
|
|
- let totalMinutes = $0 * 60 + minutes
|
|
|
- duration = Decimal(totalMinutes)
|
|
|
- hasChanges = true
|
|
|
- }
|
|
|
- ),
|
|
|
- label: Text("")
|
|
|
- ) {
|
|
|
- ForEach(0 ..< 24) { hour in
|
|
|
- Text("\(hour) hr").tag(hour)
|
|
|
- }
|
|
|
- }
|
|
|
- .pickerStyle(WheelPickerStyle())
|
|
|
- .frame(maxWidth: .infinity)
|
|
|
-
|
|
|
- Picker(
|
|
|
- selection: Binding(
|
|
|
- get: {
|
|
|
- Int(truncating: duration as NSNumber) %
|
|
|
- 60 // Convert Decimal to Int for modulus operation
|
|
|
- },
|
|
|
- set: {
|
|
|
- duration = Decimal((Int(truncating: duration as NSNumber) / 60) * 60 + $0)
|
|
|
- hasChanges = true
|
|
|
- }
|
|
|
- ),
|
|
|
- label: Text("")
|
|
|
- ) {
|
|
|
- ForEach(Array(stride(from: 0, through: 55, by: 5)), id: \.self) { minute in
|
|
|
- Text("\(minute) min").tag(minute)
|
|
|
- }
|
|
|
- }
|
|
|
- .pickerStyle(WheelPickerStyle())
|
|
|
- .frame(maxWidth: .infinity)
|
|
|
- }
|
|
|
- .listRowSeparator(.hidden, edges: .top)
|
|
|
- }
|
|
|
- }
|
|
|
- }.listRowBackground(Color.chart)
|
|
|
-
|
|
|
- Section {
|
|
|
// Picker on the right side
|
|
|
let settingsProvider = PickerSettingsProvider.shared
|
|
|
let glucoseSetting = PickerSetting(value: 0, step: targetStep, min: 80, max: 270, type: .glucose)
|
|
|
@@ -267,6 +201,72 @@ struct EditTempTargetForm: View {
|
|
|
.listRowBackground(Color.chart)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ Section {
|
|
|
+ DatePicker("Date", selection: $date)
|
|
|
+ .onChange(of: date) { hasChanges = true }
|
|
|
+ }.listRowBackground(Color.chart)
|
|
|
+
|
|
|
+ Section {
|
|
|
+ VStack {
|
|
|
+ HStack {
|
|
|
+ Text("Duration")
|
|
|
+ Spacer()
|
|
|
+ Text(formatHrMin(Int(duration)))
|
|
|
+ .foregroundColor(!displayPickerDuration ? .primary : .accentColor)
|
|
|
+ }
|
|
|
+ .onTapGesture {
|
|
|
+ displayPickerDuration = toggleScrollWheel(displayPickerDuration)
|
|
|
+ }
|
|
|
+ .onChange(of: duration) { hasChanges = true }
|
|
|
+
|
|
|
+ if displayPickerDuration {
|
|
|
+ HStack {
|
|
|
+ Picker(
|
|
|
+ selection: Binding(
|
|
|
+ get: {
|
|
|
+ Int(truncating: duration as NSNumber) / 60
|
|
|
+ },
|
|
|
+ set: {
|
|
|
+ let minutes = Int(truncating: duration as NSNumber) % 60
|
|
|
+ let totalMinutes = $0 * 60 + minutes
|
|
|
+ duration = Decimal(totalMinutes)
|
|
|
+ hasChanges = true
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ label: Text("")
|
|
|
+ ) {
|
|
|
+ ForEach(0 ..< 24) { hour in
|
|
|
+ Text("\(hour) hr").tag(hour)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .pickerStyle(WheelPickerStyle())
|
|
|
+ .frame(maxWidth: .infinity)
|
|
|
+
|
|
|
+ Picker(
|
|
|
+ selection: Binding(
|
|
|
+ get: {
|
|
|
+ Int(truncating: duration as NSNumber) %
|
|
|
+ 60 // Convert Decimal to Int for modulus operation
|
|
|
+ },
|
|
|
+ set: {
|
|
|
+ duration = Decimal((Int(truncating: duration as NSNumber) / 60) * 60 + $0)
|
|
|
+ hasChanges = true
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ label: Text("")
|
|
|
+ ) {
|
|
|
+ ForEach(Array(stride(from: 0, through: 55, by: 5)), id: \.self) { minute in
|
|
|
+ Text("\(minute) min").tag(minute)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .pickerStyle(WheelPickerStyle())
|
|
|
+ .frame(maxWidth: .infinity)
|
|
|
+ }
|
|
|
+ .listRowSeparator(.hidden, edges: .top)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }.listRowBackground(Color.chart)
|
|
|
}
|
|
|
}
|
|
|
|