Преглед изворни кода

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

Deniz Cengiz пре 1 година
родитељ
комит
8f1b33cd1d
1 измењених фајлова са 5 додато и 2 уклоњено
  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)