From 97ea503bf93023712e333aaed8f7df986243397c Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 20 May 2024 15:01:27 +0200 Subject: [PATCH] Prevent double tapping of the add carbs button (save/continue). (#637) fix by Jon --- .../Sources/Modules/AddCarbs/View/AddCarbsRootView.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift b/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift index 61744d40c5..b0bc81415a 100644 --- a/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift +++ b/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift @@ -12,6 +12,7 @@ extension AddCarbs { @State var isPromptPresented = false @State var saved = false @State var pushed = false + @State var button = false @State private var showAlert = false @FocusState private var isFocused: Bool @@ -130,8 +131,11 @@ extension AddCarbs { } Section { - Button { state.add(override, fetch: editMode) } - label: { Text((state.skipBolus && !override && !editMode) ? "Save" : "Continue") } + Button { + button.toggle() + if button { state.add(override, fetch: editMode) } + } + label: { Text(((state.skipBolus && !override && !editMode) || state.carbs <= 0) ? "Save" : "Continue") } .disabled(empty) .frame(maxWidth: .infinity, alignment: .center) }.listRowBackground(!empty ? Color(.systemBlue) : Color(.systemGray4))