From 1b9d8b693fb47b93eeaf649408dcc60ce4b0e7fa Mon Sep 17 00:00:00 2001 From: bogdan <1926167@stud.hs-mannheim.de> Date: Tue, 6 Jun 2023 23:45:02 +0200 Subject: [PATCH] bug fix --- .flutter-plugins-dependencies | 2 +- lib/android/components/form/form_builder.dart | 68 ++++++++++++------- 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 1caa7f2..915bca8 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"fluttertoast","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/fluttertoast-8.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.2/","native_build":true,"dependencies":[]}],"android":[{"name":"fluttertoast","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/fluttertoast-8.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.10/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.6/","native_build":false,"dependencies":[]}],"web":[{"name":"fluttertoast","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/fluttertoast-8.2.2/","dependencies":[]}]},"dependencyGraph":[{"name":"fluttertoast","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-06-03 00:48:24.365407","version":"3.7.9"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"fluttertoast","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/fluttertoast-8.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.2/","native_build":true,"dependencies":[]}],"android":[{"name":"fluttertoast","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/fluttertoast-8.2.2/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.10/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.6/","native_build":false,"dependencies":[]}],"web":[{"name":"fluttertoast","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/fluttertoast-8.2.2/","dependencies":[]}]},"dependencyGraph":[{"name":"fluttertoast","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-06-06 22:44:47.468267","version":"3.7.9"} \ No newline at end of file diff --git a/lib/android/components/form/form_builder.dart b/lib/android/components/form/form_builder.dart index d79d85f..486d39f 100644 --- a/lib/android/components/form/form_builder.dart +++ b/lib/android/components/form/form_builder.dart @@ -119,32 +119,52 @@ class _FormBuilderComponentState extends State { onPressed: () { final Box box = Hive.box("USER_BOX"); - print(formKey - .currentState?.fields['gewicht']?.value ?? - box.get("USER").gewicht); + if (widget.lockTextFields) { + box.put( + "USER", + User( + formKey.currentState?.fields['vorname'] + ?.value ?? + box.get("USER").vorname.toString(), + formKey.currentState?.fields['nachname'] + ?.value ?? + box.get("USER").nachname.toString(), + formKey.currentState?.fields['gewicht'] + ?.value ?? + box.get("USER").gewicht, + formKey.currentState?.fields['groesse'] + ?.value ?? + box.get("USER").groesse, + formKey.currentState?.fields['alter']?.value ?? + box.get("USER").alter, + formKey.currentState?.fields['kalorien'] + ?.value ?? + box.get("USER").kalorien)); - box.put( - "USER", - User( - 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 ?? - box.get("USER").gewicht), - int.parse(formKey - .currentState?.fields['groesse']?.value ?? - int.parse(box.get("USER").groesse)), - int.parse(formKey - .currentState?.fields['alter']?.value ?? - int.parse(box.get("USER").alter)), - int.parse(formKey.currentState?.fields['kalorien'] - ?.value ?? - int.parse(box.get("USER").kalorien)))); + ScaffoldMessenger.of(context) + .showSnackBar(const SnackBar( + duration: Duration(seconds: 2), + content: Text('Eine Beispiel Snackbar'), + )); + } else { + box.put( + "USER", + User( + formKey.currentState?.fields['vorname']?.value, + formKey.currentState?.fields['nachname']?.value, + formKey.currentState?.fields['gewicht']?.value, + formKey.currentState?.fields['groesse']?.value, + formKey.currentState?.fields['alter']?.value, + formKey + .currentState?.fields['kalorien']?.value)); + } - Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (BuildContext context) => const MainPage())); + Future.delayed( + const Duration(seconds: 2), + () => Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => + const MainPage()))); }, child: const Text("Eingaben bestätigen"), )),