Selaa lähdekoodia

Adjust (-) and (+) button to add/subtact 5g carbs in CarbView

Deniz Cengiz 1 vuosi sitten
vanhempi
commit
8f1b33cd1d
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. 5 2
      Trio Watch App Extension/Views/CarbsInputView.swift

+ 5 - 2
Trio Watch App Extension/Views/CarbsInputView.swift

@@ -40,7 +40,10 @@ struct CarbsInputView: View {
             HStack {
                 // "-" Button
                 Button(action: {
-                    if carbsAmount > 0 { carbsAmount -= 1 }
+                    if carbsAmount > 0 {
+                        let currentAmount = carbsAmount
+                        carbsAmount < 5 ? carbsAmount = 0 : (carbsAmount -= 5)
+                    }
                 }) {
                     Image(systemName: "minus.circle.fill")
                         .font(.title3)
@@ -72,7 +75,7 @@ struct CarbsInputView: View {
 
                 // "+" Button
                 Button(action: {
-                    carbsAmount += 1
+                    carbsAmount += 5
                 }) {
                     Image(systemName: "plus.circle.fill")
                         .font(.title3)