|
|
@@ -54,6 +54,28 @@ extension AddCarbs {
|
|
|
if state.useFPU {
|
|
|
proteinAndFat()
|
|
|
}
|
|
|
+ HStack {
|
|
|
+ Button {
|
|
|
+ isPromtPresented = true
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ )
|
|
|
+ )
|
|
|
+ .popover(isPresented: $isPromtPresented) {
|
|
|
+ presetPopover
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
Section {
|
|
|
@@ -208,28 +230,6 @@ extension AddCarbs {
|
|
|
)
|
|
|
Text("grams").foregroundColor(.secondary)
|
|
|
}
|
|
|
- HStack {
|
|
|
- Button {
|
|
|
- isPromtPresented = true
|
|
|
- }
|
|
|
- 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
|
|
|
- )
|
|
|
- )
|
|
|
- .popover(isPresented: $isPromtPresented) {
|
|
|
- presetPopover
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|