From 27cbbed38fcff517e49863afafd11e21212a02eb Mon Sep 17 00:00:00 2001 From: Thilina Herath Date: Wed, 6 Oct 2021 18:37:49 +0800 Subject: [PATCH] Update gym_mode.dart --- lib/widgets/workouts/gym_mode.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/widgets/workouts/gym_mode.dart b/lib/widgets/workouts/gym_mode.dart index c217d5975..9ecc9aca1 100644 --- a/lib/widgets/workouts/gym_mode.dart +++ b/lib/widgets/workouts/gym_mode.dart @@ -259,7 +259,7 @@ class _LogPageState extends State { final _repsController = TextEditingController(); final _weightController = TextEditingController(); var _detailed = false; - int _state = 0; + bool _isSaving = false; late FocusNode focusNode; @@ -460,7 +460,7 @@ class _LogPageState extends State { }, ), ElevatedButton( - child: (_state == 0) + child: (!_isSaving) ? Text(AppLocalizations.of(context).save) : Container( height: 20, @@ -469,7 +469,7 @@ class _LogPageState extends State { valueColor: AlwaysStoppedAnimation(Colors.white), ), ), - onPressed: _state == 1 + onPressed: _isSaving ? null : () async { // Validate and save the current values to the weightEntry @@ -477,7 +477,7 @@ class _LogPageState extends State { if (!isValid) { return; } - _state = 1; + _isSaving = true; _form.currentState!.save(); // Save the entry on the server @@ -496,13 +496,13 @@ class _LogPageState extends State { duration: DEFAULT_ANIMATION_DURATION, curve: DEFAULT_ANIMATION_CURVE, ); - _state = 0; + _isSaving = false; } on WgerHttpException catch (error) { showHttpExceptionErrorDialog(error, context); - _state = 0; + _isSaving = false; } catch (error) { showErrorDialog(error, context); - _state = 0; + _isSaving = false; } }, ),