diff --git a/lib/widgets/weight/forms.dart b/lib/widgets/weight/forms.dart index 7a476208..ff2881c3 100644 --- a/lib/widgets/weight/forms.dart +++ b/lib/widgets/weight/forms.dart @@ -35,7 +35,8 @@ class WeightForm extends StatelessWidget { WeightForm([WeightEntry? weightEntry]) { this._weightEntry = weightEntry ?? WeightEntry(date: DateTime.now()); - weightController.text = _weightEntry.id == null ? '' : _weightEntry.weight.toString(); + weightController.text = + _weightEntry.id == null ? '' : _weightEntry.weight.toString(); dateController.text = toDate(_weightEntry.date)!; } @@ -47,12 +48,13 @@ class WeightForm extends StatelessWidget { children: [ // Weight date TextFormField( - decoration: InputDecoration(labelText: AppLocalizations.of(context).date), + decoration: + InputDecoration(labelText: AppLocalizations.of(context).date), controller: dateController, onTap: () async { // Stop keyboard from appearing FocusScope.of(context).requestFocus(new FocusNode()); - + print("date picker"); // Show Date Picker Here var pickedDate = await showDatePicker( context: context, @@ -66,7 +68,8 @@ class WeightForm extends StatelessWidget { } // if the date is known, don't allow it - return Provider.of(context, listen: false).findByDate(day) == + return Provider.of(context, listen: false) + .findByDate(day) == null ? true : false; @@ -82,7 +85,8 @@ class WeightForm extends StatelessWidget { // Weight TextFormField( - decoration: InputDecoration(labelText: AppLocalizations.of(context).weight), + decoration: + InputDecoration(labelText: AppLocalizations.of(context).weight), controller: weightController, keyboardType: TextInputType.number, onSaved: (newValue) { @@ -113,12 +117,25 @@ class WeightForm extends StatelessWidget { // Save the entry on the server try { _weightEntry.id == null - ? await Provider.of(context, listen: false) + ? await Provider.of(context, + listen: false) .addEntry(_weightEntry) - : await Provider.of(context, listen: false) + : await Provider.of(context, + listen: false) .editEntry(_weightEntry); } on WgerHttpException catch (error) { + await showDialog( + context: context, + builder: (context) => AlertDialog( + content: Text("please wait"), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text("Ok")) + ], + )); showHttpExceptionErrorDialog(error, context); + Navigator.pop(context); } catch (error) { showErrorDialog(error, context); }