|
@@ -24,6 +24,7 @@ extension Treatments {
|
|
|
@State private var calculatorDetent = PresentationDetent.large
|
|
@State private var calculatorDetent = PresentationDetent.large
|
|
|
@State private var pushed: Bool = false
|
|
@State private var pushed: Bool = false
|
|
|
@State private var debounce: DispatchWorkItem?
|
|
@State private var debounce: DispatchWorkItem?
|
|
|
|
|
+ @State private var showFatProteinOrderBanner = false
|
|
|
|
|
|
|
|
private enum Config {
|
|
private enum Config {
|
|
|
static let dividerHeight: CGFloat = 2
|
|
static let dividerHeight: CGFloat = 2
|
|
@@ -85,35 +86,35 @@ extension Treatments {
|
|
|
@ViewBuilder private func proteinAndFat() -> some View {
|
|
@ViewBuilder private func proteinAndFat() -> some View {
|
|
|
HStack {
|
|
HStack {
|
|
|
HStack {
|
|
HStack {
|
|
|
- Text("Protein")
|
|
|
|
|
|
|
+ Text("Fat")
|
|
|
TextFieldWithToolBar(
|
|
TextFieldWithToolBar(
|
|
|
- text: $state.protein,
|
|
|
|
|
|
|
+ text: $state.fat,
|
|
|
placeholder: "0",
|
|
placeholder: "0",
|
|
|
keyboardType: .numberPad,
|
|
keyboardType: .numberPad,
|
|
|
numberFormatter: mealFormatter,
|
|
numberFormatter: mealFormatter,
|
|
|
showArrows: true,
|
|
showArrows: true,
|
|
|
- previousTextField: { focusedField = previousField(from: .protein) },
|
|
|
|
|
- nextTextField: { focusedField = nextField(from: .protein) },
|
|
|
|
|
|
|
+ previousTextField: { focusedField = previousField(from: .fat) },
|
|
|
|
|
+ nextTextField: { focusedField = nextField(from: .fat) },
|
|
|
unitsText: String(localized: "g", comment: "Units for carbs")
|
|
unitsText: String(localized: "g", comment: "Units for carbs")
|
|
|
)
|
|
)
|
|
|
- .focused($focusedField, equals: .protein)
|
|
|
|
|
|
|
+ .focused($focusedField, equals: .fat)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Divider().foregroundStyle(.primary).fontWeight(.bold).frame(width: 10)
|
|
Divider().foregroundStyle(.primary).fontWeight(.bold).frame(width: 10)
|
|
|
|
|
|
|
|
HStack {
|
|
HStack {
|
|
|
- Text("Fat")
|
|
|
|
|
|
|
+ Text("Protein")
|
|
|
TextFieldWithToolBar(
|
|
TextFieldWithToolBar(
|
|
|
- text: $state.fat,
|
|
|
|
|
|
|
+ text: $state.protein,
|
|
|
placeholder: "0",
|
|
placeholder: "0",
|
|
|
keyboardType: .numberPad,
|
|
keyboardType: .numberPad,
|
|
|
numberFormatter: mealFormatter,
|
|
numberFormatter: mealFormatter,
|
|
|
showArrows: true,
|
|
showArrows: true,
|
|
|
- previousTextField: { focusedField = previousField(from: .fat) },
|
|
|
|
|
- nextTextField: { focusedField = nextField(from: .fat) },
|
|
|
|
|
|
|
+ previousTextField: { focusedField = previousField(from: .protein) },
|
|
|
|
|
+ nextTextField: { focusedField = nextField(from: .protein) },
|
|
|
unitsText: String(localized: "g", comment: "Units for carbs")
|
|
unitsText: String(localized: "g", comment: "Units for carbs")
|
|
|
)
|
|
)
|
|
|
- .focused($focusedField, equals: .fat)
|
|
|
|
|
|
|
+ .focused($focusedField, equals: .protein)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -198,6 +199,23 @@ extension Treatments {
|
|
|
|
|
|
|
|
if state.useFPUconversion {
|
|
if state.useFPUconversion {
|
|
|
proteinAndFat()
|
|
proteinAndFat()
|
|
|
|
|
+
|
|
|
|
|
+ if showFatProteinOrderBanner {
|
|
|
|
|
+ HStack {
|
|
|
|
|
+ Image(systemName: "arrow.left.arrow.right")
|
|
|
|
|
+ Text("The order of Fat and Protein inputs has changed.").font(.callout)
|
|
|
|
|
+ Spacer()
|
|
|
|
|
+ Button {
|
|
|
|
|
+ PropertyPersistentFlags.shared.hasSeenFatProteinOrderChange = true
|
|
|
|
|
+ withAnimation { showFatProteinOrderBanner = false }
|
|
|
|
|
+ } label: {
|
|
|
|
|
+ Image(systemName: "xmark.circle.fill")
|
|
|
|
|
+ }
|
|
|
|
|
+ .buttonStyle(.plain)
|
|
|
|
|
+ }
|
|
|
|
|
+ .listRowBackground(Color.orange.opacity(0.75))
|
|
|
|
|
+ .transition(.opacity)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Time
|
|
// Time
|
|
@@ -391,6 +409,10 @@ extension Treatments {
|
|
|
Task { @MainActor in
|
|
Task { @MainActor in
|
|
|
state.insulinCalculated = await state.calculateInsulin()
|
|
state.insulinCalculated = await state.calculateInsulin()
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if PropertyPersistentFlags.shared.hasSeenFatProteinOrderChange != true {
|
|
|
|
|
+ showFatProteinOrderBanner = true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
.onDisappear {
|
|
.onDisappear {
|