diff --git a/Todo.txt b/Todo.txt index ad21d9b..baecd28 100644 --- a/Todo.txt +++ b/Todo.txt @@ -10,6 +10,7 @@ nach koordinaten lkr auswählen (esri-leaflet-geocoder) fix ktage und nebeneinander positioniere textdateien auch an server senden error check wenn dateiauswahl abgebrochen wurde einfügen +save option einfügen nur zum speichern keine ahnung obs funktioniert: eintrg in db wenn http response (in sent column) diff --git a/lib/addCam/add_cam_main.dart b/lib/addCam/add_cam_main.dart index f0c7424..62862cd 100644 --- a/lib/addCam/add_cam_main.dart +++ b/lib/addCam/add_cam_main.dart @@ -256,7 +256,7 @@ class _AddCamMainState extends State { child: Text(AppLocalizations.of(context)!.template)), TextButton( onPressed: () async { - saveFile(); + saveData(); _httpRequest(); Navigator.pushNamedAndRemoveUntil( // ignore: use_build_context_synchronously @@ -412,7 +412,12 @@ class _AddCamMainState extends State { children: [ Align( alignment: Alignment.bottomLeft, - child: Standort(standortC: standortC), + child: RequiredVarTextField( + required: true, + dbName: "Standort", + textController: standortC, + localization: AppLocalizations.of(context)!.altstort, + ), ), const SizedBox( height: 1, @@ -447,6 +452,7 @@ class _AddCamMainState extends State { }); }, ), + RequiredVarTextField(textController: betreuungC, localization: AppLocalizations.of(context)!.betreuung, dbName: "KontSum", required: false), Betreuung(betreuungC: betreuungC), const SizedBox( height: 20, @@ -510,7 +516,7 @@ class _AddCamMainState extends State { ], )), - // Second step + // Second step Step( title: Text(AppLocalizations.of(context)!.secondstep), content: Column( @@ -699,7 +705,7 @@ class _AddCamMainState extends State { )) ]; - // Here the site is built inclusive the steps from above + // Here the site is built with the steps from above return Scaffold( appBar: AppBar(title: Text(AppLocalizations.of(context)!.addplace)), body: PageTransitionSwitcher( diff --git a/lib/addCam/cam_widgets.dart b/lib/addCam/cam_widgets.dart index 85ffb14..3a37bad 100644 --- a/lib/addCam/cam_widgets.dart +++ b/lib/addCam/cam_widgets.dart @@ -16,6 +16,192 @@ import 'package:shared_preferences/shared_preferences.dart'; // * Step 1 place, camera, terretory // +class RequiredVarTextField extends StatefulWidget { + final TextEditingController textController; + final String localization; + final String dbName; + final bool required; + + const RequiredVarTextField( + {super.key, + required this.textController, + required this.localization, + required this.dbName, required this.required}); + + @override + State createState() => _RequiredVarTextFieldState(); +} + +class _RequiredVarTextFieldState extends State { + late Future>> dbVar; + + @override + void initState() { + super.initState(); + dbVar = DBHelper().getPlace(); + } + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Expanded( + flex: 3, + child: TextField( + controller: widget.textController, + keyboardType: TextInputType.multiline, + maxLines: null, + decoration: InputDecoration( + hintText: widget.localization, + enabledBorder: widget.required + ? (widget.textController.text.isEmpty + ? const UnderlineInputBorder( + borderSide: BorderSide(color: Colors.red)) + : const UnderlineInputBorder( + borderSide: BorderSide(color: Colors.green))) + : const UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey)), + focusedBorder: widget.required + ? (widget.textController.text.isEmpty + ? const UnderlineInputBorder( + borderSide: BorderSide(color: Colors.red)) + : const UnderlineInputBorder( + borderSide: BorderSide(color: Colors.green))) + : const UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey)) + ), + )), + Expanded( + flex: 1, + child: Align( + alignment: Alignment.bottomLeft, + child: FutureBuilder>>( + future: dbVar, + builder: (BuildContext context, + AsyncSnapshot>> snapshot) { + if (snapshot.hasData) { + return PopupMenuButton( + onSelected: (String value) { + setState(() { + widget.textController.text = value; + }); + }, + itemBuilder: (BuildContext context) { + return snapshot.data! + .map((item) => PopupMenuItem( + value: item[widget.dbName].toString(), + child: Text(item[widget.dbName].toString()), + )) + .toList(); + }, + child: const Icon(Icons.arrow_drop_down), + ); + } else if (snapshot.hasError) { + return Text('Fehler: ${snapshot.error}'); + } else { + return const CircularProgressIndicator(); + } + }, + ), + ), + ) + ], + ); + } + + DropdownMenuItem buildMenuItem(String item) => DropdownMenuItem( + value: item, + child: Text(item), + ); +} + +// Standort + +class Standort extends StatefulWidget { + final TextEditingController standortC; + final String localization; + + const Standort( + {super.key, required this.standortC, required this.localization}); + + @override + State createState() => _RequiredVarTextFieldState(); +} + +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 { @@ -45,8 +231,8 @@ class _CamIdState extends State { Expanded( flex: 2, child: TextField( - keyboardType: TextInputType.multiline, - maxLines: null, + keyboardType: TextInputType.multiline, + maxLines: null, decoration: InputDecoration( hintText: AppLocalizations.of(context)!.camLink, enabledBorder: widget.id.text.isEmpty @@ -233,7 +419,9 @@ class Karte extends StatefulWidget { } class KarteState extends State { - List markers = [const Marker(point: LatLng(0, 0), child: Icon(Icons.location_on))]; + List markers = [ + const Marker(point: LatLng(0, 0), child: Icon(Icons.location_on)) + ]; LatLng? selectedPosition; Position? updatedPosition; bool saveVisible = false; @@ -241,7 +429,15 @@ class KarteState extends State { @override void initState() { super.initState(); - markers = [Marker(point: LatLng(widget.currentPosition.latitude, widget.currentPosition.longitude), child: const Icon(Icons.location_on, color: Colors.red,))]; + markers = [ + Marker( + point: LatLng(widget.currentPosition.latitude, + widget.currentPosition.longitude), + child: const Icon( + Icons.location_on, + color: Colors.red, + )) + ]; } @override @@ -283,9 +479,12 @@ class KarteState extends State { ], ), body: FlutterMap( - mapController: MapController(), + mapController: MapController(), options: MapOptions( - interactionOptions: const InteractionOptions(flags: InteractiveFlag.pinchZoom | InteractiveFlag.drag | InteractiveFlag.pinchMove), + interactionOptions: const InteractionOptions( + flags: InteractiveFlag.pinchZoom | + InteractiveFlag.drag | + InteractiveFlag.pinchMove), initialCenter: LatLng(widget.currentPosition.latitude, widget.currentPosition.longitude), initialZoom: 16.0, @@ -406,7 +605,7 @@ class Adresse1 extends StatefulWidget { const Adresse1({super.key, required this.adresse1C}); @override -State createState() => _Adresse1State(); + State createState() => _Adresse1State(); } class _Adresse1State extends State { @@ -551,7 +750,8 @@ class _Adresse2State extends State { if (snapshot.hasData) { return DropdownButton( items: snapshot.data! - .map((item) => buildMenuItem(item['Adresse2'].toString())) + .map((item) => + buildMenuItem(item['Adresse2'].toString())) .toList(), onChanged: (value) { setState( @@ -1721,7 +1921,8 @@ class _AbbauDatState extends State { ), Builder(builder: (context) { if (abbauDat != null) { - return Text('${abbauDat?.day}. ${abbauDat?.month}. ${abbauDat?.year}'); + return Text( + '${abbauDat?.day}. ${abbauDat?.month}. ${abbauDat?.year}'); } else { return Text(AppLocalizations.of(context)!.nichts); } @@ -2216,96 +2417,6 @@ class _FKontakt3State extends State { ); } -// Standort - -class Standort extends StatefulWidget { - final TextEditingController standortC; - - const Standort({super.key, required this.standortC}); - - @override - State createState() => _StandortState(); -} - -class _StandortState extends State { - String? selectedRudel; - 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: AppLocalizations.of(context)!.altstort, - enabledBorder: widget.standortC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - focusedBorder: widget.standortC.text.isEmpty - ? const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.red)) - : const UnderlineInputBorder( - borderSide: BorderSide(color: Colors.green)), - ), - controller: widget.standortC, - )), - 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( - () { - selectedRudel = value; - widget.standortC.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 { diff --git a/time.txt b/time.txt index 0e9a590..6809640 100644 --- a/time.txt +++ b/time.txt @@ -46,4 +46,5 @@ 21 mär 4h 15 min 23 mär 2h 15 min 24 mär 1h -26 mär beginn 10:20 \ No newline at end of file +26 mär 45 min +20 mär 1h 30 min \ No newline at end of file