|
@@ -36,7 +36,6 @@ extension AddCarbs {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
Section {
|
|
Section {
|
|
|
HStack {
|
|
HStack {
|
|
|
Text("Carbs").fontWeight(.semibold)
|
|
Text("Carbs").fontWeight(.semibold)
|
|
@@ -51,34 +50,49 @@ extension AddCarbs {
|
|
|
Text("grams").foregroundColor(.secondary)
|
|
Text("grams").foregroundColor(.secondary)
|
|
|
}.padding(.vertical)
|
|
}.padding(.vertical)
|
|
|
|
|
|
|
|
- if state.useFPU {
|
|
|
|
|
|
|
+ if state.useFPUconversion {
|
|
|
proteinAndFat()
|
|
proteinAndFat()
|
|
|
}
|
|
}
|
|
|
HStack {
|
|
HStack {
|
|
|
Button {
|
|
Button {
|
|
|
|
|
+ state.useFPUconversion.toggle()
|
|
|
|
|
+ }
|
|
|
|
|
+ label: { Text(state.useFPUconversion ? "Hide Fat & Protein" : "Fat and Protein") }
|
|
|
|
|
+ .controlSize(.mini)
|
|
|
|
|
+ .buttonStyle(BorderlessButtonStyle())
|
|
|
|
|
+ Button {
|
|
|
isPromtPresented = true
|
|
isPromtPresented = true
|
|
|
}
|
|
}
|
|
|
label: { Text("Save as Preset") }
|
|
label: { Text("Save as Preset") }
|
|
|
- }
|
|
|
|
|
- .frame(maxWidth: .infinity, alignment: .trailing)
|
|
|
|
|
- .controlSize(.mini)
|
|
|
|
|
- .buttonStyle(BorderlessButtonStyle())
|
|
|
|
|
-
|
|
|
|
|
- .disabled(
|
|
|
|
|
- (state.carbs <= 0 && state.fat <= 0 && state.protein <= 0) ||
|
|
|
|
|
- (
|
|
|
|
|
- (((state.selection?.carbs ?? 0) as NSDecimalNumber) as Decimal) == state
|
|
|
|
|
- .carbs && (((state.selection?.fat ?? 0) as NSDecimalNumber) as Decimal) == state
|
|
|
|
|
- .fat && (((state.selection?.protein ?? 0) as NSDecimalNumber) as Decimal) == state
|
|
|
|
|
- .protein
|
|
|
|
|
|
|
+ .frame(maxWidth: .infinity, alignment: .trailing)
|
|
|
|
|
+ .controlSize(.mini)
|
|
|
|
|
+ .buttonStyle(BorderlessButtonStyle())
|
|
|
|
|
+ .foregroundColor(
|
|
|
|
|
+ (state.carbs <= 0 && state.fat <= 0 && state.protein <= 0) ||
|
|
|
|
|
+ (
|
|
|
|
|
+ (((state.selection?.carbs ?? 0) as NSDecimalNumber) as Decimal) == state
|
|
|
|
|
+ .carbs && (((state.selection?.fat ?? 0) as NSDecimalNumber) as Decimal) == state
|
|
|
|
|
+ .fat && (((state.selection?.protein ?? 0) as NSDecimalNumber) as Decimal) ==
|
|
|
|
|
+ state
|
|
|
|
|
+ .protein
|
|
|
|
|
+ ) ? .secondary : .orange
|
|
|
)
|
|
)
|
|
|
- )
|
|
|
|
|
|
|
+ .disabled(
|
|
|
|
|
+ (state.carbs <= 0 && state.fat <= 0 && state.protein <= 0) ||
|
|
|
|
|
+ (
|
|
|
|
|
+ (((state.selection?.carbs ?? 0) as NSDecimalNumber) as Decimal) == state
|
|
|
|
|
+ .carbs && (((state.selection?.fat ?? 0) as NSDecimalNumber) as Decimal) == state
|
|
|
|
|
+ .fat && (((state.selection?.protein ?? 0) as NSDecimalNumber) as Decimal) == state
|
|
|
|
|
+ .protein
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
.popover(isPresented: $isPromtPresented) {
|
|
.popover(isPresented: $isPromtPresented) {
|
|
|
presetPopover
|
|
presetPopover
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if state.useFPU {
|
|
|
|
|
|
|
+ if state.useFPUconversion {
|
|
|
Section {
|
|
Section {
|
|
|
mealPresets
|
|
mealPresets
|
|
|
}
|
|
}
|
|
@@ -95,7 +109,7 @@ extension AddCarbs {
|
|
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if !state.useFPU {
|
|
|
|
|
|
|
+ if !state.useFPUconversion {
|
|
|
Section {
|
|
Section {
|
|
|
mealPresets
|
|
mealPresets
|
|
|
}
|
|
}
|
|
@@ -223,28 +237,28 @@ extension AddCarbs {
|
|
|
|
|
|
|
|
@ViewBuilder private func proteinAndFat() -> some View {
|
|
@ViewBuilder private func proteinAndFat() -> some View {
|
|
|
HStack {
|
|
HStack {
|
|
|
- Text("Protein").foregroundColor(.red) // .fontWeight(.thin)
|
|
|
|
|
|
|
+ Text("Fat").foregroundColor(.orange) // .fontWeight(.thin)
|
|
|
Spacer()
|
|
Spacer()
|
|
|
DecimalTextField(
|
|
DecimalTextField(
|
|
|
"0",
|
|
"0",
|
|
|
- value: $state.protein,
|
|
|
|
|
|
|
+ value: $state.fat,
|
|
|
formatter: formatter,
|
|
formatter: formatter,
|
|
|
autofocus: false,
|
|
autofocus: false,
|
|
|
cleanInput: true
|
|
cleanInput: true
|
|
|
- ).foregroundColor(.loopRed)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ )
|
|
|
Text("grams").foregroundColor(.secondary)
|
|
Text("grams").foregroundColor(.secondary)
|
|
|
}
|
|
}
|
|
|
HStack {
|
|
HStack {
|
|
|
- Text("Fat").foregroundColor(.orange) // .fontWeight(.thin)
|
|
|
|
|
|
|
+ Text("Protein").foregroundColor(.red) // .fontWeight(.thin)
|
|
|
Spacer()
|
|
Spacer()
|
|
|
DecimalTextField(
|
|
DecimalTextField(
|
|
|
"0",
|
|
"0",
|
|
|
- value: $state.fat,
|
|
|
|
|
|
|
+ value: $state.protein,
|
|
|
formatter: formatter,
|
|
formatter: formatter,
|
|
|
autofocus: false,
|
|
autofocus: false,
|
|
|
cleanInput: true
|
|
cleanInput: true
|
|
|
- )
|
|
|
|
|
|
|
+ ).foregroundColor(.loopRed)
|
|
|
|
|
+
|
|
|
Text("grams").foregroundColor(.secondary)
|
|
Text("grams").foregroundColor(.secondary)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|