|
|
@@ -125,6 +125,21 @@ extension AddCarbs {
|
|
|
}
|
|
|
)
|
|
|
Button {
|
|
|
+ if state.carbs != 0 { state.carbs -= ((state.selection?.carbs ?? 0) as NSDecimalNumber) as Decimal }
|
|
|
+ if state.fat != 0 { state.fat -= ((state.selection?.fat ?? 0) as NSDecimalNumber) as Decimal }
|
|
|
+ if state.protein != 0 { state.protein -= ((state.selection?.protein ?? 0) as NSDecimalNumber) as Decimal }
|
|
|
+ }
|
|
|
+ label: { Text("- 1") }
|
|
|
+ .disabled(state.selection == nil || (
|
|
|
+ (((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
|
|
|
+ ))
|
|
|
+ .buttonStyle(BorderlessButtonStyle())
|
|
|
+ .frame(maxWidth: .infinity, alignment: .trailing)
|
|
|
+ .accentColor(.red)
|
|
|
+ Button {
|
|
|
state.carbs += ((state.selection?.carbs ?? 0) as NSDecimalNumber) as Decimal
|
|
|
state.fat += ((state.selection?.fat ?? 0) as NSDecimalNumber) as Decimal
|
|
|
state.protein += ((state.selection?.protein ?? 0) as NSDecimalNumber) as Decimal }
|
|
|
@@ -132,6 +147,7 @@ extension AddCarbs {
|
|
|
.disabled(state.selection == nil)
|
|
|
.buttonStyle(BorderlessButtonStyle())
|
|
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
|
|
+ .accentColor(.green)
|
|
|
}
|
|
|
}
|
|
|
}
|