Просмотр исходного кода

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

Deniz Cengiz 1 год назад
Родитель
Сommit
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)