diff --git a/Todo.txt b/Todo.txt index b7ee0bc..01dd2a8 100644 --- a/Todo.txt +++ b/Todo.txt @@ -2,7 +2,6 @@ todo: maybe auch vorschläge aus templates in dropdown menüs anzeigen im englischen abändern zurückfeld in datenansicht -überschriften für view cams dropdown menü fixen (ai fragen) fehler beim speichern anzeigen nach koordinaten lkr auswählen (esri-leaflet-geocoder) @@ -28,6 +27,7 @@ eintrg in db wenn http response (in sent column) not to do: +überschriften für view cams standartwert in textfeld überschriften für view cams schritte latlang umbenennen diff --git a/lib/addCam/cam_widgets.dart b/lib/addCam/cam_widgets.dart index 1934bf3..ce94130 100644 --- a/lib/addCam/cam_widgets.dart +++ b/lib/addCam/cam_widgets.dart @@ -11,11 +11,6 @@ import 'package:geocoding/geocoding.dart'; // * Collection of All widgets displayed in the add_cam section -// ! Sort!! - -// -// * Step 1 place, camera, terretory -// class VarTextField extends StatefulWidget { final TextEditingController textController; @@ -43,8 +38,9 @@ class _VarTextFieldState extends State { void initState() { super.initState(); - if (widget.textController.text == "" && widget.default_value != null) + if (widget.textController.text == "" && widget.default_value != null) { _loadPref(); + } dbVar = DBHelper().getPlace(); } @@ -64,7 +60,7 @@ class _VarTextFieldState extends State { return Row( children: [ Expanded( - flex: 3, + flex: 5, child: TextField( controller: widget.textController, keyboardType: TextInputType.multiline, @@ -93,6 +89,7 @@ class _VarTextFieldState extends State { : const UnderlineInputBorder( borderSide: BorderSide(color: Colors.grey))), )), + const SizedBox(width: 15,), Expanded( flex: 1, child: Align( @@ -102,6 +99,8 @@ class _VarTextFieldState extends State { builder: (BuildContext context, AsyncSnapshot>> snapshot) { if (snapshot.hasData) { + // Filtern der Daten, um sicherzustellen, dass keine 'null' Werte für den Schlüssel dbName vorhanden sind + var filteredData = snapshot.data!.where((item) => item[widget.dbName] != null && item[widget.dbName] != "" ).toList(); return PopupMenuButton( onSelected: (String value) { setState(() { @@ -109,7 +108,7 @@ class _VarTextFieldState extends State { }); }, itemBuilder: (BuildContext context) { - return snapshot.data! + return filteredData .map((item) => PopupMenuItem( value: item[widget.dbName].toString(), child: Text(item[widget.dbName].toString()), @@ -137,295 +136,8 @@ class _VarTextFieldState extends State { ); } -// Standort -class Standort extends StatefulWidget { - final TextEditingController standortC; - final String localization; - const Standort( - {super.key, required this.standortC, required this.localization}); - - @override - State createState() => _StandortState(); -} - -class _StandortState extends State { - late Future>> Standort; - - @override - void initState() { - super.initState(); - Standort = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 3, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: widget.localization, - enabledBorder: widget.textController.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.textController.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.textController, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: Standort, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['Standort'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - widget.textController.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// CamId == ID of the camera - -class CamId extends StatefulWidget { - final TextEditingController id; - - const CamId({super.key, required this.id}); - - @override - State createState() => _CamIdState(); -} - -class _CamIdState extends State { - bool error = false; - String? selectedID; - late Future>> ids; - - @override - void initState() { - super.initState(); - ids = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.camLink, - enabledBorder: widget.id.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.id.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.id, - onChanged: (value) { - setState(() { - widget.id.text = value; - }); - }, - ), - ), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: ids, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => buildMenuItem(item['CID'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedID = value; - widget.id.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// Rudel == Rudel or Terretory or Animal species - -class Rudel extends StatefulWidget { - final TextEditingController rudelC; - - const Rudel({super.key, required this.rudelC}); - - @override - State createState() => _RudelState(); -} - -class _RudelState extends State { - String? selectedRudel; - late Future>> rudel; - - @override - void initState() { - super.initState(); - rudel = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.rudel, - enabledBorder: widget.rudelC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.rudelC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.rudelC, - onChanged: (value) => setState(() { - widget.rudelC.text = value; - }), - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: rudel, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => buildMenuItem(item['Rudel'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.rudelC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// -// * Step 2 Date, contact, place -// - -// -// -// -// -// -// -// -// -// -// // Karte // ! completely new page @@ -501,6 +213,7 @@ class KarteState extends State { widget.onPositionChange(updatedPosition!); }); } + // ignore: use_build_context_synchronously Navigator.pop(context); }, child: const Icon(Icons.save), @@ -629,637 +342,6 @@ class _DatumState extends State { } } -// Adresse1 - -class Adresse1 extends StatefulWidget { - final TextEditingController adresse1C; - - const Adresse1({super.key, required this.adresse1C}); - - @override - State createState() => _Adresse1State(); -} - -class _Adresse1State extends State { - String? selectedRudel; - late Future>> Adresse1; - - @override - void initState() { - super.initState(); - - _loadPref(); - - Adresse1 = DBHelper().getPlace(); - } - - void _loadPref() { - Future.delayed(Duration.zero, () async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - String adresse1 = prefs.getString('adresse1') ?? ""; - setState(() { - widget.adresse1C.text = adresse1; - }); - }); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.adresse1, - enabledBorder: widget.adresse1C.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.adresse1C.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.adresse1C, - onChanged: (value) => setState(() { - widget.adresse1C.text = value; - }), - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: Adresse1, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['Adresse1'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.adresse1C.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// Adresse2 - -class Adresse2 extends StatefulWidget { - final TextEditingController adresse2C; - - const Adresse2({super.key, required this.adresse2C}); - - @override - State createState() => _Adresse2State(); -} - -class _Adresse2State extends State { - String? selectedRudel; - late Future>> Adresse2; - - @override - void initState() { - super.initState(); - Adresse2 = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.adresse2), - controller: widget.adresse2C, - onChanged: (value) => setState(() { - widget.adresse2C.text = value; - }), - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: Adresse2, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['Adresse2'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.adresse2C.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// Adresse3 - -class Adresse3 extends StatefulWidget { - final TextEditingController adresse3C; - - const Adresse3({super.key, required this.adresse3C}); - - @override - State createState() => _Adresse3State(); -} - -class _Adresse3State extends State { - String? selectedRudel; - late Future>> Adresse3; - - @override - void initState() { - super.initState(); - Adresse3 = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.adresse3), - controller: widget.adresse3C, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: Adresse3, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['Adresse3'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.adresse3C.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// BLand - -class BLand extends StatefulWidget { - final TextEditingController bLandC; - - const BLand({super.key, required this.bLandC}); - - @override - State createState() => _BLandState(); -} - -class _BLandState extends State { - String? selectedRudel; - late Future>> BLand; - - @override - void initState() { - super.initState(); - - if (widget.bLandC.text == "") _loadPref(); - - BLand = DBHelper().getPlace(); - } - - void _loadPref() { - Future.delayed(Duration.zero, () async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - String bLand = prefs.getString('bLand') ?? ""; - setState(() { - widget.bLandC.text = bLand; - }); - }); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.bland, - enabledBorder: widget.bLandC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.bLandC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.bLandC, - onChanged: (value) => setState(() { - widget.bLandC.text = value; - }), - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: BLand, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => buildMenuItem(item['BLand'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.bLandC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// Lkr - -class Lkr extends StatefulWidget { - final TextEditingController lkrC; - - const Lkr({super.key, required this.lkrC}); - - @override - State createState() => _LkrState(); -} - -class _LkrState extends State { - String? selectedRudel; - late Future>> Lkr; - - @override - void initState() { - super.initState(); - Lkr = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.lkr, - enabledBorder: widget.lkrC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.lkrC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.lkrC, - onChanged: (value) => setState(() { - widget.lkrC.text = value; - }), - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: Lkr, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => buildMenuItem(item['Lkr'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.lkrC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// BeiOrt - -class BeiOrt extends StatefulWidget { - final TextEditingController beiOrtC; - - const BeiOrt({super.key, required this.beiOrtC}); - - @override - State createState() => _BeiOrtState(); -} - -class _BeiOrtState extends State { - String? selectedRudel; - late Future>> BeiOrt; - - @override - void initState() { - super.initState(); - BeiOrt = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.beiort, - enabledBorder: widget.beiOrtC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.beiOrtC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.beiOrtC, - onChanged: (value) => setState(() { - widget.beiOrtC.text = value; - }), - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: BeiOrt, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => buildMenuItem(item['BeiOrt'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.beiOrtC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// OrtInfo - -class OrtInfo extends StatefulWidget { - final TextEditingController ortInfoC; - - const OrtInfo({super.key, required this.ortInfoC}); - - @override - State createState() => _OrtInfoState(); -} - -class _OrtInfoState extends State { - String? selectedRudel; - late Future>> OrtInfo; - - @override - void initState() { - super.initState(); - OrtInfo = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.ortinfo, - ), - controller: widget.ortInfoC, - onChanged: (value) => setState(() { - widget.ortInfoC.text = value; - }), - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: OrtInfo, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map( - (item) => buildMenuItem(item['OrtInfo'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.ortInfoC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} // Status @@ -1381,97 +463,6 @@ class _STTypState extends State { } } -// FFTyp - -class FFTyp extends StatefulWidget { - final TextEditingController ffTypC; - - const FFTyp({super.key, required this.ffTypC}); - - @override - State createState() => _FFTypState(); -} - -class _FFTypState extends State { - String? selectedRudel; - late Future>> FFTyp; - - @override - void initState() { - super.initState(); - FFTyp = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.fftyp, - enabledBorder: widget.ffTypC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.ffTypC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.ffTypC, - onChanged: (value) => setState(() { - widget.ffTypC.text = value; - }), - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: FFTyp, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => buildMenuItem(item['FFTyp'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.ffTypC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - // platzung class Platzung extends StatefulWidget { @@ -1723,84 +714,6 @@ class _MEZState extends State { } } -// KSchloNr - -class KSchloNr extends StatefulWidget { - final TextEditingController kSchloNrC; - - const KSchloNr({super.key, required this.kSchloNrC}); - - @override - State createState() => _KSchloNrState(); -} - -class _KSchloNrState extends State { - String? selectedRudel; - late Future>> KSchloNr; - - @override - void initState() { - super.initState(); - KSchloNr = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.kschlonr), - controller: widget.kSchloNrC, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: KSchloNr, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['KSchloNr'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.kSchloNrC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - // Bearsafe class Bearsafe extends StatefulWidget { @@ -1976,713 +889,3 @@ class _AbbauDatState extends State { return abbauDat; } } - -// Auftrag - -class Auftrag extends StatefulWidget { - final TextEditingController auftragC; - - const Auftrag({super.key, required this.auftragC}); - - @override - State createState() => _AuftragState(); -} - -class _AuftragState extends State { - String? selectedRudel; - late Future>> Auftrag; - - @override - void initState() { - super.initState(); - Auftrag = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.auftrag), - controller: widget.auftragC, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: Auftrag, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map( - (item) => buildMenuItem(item['Auftrag'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.auftragC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// KontAbsp - -class KontAbsp extends StatefulWidget { - final TextEditingController kontAbspC; - - const KontAbsp({super.key, required this.kontAbspC}); - - @override - State createState() => _KontAbspState(); -} - -class _KontAbspState extends State { - String? selectedRudel; - late Future>> KontAbsp; - - @override - void initState() { - super.initState(); - KontAbsp = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.kontabsp), - controller: widget.kontAbspC, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: KontAbsp, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['KontAbsp'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.kontAbspC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// SonstBem - -class SonstBem extends StatefulWidget { - final TextEditingController sonstBemC; - - const SonstBem({super.key, required this.sonstBemC}); - - @override - State createState() => _SonstBemState(); -} - -class _SonstBemState extends State { - String? selectedRudel; - late Future>> SonstBem; - - @override - void initState() { - super.initState(); - SonstBem = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.sonstbemerkungen), - controller: widget.sonstBemC, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: SonstBem, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['SonstBem'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.sonstBemC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// FKontakt1 - -class FKontakt1 extends StatefulWidget { - final TextEditingController fKontakt1C; - - const FKontakt1({super.key, required this.fKontakt1C}); - - @override - State createState() => _FKontakt1State(); -} - -class _FKontakt1State extends State { - String? selectedRudel; - late Future>> FKontakt1; - - @override - void initState() { - super.initState(); - FKontakt1 = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.fkontakt1), - controller: widget.fKontakt1C, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: FKontakt1, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['FKontakt1'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.fKontakt1C.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// FKontakt2 - -class FKontakt2 extends StatefulWidget { - final TextEditingController fKontakt2C; - - const FKontakt2({super.key, required this.fKontakt2C}); - - @override - State createState() => _FKontakt2State(); -} - -class _FKontakt2State extends State { - String? selectedRudel; - late Future>> FKontakt2; - - @override - void initState() { - super.initState(); - FKontakt2 = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.fkontakt2), - controller: widget.fKontakt2C, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: FKontakt2, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['FKontakt2'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.fKontakt2C.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// FKontakt3 - -class FKontakt3 extends StatefulWidget { - final TextEditingController fKontakt3C; - - const FKontakt3({super.key, required this.fKontakt3C}); - - @override - State createState() => _FKontakt3State(); -} - -class _FKontakt3State extends State { - String? selectedRudel; - late Future>> FKontakt3; - - @override - void initState() { - super.initState(); - FKontakt3 = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 3, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.fkontakt3), - controller: widget.fKontakt3C, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: FKontakt3, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map((item) => - buildMenuItem(item['FKontakt3'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.fKontakt3C.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// KTage1 - -class KTage1 extends StatefulWidget { - final TextEditingController kTage1C; - - const KTage1({super.key, required this.kTage1C}); - - @override - State createState() => _KTage1State(); -} - -class _KTage1State extends State { - @override - void initState() { - super.initState(); - widget.kTage1C.text = '28'; - } - - @override - Widget build(BuildContext context) { - return TextField( - keyboardType: TextInputType.number, - controller: widget.kTage1C, - onChanged: (value) => setState(() { - widget.kTage1C.text = value; - }), - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.ktage1, - enabledBorder: widget.kTage1C.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.kTage1C.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - ); - } -} - -// KTage2 - -class KTage2 extends StatefulWidget { - final TextEditingController kTage2C; - - const KTage2({super.key, required this.kTage2C}); - - @override - State createState() => _KTage2State(); -} - -class _KTage2State extends State { - @override - void initState() { - super.initState(); - widget.kTage2C.text = '42'; - } - - @override - Widget build(BuildContext context) { - return TextField( - keyboardType: TextInputType.number, - controller: widget.kTage2C, - onChanged: (value) => setState(() { - widget.kTage2C.text = value; - }), - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.ktage2, - enabledBorder: widget.kTage2C.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.kTage2C.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - ); - } -} - -// IntKomm - -class IntKomm extends StatefulWidget { - final TextEditingController intKommC; - - const IntKomm({super.key, required this.intKommC}); - - @override - State createState() => _IntKommState(); -} - -class _IntKommState extends State { - String? selectedRudel; - late Future>> IntKomm; - - @override - void initState() { - super.initState(); - IntKomm = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 2, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.intkomm), - controller: widget.intKommC, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: IntKomm, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map( - (item) => buildMenuItem(item['IntKomm'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.intKommC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} - -// KontSum - -class Betreuung extends StatefulWidget { - final TextEditingController betreuungC; - - const Betreuung({super.key, required this.betreuungC}); - - @override - State createState() => _BetreuungState(); -} - -class _BetreuungState extends State { - String? selectedRudel; - late Future>> KontSum; - - @override - void initState() { - super.initState(); - KontSum = DBHelper().getPlace(); - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Expanded( - flex: 3, - child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, - decoration: InputDecoration( - hintText: AppLocalizations.of(context)!.betreuung), - controller: widget.betreuungC, - )), - Expanded( - flex: 1, - child: Align( - alignment: Alignment.bottomLeft, - child: FutureBuilder>>( - future: KontSum, - builder: (BuildContext context, - AsyncSnapshot>> snapshot) { - if (snapshot.hasData) { - return DropdownButton( - items: snapshot.data! - .map( - (item) => buildMenuItem(item['KontSum'].toString())) - .toList(), - onChanged: (value) { - setState( - () { - selectedRudel = value; - widget.betreuungC.text = value ?? ''; - }, - ); - }, - value: null, - underline: const SizedBox(), - ); - } else if (snapshot.hasError) { - return Text('Fehler: ${snapshot.error}'); - } else { - return const CircularProgressIndicator(); - } - }, - ), - ), - ) - ], - ); - } - - DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( - value: item, - child: Text(item), - ); -} diff --git a/lib/viewCam/view_cams.dart b/lib/viewCam/view_cams.dart index 31c2d37..0f5ec64 100644 --- a/lib/viewCam/view_cams.dart +++ b/lib/viewCam/view_cams.dart @@ -1,8 +1,6 @@ import 'package:fforte/addCam/add_cam_main.dart'; import 'package:fforte/other/db_helper.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_popup_card/flutter_popup_card.dart'; // * Site that shows all entries in the databases