From def5b35fb8037df6354bcb8ab9c44849b8e948f5 Mon Sep 17 00:00:00 2001 From: nico Date: Thu, 16 May 2024 21:07:08 +0200 Subject: [PATCH] filtered double entries, fixed betreuung dropdown, fixed abbau --- lib/addCam/add_cam_main.dart | 60 ++++++++++++++++-------------------- lib/addCam/cam_widgets.dart | 43 ++++++++++++++++++-------- lib/l10n/app_de.arb | 5 +-- lib/l10n/app_en.arb | 5 +++ 4 files changed, 65 insertions(+), 48 deletions(-) diff --git a/lib/addCam/add_cam_main.dart b/lib/addCam/add_cam_main.dart index e430bb1..595cfcf 100644 --- a/lib/addCam/add_cam_main.dart +++ b/lib/addCam/add_cam_main.dart @@ -506,9 +506,6 @@ class _AddCamMainState extends State { localization: AppLocalizations.of(context)!.altstort, ), ), - const SizedBox( - height: 1, - ), const SizedBox( height: 5, ), @@ -534,7 +531,7 @@ class _AddCamMainState extends State { VarTextField( textController: betreuungC, localization: AppLocalizations.of(context)!.betreuung, - dbName: "KontSum", + dbName: "Betreuung", required: false), const SizedBox( height: 20, @@ -650,7 +647,7 @@ class _AddCamMainState extends State { localization: AppLocalizations.of(context)!.bland, dbName: "BLand", required: true, - default_value: "bLand", + defaultValue: "bLand", ), VarTextField( textController: lkrC, @@ -717,7 +714,7 @@ class _AddCamMainState extends State { alignment: Alignment.bottomLeft, child: Row( children: [ - Text(AppLocalizations.of(context)!.ktage1), + Text(AppLocalizations.of(context)!.ktage), const Text( '*', style: TextStyle(color: Colors.red), @@ -725,34 +722,31 @@ class _AddCamMainState extends State { ], ), ), - VarTextField( - textController: kTage1C, - localization: AppLocalizations.of(context)!.ktage1, - dbName: "KTage1", - required: true, - default_value: "kTage1", + + Row( + children: [ + Expanded( + child: Text( AppLocalizations.of(context)!.ktage1)), + + const SizedBox(width: 15,), + Expanded( + flex: 4, + child: VarTextField(otherDefault: "24", textController: kTage1C, localization: AppLocalizations.of(context)!.ktage1, dbName: "KTage1", required: true)) + ], ), - const SizedBox( - height: 20, - ), - Align( - alignment: Alignment.bottomLeft, - child: Row( - children: [ - Text(AppLocalizations.of(context)!.ktage2), - const Text( - '*', - style: TextStyle(color: Colors.red), - ) - ], - )), - VarTextField( - textController: kTage2C, - localization: AppLocalizations.of(context)!.ktage2, - dbName: "KTage1", - required: true, - default_value: "kTage2", + + + Row( + children: [ + Expanded( + child: Text( AppLocalizations.of(context)!.ktage2)), + const SizedBox(width: 15,), + Expanded( + flex: 4, + child: VarTextField(otherDefault: "48", textController: kTage2C, localization: AppLocalizations.of(context)!.ktage2, dbName: "KTage2", required: true)) + ], ), + const SizedBox( height: 20, ), @@ -797,7 +791,7 @@ class _AddCamMainState extends State { localization: AppLocalizations.of(context)!.adresse1, dbName: "Adresse1", required: true, - default_value: "addresse1", + defaultValue: "addresse1", ), VarTextField( textController: adresse2C, diff --git a/lib/addCam/cam_widgets.dart b/lib/addCam/cam_widgets.dart index cbddf6c..87b2a22 100644 --- a/lib/addCam/cam_widgets.dart +++ b/lib/addCam/cam_widgets.dart @@ -1,4 +1,4 @@ -// ignore_for_file: non_constant_identifier_names + import 'package:fforte/other/db_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -14,7 +14,8 @@ class VarTextField extends StatefulWidget { final TextEditingController textController; final String localization; final String dbName; - final String? default_value; + final String? defaultValue; + final String? otherDefault; final bool required; const VarTextField( @@ -23,7 +24,8 @@ class VarTextField extends StatefulWidget { required this.localization, required this.dbName, required this.required, - this.default_value}); + this.defaultValue, + this.otherDefault}); @override State createState() => _VarTextFieldState(); @@ -36,10 +38,14 @@ class _VarTextFieldState extends State { void initState() { super.initState(); - if (widget.textController.text == "" && widget.default_value != null) { + if (widget.textController.text == "" && widget.defaultValue != null) { _loadPref(); } + if (widget.otherDefault != null) { + widget.textController.text = widget.otherDefault!; + } + dbVar = _loadData(); } @@ -52,7 +58,7 @@ class _VarTextFieldState extends State { void _loadPref() { Future.delayed(Duration.zero, () async { SharedPreferences prefs = await SharedPreferences.getInstance(); - String bLand = prefs.getString(widget.default_value!) ?? ""; + String bLand = prefs.getString(widget.defaultValue!) ?? ""; setState(() { widget.textController.text = bLand; }); @@ -93,8 +99,10 @@ class _VarTextFieldState extends State { : const UnderlineInputBorder( borderSide: BorderSide(color: Colors.grey))), )), - const SizedBox( - width: 15, + const Expanded( + child: SizedBox( + width: 15, + ), ), Expanded( flex: 1, @@ -111,6 +119,9 @@ class _VarTextFieldState extends State { item[widget.dbName] != null && item[widget.dbName] != "") .toList(); + + var uniqueData = { ...filteredData.map((e) => e[widget.dbName].toString())}; + return PopupMenuButton( onSelected: (String value) { setState(() { @@ -118,10 +129,10 @@ class _VarTextFieldState extends State { }); }, itemBuilder: (BuildContext context) { - return filteredData - .map((item) => PopupMenuItem( - value: item[widget.dbName].toString(), - child: Text(item[widget.dbName].toString()), + return uniqueData + .map((value) => PopupMenuItem( + value: value, + child: Text(value), )) .toList(); }, @@ -141,6 +152,8 @@ class _VarTextFieldState extends State { } } + + // Karte // ! completely new page @@ -810,7 +823,7 @@ class _AbbauDatState extends State { Widget build(BuildContext context) { return Row( children: [ - Row(children: [ + Column(children: [ SizedBox( width: 140, child: ElevatedButton( @@ -822,6 +835,8 @@ class _AbbauDatState extends State { }, child: Text(AppLocalizations.of(context)!.pickabbaudat)), ), + Row( + children: [ const SizedBox( width: 10, ), @@ -844,6 +859,8 @@ class _AbbauDatState extends State { }, child: const Text("X")) ]), + ], + ) ], ); } @@ -856,6 +873,6 @@ class _AbbauDatState extends State { lastDate: DateTime(5000)); if (date == null) return null; - return abbauDat; + return date; } } diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index fe09b0d..715d775 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -52,8 +52,9 @@ "altstort": "Standort", "wiesefeld": "Wiese/Feld/Offenfläche", "nichts": "---", - "ktage1": "Kontrollintervall (Tage 1)", - "ktage2": "Kontrollintervall (Tage 2)", + "ktage": "Kontrollintervall", + "ktage1": "Tage 1", + "ktage2": "Tage 2", "eugrid": "EUGrid", "pickDate": "Aufstellung", "pickTime": "Zeit auswählen", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index b8795fa..441c6b9 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -246,6 +246,11 @@ "description": "nichts text" }, + "ktage": "KDays", + "@ktage": { + "description": "just ktage" + }, + "ktage1": "KDays 1", "@ktage1": { "description": "ktage1 text/number field"