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,
),
),
const SizedBox(
height: 1,
),
const SizedBox(
height: 5,
),
@@ -534,7 +531,7 @@ class _AddCamMainState extends State<AddCamMain> {
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<AddCamMain> {
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<AddCamMain> {
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<AddCamMain> {
],
),
),
VarTextField(
textController: kTage1C,
localization: AppLocalizations.of(context)!.ktage1,
dbName: "KTage1",
required: true,
default_value: "kTage1",
),
const SizedBox(
height: 20,
),
Align(
alignment: Alignment.bottomLeft,
child: Row(
Row(
children: [
Text(AppLocalizations.of(context)!.ktage2),
const Text(
'*',
style: TextStyle(color: Colors.red),
)
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))
],
)),
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<AddCamMain> {
localization: AppLocalizations.of(context)!.adresse1,
dbName: "Adresse1",
required: true,
default_value: "addresse1",
defaultValue: "addresse1",
),
VarTextField(
textController: adresse2C,

View File

@@ -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<VarTextField> createState() => _VarTextFieldState();
@@ -36,10 +38,14 @@ class _VarTextFieldState extends State<VarTextField> {
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<VarTextField> {
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,9 +99,11 @@ class _VarTextFieldState extends State<VarTextField> {
: const UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey))),
)),
const SizedBox(
const Expanded(
child: SizedBox(
width: 15,
),
),
Expanded(
flex: 1,
child: Align(
@@ -111,6 +119,9 @@ class _VarTextFieldState extends State<VarTextField> {
item[widget.dbName] != null &&
item[widget.dbName] != "")
.toList();
var uniqueData = { ...filteredData.map((e) => e[widget.dbName].toString())};
return PopupMenuButton<String>(
onSelected: (String value) {
setState(() {
@@ -118,10 +129,10 @@ class _VarTextFieldState extends State<VarTextField> {
});
},
itemBuilder: (BuildContext context) {
return filteredData
.map((item) => PopupMenuItem<String>(
value: item[widget.dbName].toString(),
child: Text(item[widget.dbName].toString()),
return uniqueData
.map((value) => PopupMenuItem<String>(
value: value,
child: Text(value),
))
.toList();
},
@@ -141,6 +152,8 @@ class _VarTextFieldState extends State<VarTextField> {
}
}
// Karte
// ! completely new page
@@ -810,7 +823,7 @@ class _AbbauDatState extends State<AbbauDat> {
Widget build(BuildContext context) {
return Row(
children: [
Row(children: [
Column(children: [
SizedBox(
width: 140,
child: ElevatedButton(
@@ -822,6 +835,8 @@ class _AbbauDatState extends State<AbbauDat> {
},
child: Text(AppLocalizations.of(context)!.pickabbaudat)),
),
Row(
children: [
const SizedBox(
width: 10,
),
@@ -845,6 +860,8 @@ class _AbbauDatState extends State<AbbauDat> {
child: const Text("X"))
]),
],
)
],
);
}
@@ -856,6 +873,6 @@ class _AbbauDatState extends State<AbbauDat> {
lastDate: DateTime(5000));
if (date == null) return null;
return abbauDat;
return date;
}
}

View File

@@ -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",

View File

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