diff --git a/lib/android/components/form/form_builder.dart b/lib/android/components/form/form_builder.dart index 10e086e..d79d85f 100644 --- a/lib/android/components/form/form_builder.dart +++ b/lib/android/components/form/form_builder.dart @@ -118,19 +118,30 @@ class _FormBuilderComponentState extends State { ), onPressed: () { final Box box = Hive.box("USER_BOX"); + + print(formKey + .currentState?.fields['gewicht']?.value ?? + box.get("USER").gewicht); + box.put( "USER", User( - formKey.currentState?.fields['vorname']?.value, - formKey.currentState?.fields['nachname']?.value, + formKey.currentState?.fields['vorname']?.value.toString() ?? + box.get("USER").vorname.toString(), + formKey.currentState?.fields['nachname']?.value.toString() ?? + box.get("USER").nachname.toString(), int.parse(formKey - .currentState?.fields['gewicht']?.value), + .currentState?.fields['gewicht']?.value ?? + box.get("USER").gewicht), int.parse(formKey - .currentState?.fields['groesse']?.value), - int.parse( - formKey.currentState?.fields['alter']?.value), + .currentState?.fields['groesse']?.value ?? + int.parse(box.get("USER").groesse)), int.parse(formKey - .currentState?.fields['kalorien']?.value))); + .currentState?.fields['alter']?.value ?? + int.parse(box.get("USER").alter)), + int.parse(formKey.currentState?.fields['kalorien'] + ?.value ?? + int.parse(box.get("USER").kalorien)))); Navigator.of(context).pushReplacement(MaterialPageRoute( builder: (BuildContext context) => const MainPage())); diff --git a/lib/android/components/form/form_builder_text_field_component.dart b/lib/android/components/form/form_builder_text_field_component.dart index 1c18a35..36a201b 100644 --- a/lib/android/components/form/form_builder_text_field_component.dart +++ b/lib/android/components/form/form_builder_text_field_component.dart @@ -75,16 +75,18 @@ class TextFieldChild extends StatelessWidget { hintText: StringUtils.capitalize(formTextField.title), labelText: StringUtils.capitalize(formTextField.title), fillColor: Colors.white70), - keyboardType: TextInputType.number, + keyboardType: formTextField.textInputType, maxLength: TextInputType.number == formTextField.textInputType ? 7 : 30, autovalidateMode: AutovalidateMode.onUserInteraction, validator: FormBuilderValidators.compose([ FormBuilderValidators.required(), + TextInputType.number == formTextField.textInputType ? FormBuilderValidators.max(formTextField.numericMax!, errorText: formTextField.numericMaxErrorMessage) : FormBuilderValidators.maxLength(30, errorText: formTextField.maxLengthErrorMessage), + TextInputType.number == formTextField.textInputType ? FormBuilderValidators.min(formTextField.numericMin!, errorText: formTextField.numericMinErrorMessage)