filtered double entries, fixed betreuung dropdown, fixed abbau

This commit is contained in:
nico
2024-05-16 21:07:08 +02:00
parent 26fc004dc4
commit def5b35fb8
4 changed files with 65 additions and 48 deletions

View File

@@ -506,9 +506,6 @@ class _AddCamMainState extends State<AddCamMain> {
localization: AppLocalizations.of(context)!.altstort, localization: AppLocalizations.of(context)!.altstort,
), ),
), ),
const SizedBox(
height: 1,
),
const SizedBox( const SizedBox(
height: 5, height: 5,
), ),
@@ -534,7 +531,7 @@ class _AddCamMainState extends State<AddCamMain> {
VarTextField( VarTextField(
textController: betreuungC, textController: betreuungC,
localization: AppLocalizations.of(context)!.betreuung, localization: AppLocalizations.of(context)!.betreuung,
dbName: "KontSum", dbName: "Betreuung",
required: false), required: false),
const SizedBox( const SizedBox(
height: 20, height: 20,
@@ -650,7 +647,7 @@ class _AddCamMainState extends State<AddCamMain> {
localization: AppLocalizations.of(context)!.bland, localization: AppLocalizations.of(context)!.bland,
dbName: "BLand", dbName: "BLand",
required: true, required: true,
default_value: "bLand", defaultValue: "bLand",
), ),
VarTextField( VarTextField(
textController: lkrC, textController: lkrC,
@@ -717,7 +714,7 @@ class _AddCamMainState extends State<AddCamMain> {
alignment: Alignment.bottomLeft, alignment: Alignment.bottomLeft,
child: Row( child: Row(
children: [ children: [
Text(AppLocalizations.of(context)!.ktage1), Text(AppLocalizations.of(context)!.ktage),
const Text( const Text(
'*', '*',
style: TextStyle(color: Colors.red), style: TextStyle(color: Colors.red),
@@ -725,34 +722,31 @@ class _AddCamMainState extends State<AddCamMain> {
], ],
), ),
), ),
VarTextField(
textController: kTage1C, Row(
localization: AppLocalizations.of(context)!.ktage1, children: [
dbName: "KTage1", Expanded(
required: true, child: Text( AppLocalizations.of(context)!.ktage1)),
default_value: "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,
), Row(
Align( children: [
alignment: Alignment.bottomLeft, Expanded(
child: Row( child: Text( AppLocalizations.of(context)!.ktage2)),
children: [ const SizedBox(width: 15,),
Text(AppLocalizations.of(context)!.ktage2), Expanded(
const Text( flex: 4,
'*', child: VarTextField(otherDefault: "48", textController: kTage2C, localization: AppLocalizations.of(context)!.ktage2, dbName: "KTage2", required: true))
style: TextStyle(color: Colors.red), ],
)
],
)),
VarTextField(
textController: kTage2C,
localization: AppLocalizations.of(context)!.ktage2,
dbName: "KTage1",
required: true,
default_value: "kTage2",
), ),
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
@@ -797,7 +791,7 @@ class _AddCamMainState extends State<AddCamMain> {
localization: AppLocalizations.of(context)!.adresse1, localization: AppLocalizations.of(context)!.adresse1,
dbName: "Adresse1", dbName: "Adresse1",
required: true, required: true,
default_value: "addresse1", defaultValue: "addresse1",
), ),
VarTextField( VarTextField(
textController: adresse2C, textController: adresse2C,

View File

@@ -1,4 +1,4 @@
// ignore_for_file: non_constant_identifier_names
import 'package:fforte/other/db_helper.dart'; import 'package:fforte/other/db_helper.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@@ -14,7 +14,8 @@ class VarTextField extends StatefulWidget {
final TextEditingController textController; final TextEditingController textController;
final String localization; final String localization;
final String dbName; final String dbName;
final String? default_value; final String? defaultValue;
final String? otherDefault;
final bool required; final bool required;
const VarTextField( const VarTextField(
@@ -23,7 +24,8 @@ class VarTextField extends StatefulWidget {
required this.localization, required this.localization,
required this.dbName, required this.dbName,
required this.required, required this.required,
this.default_value}); this.defaultValue,
this.otherDefault});
@override @override
State<VarTextField> createState() => _VarTextFieldState(); State<VarTextField> createState() => _VarTextFieldState();
@@ -36,10 +38,14 @@ class _VarTextFieldState extends State<VarTextField> {
void initState() { void initState() {
super.initState(); super.initState();
if (widget.textController.text == "" && widget.default_value != null) { if (widget.textController.text == "" && widget.defaultValue != null) {
_loadPref(); _loadPref();
} }
if (widget.otherDefault != null) {
widget.textController.text = widget.otherDefault!;
}
dbVar = _loadData(); dbVar = _loadData();
} }
@@ -52,7 +58,7 @@ class _VarTextFieldState extends State<VarTextField> {
void _loadPref() { void _loadPref() {
Future.delayed(Duration.zero, () async { Future.delayed(Duration.zero, () async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
String bLand = prefs.getString(widget.default_value!) ?? ""; String bLand = prefs.getString(widget.defaultValue!) ?? "";
setState(() { setState(() {
widget.textController.text = bLand; widget.textController.text = bLand;
}); });
@@ -93,8 +99,10 @@ class _VarTextFieldState extends State<VarTextField> {
: const UnderlineInputBorder( : const UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey))), borderSide: BorderSide(color: Colors.grey))),
)), )),
const SizedBox( const Expanded(
width: 15, child: SizedBox(
width: 15,
),
), ),
Expanded( Expanded(
flex: 1, flex: 1,
@@ -111,6 +119,9 @@ class _VarTextFieldState extends State<VarTextField> {
item[widget.dbName] != null && item[widget.dbName] != null &&
item[widget.dbName] != "") item[widget.dbName] != "")
.toList(); .toList();
var uniqueData = { ...filteredData.map((e) => e[widget.dbName].toString())};
return PopupMenuButton<String>( return PopupMenuButton<String>(
onSelected: (String value) { onSelected: (String value) {
setState(() { setState(() {
@@ -118,10 +129,10 @@ class _VarTextFieldState extends State<VarTextField> {
}); });
}, },
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return filteredData return uniqueData
.map((item) => PopupMenuItem<String>( .map((value) => PopupMenuItem<String>(
value: item[widget.dbName].toString(), value: value,
child: Text(item[widget.dbName].toString()), child: Text(value),
)) ))
.toList(); .toList();
}, },
@@ -141,6 +152,8 @@ class _VarTextFieldState extends State<VarTextField> {
} }
} }
// Karte // Karte
// ! completely new page // ! completely new page
@@ -810,7 +823,7 @@ class _AbbauDatState extends State<AbbauDat> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Row(
children: [ children: [
Row(children: [ Column(children: [
SizedBox( SizedBox(
width: 140, width: 140,
child: ElevatedButton( child: ElevatedButton(
@@ -822,6 +835,8 @@ class _AbbauDatState extends State<AbbauDat> {
}, },
child: Text(AppLocalizations.of(context)!.pickabbaudat)), child: Text(AppLocalizations.of(context)!.pickabbaudat)),
), ),
Row(
children: [
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
@@ -844,6 +859,8 @@ class _AbbauDatState extends State<AbbauDat> {
}, },
child: const Text("X")) child: const Text("X"))
]), ]),
],
)
], ],
); );
} }
@@ -856,6 +873,6 @@ class _AbbauDatState extends State<AbbauDat> {
lastDate: DateTime(5000)); lastDate: DateTime(5000));
if (date == null) return null; if (date == null) return null;
return abbauDat; return date;
} }
} }

View File

@@ -52,8 +52,9 @@
"altstort": "Standort", "altstort": "Standort",
"wiesefeld": "Wiese/Feld/Offenfläche", "wiesefeld": "Wiese/Feld/Offenfläche",
"nichts": "---", "nichts": "---",
"ktage1": "Kontrollintervall (Tage 1)", "ktage": "Kontrollintervall",
"ktage2": "Kontrollintervall (Tage 2)", "ktage1": "Tage 1",
"ktage2": "Tage 2",
"eugrid": "EUGrid", "eugrid": "EUGrid",
"pickDate": "Aufstellung", "pickDate": "Aufstellung",
"pickTime": "Zeit auswählen", "pickTime": "Zeit auswählen",

View File

@@ -246,6 +246,11 @@
"description": "nichts text" "description": "nichts text"
}, },
"ktage": "KDays",
"@ktage": {
"description": "just ktage"
},
"ktage1": "KDays 1", "ktage1": "KDays 1",
"@ktage1": { "@ktage1": {
"description": "ktage1 text/number field" "description": "ktage1 text/number field"