Update gym_mode.dart

This commit is contained in:
Thilina Herath
2021-10-06 18:37:49 +08:00
parent 96ac3b2ec6
commit 27cbbed38f

View File

@@ -259,7 +259,7 @@ class _LogPageState extends State<LogPage> {
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<LogPage> {
},
),
ElevatedButton(
child: (_state == 0)
child: (!_isSaving)
? Text(AppLocalizations.of(context).save)
: Container(
height: 20,
@@ -469,7 +469,7 @@ class _LogPageState extends State<LogPage> {
valueColor: AlwaysStoppedAnimation<Color>(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<LogPage> {
if (!isValid) {
return;
}
_state = 1;
_isSaving = true;
_form.currentState!.save();
// Save the entry on the server
@@ -496,13 +496,13 @@ class _LogPageState extends State<LogPage> {
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;
}
},
),