From 2a43ed55140171d9294ba77147f27c82f37d772e Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 10 May 2025 18:04:32 +0200 Subject: [PATCH] outsourced add cam main widgets and cleaned karte widget up time --- lib/screens/addCam/add_cam_main.dart | 20 +- lib/screens/addCam/cam_widgets.dart | 630 ---------------------- lib/screens/addCam/widgets/abbau_dat.dart | 79 +++ lib/screens/addCam/widgets/foto_film.dart | 61 +++ lib/screens/addCam/widgets/karte.dart | 111 ++++ lib/screens/addCam/widgets/kont_dat.dart | 62 +++ lib/screens/addCam/widgets/mez.dart | 59 ++ lib/screens/addCam/widgets/platzung.dart | 134 +++++ lib/screens/addCam/widgets/status.dart | 58 ++ lib/screens/addCam/widgets/sttyp.dart | 61 +++ time.txt | 1 + 11 files changed, 635 insertions(+), 641 deletions(-) create mode 100644 lib/screens/addCam/widgets/abbau_dat.dart create mode 100644 lib/screens/addCam/widgets/foto_film.dart create mode 100644 lib/screens/addCam/widgets/karte.dart create mode 100644 lib/screens/addCam/widgets/kont_dat.dart create mode 100644 lib/screens/addCam/widgets/mez.dart create mode 100644 lib/screens/addCam/widgets/platzung.dart create mode 100644 lib/screens/addCam/widgets/status.dart create mode 100644 lib/screens/addCam/widgets/sttyp.dart diff --git a/lib/screens/addCam/add_cam_main.dart b/lib/screens/addCam/add_cam_main.dart index dc888c8..2ddf318 100644 --- a/lib/screens/addCam/add_cam_main.dart +++ b/lib/screens/addCam/add_cam_main.dart @@ -1,5 +1,4 @@ import 'package:fforte/enums/databases.dart'; -import 'package:fforte/screens/addCam/cam_widgets.dart'; import 'package:fforte/screens/helper/dialog_helper.dart'; import 'package:fforte/screens/helper/snack_bar_helper.dart'; import 'package:fforte/screens/addCam/exceptions/location_disabled_exception.dart'; @@ -15,6 +14,13 @@ import 'package:geolocator/geolocator.dart'; import 'package:latlong2/latlong.dart'; import 'package:animations/animations.dart'; +import 'widgets/abbau_dat.dart'; +import 'widgets/karte.dart'; +import 'widgets/kont_dat.dart'; +import 'widgets/mez.dart'; +import 'widgets/platzung.dart'; +import 'widgets/status.dart'; + class AddCamMain extends StatefulWidget { final bool isTemplate; final bool isFinished; @@ -388,7 +394,6 @@ class _AddCamMainState extends State { content: Column( children: [ Row( - // TODO MAYBE FIX children: [ Column( children: [ @@ -408,15 +413,8 @@ class _AddCamMainState extends State { ortInfoC: rmap["OrtInfo"]!["controller"], beiOrtC: rmap["BeiOrt"]!["controller"], currentPosition: currentPosition, - onPositionChange: (updatedPosition) { - setState(() { - currentPosition = updatedPosition; - rmap["DECLNG"]!["controller"]!.text = - updatedPosition.longitude.toString(); - rmap["DECLAT"]!["controller"]!.text = - updatedPosition.latitude.toString(); - }); - }, + decLatC: rmap["DECLAT"]!["controller"], + decLngC: rmap["DECLNG"]!["controller"], ); })); if (result != null) { diff --git a/lib/screens/addCam/cam_widgets.dart b/lib/screens/addCam/cam_widgets.dart index c06a1ef..d715bda 100644 --- a/lib/screens/addCam/cam_widgets.dart +++ b/lib/screens/addCam/cam_widgets.dart @@ -1,655 +1,25 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:flutter_map/flutter_map.dart'; -import 'package:geolocator/geolocator.dart'; -import 'package:latlong2/latlong.dart'; -import 'package:geocoding/geocoding.dart'; - - // Karte // ! completely new page -class Karte extends StatefulWidget { - final TextEditingController beiOrtC; - final TextEditingController ortInfoC; - final Position currentPosition; - final Function(Position) onPositionChange; - - const Karte( - {super.key, - required this.currentPosition, - required this.onPositionChange, - required this.beiOrtC, - required this.ortInfoC}); - - @override - KarteState createState() => KarteState(); -} - -class KarteState extends State { - List markers = []; - LatLng? selectedPosition; - Position? updatedPosition; - bool saveVisible = false; - - @override - void initState() { - super.initState(); - markers = [ - Marker( - point: LatLng(widget.currentPosition.latitude, - widget.currentPosition.longitude), - child: const Icon( - Icons.location_on, - color: Colors.red, - )) - ]; - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(AppLocalizations.of(context)!.map), - actions: [ - Visibility( - visible: saveVisible, - child: Row( - children: [ - Text(AppLocalizations.of(context)!.saveMap), - TextButton( - onPressed: () async { - List placemarks = await placemarkFromCoordinates( - selectedPosition!.latitude, - selectedPosition!.longitude); - // print(placemarks); - - if (selectedPosition != null) { - setState(() { - widget.beiOrtC.text = placemarks.first.locality!; - widget.ortInfoC.text = placemarks.first.street!; - - updatedPosition = Position( - longitude: selectedPosition!.longitude, - latitude: selectedPosition!.latitude, - timestamp: DateTime.now(), - accuracy: 0.0, - altitude: 0.0, - altitudeAccuracy: 0.0, - heading: 0.0, - headingAccuracy: 0.0, - speed: 0.0, - speedAccuracy: 0.0); - widget.onPositionChange(updatedPosition!); - }); - } - if (context.mounted) Navigator.pop(context); - }, - child: const Icon(Icons.save), - ), - ], - ), - ), - ], - ), - body: FlutterMap( - mapController: MapController(), - options: MapOptions( - interactionOptions: const InteractionOptions( - flags: InteractiveFlag.pinchZoom | - InteractiveFlag.drag | - InteractiveFlag.pinchMove), - initialCenter: LatLng(widget.currentPosition.latitude, - widget.currentPosition.longitude), - initialZoom: 16.0, - onTap: _handleTap, - ), - children: [ - TileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - userAgentPackageName: 'com.example.app', - ), - MarkerLayer(markers: markers), - ]), - ); - } - - _handleTap(TapPosition position, LatLng latlng) { - setState(() { - markers.clear(); - markers.add( - Marker( - width: 80.0, - height: 80.0, - point: latlng, - child: const Icon( - Icons.location_on, - color: Colors.red, - ), - ), - ); - selectedPosition = latlng; - saveVisible = true; - }); - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text( - "${AppLocalizations.of(context)!.markerSet}\n${selectedPosition!.latitude}\n${selectedPosition!.longitude}"))); - } -} // Status -class Status extends StatefulWidget { - final Function(String) onStatusChanged; - final String initialStatus; - - const Status( - {super.key, required this.onStatusChanged, this.initialStatus = 'Aktiv'}); - - @override - State createState() => _StatusState(); -} - -class _StatusState extends State { - String? _selectedStatus; - - @override - void initState() { - super.initState(); - _selectedStatus = widget.initialStatus; - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.aktiv), - leading: Radio( - value: 'aktiv', - groupValue: _selectedStatus, - onChanged: (value) { - setState(() { - _selectedStatus = value; - widget.onStatusChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.inaktiv), - leading: Radio( - value: 'inaktiv', - groupValue: _selectedStatus, - onChanged: (value) { - setState(() { - _selectedStatus = value; - widget.onStatusChanged(value!); - }); - }, - ), - ), - ], - ); - } -} // STTyp -class STTyp extends StatefulWidget { - final Function(String) onSTTypChanged; - final String initialSTTyp; - - const STTyp( - {super.key, - required this.onSTTypChanged, - this.initialSTTyp = 'opportunistisch'}); - - @override - State createState() => _STTypState(); -} - -class _STTypState extends State { - String? _selectedSTTyp; - - @override - void initState() { - super.initState(); - _selectedSTTyp = widget.initialSTTyp; - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.opportunistisch), - leading: Radio( - value: 'opportunistisch', - groupValue: _selectedSTTyp, - onChanged: (value) { - setState(() { - _selectedSTTyp = value; - widget.onSTTypChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.systematisch), - leading: Radio( - value: 'systematisch', - groupValue: _selectedSTTyp, - onChanged: (value) { - setState(() { - _selectedSTTyp = value; - widget.onSTTypChanged(value!); - }); - }, - ), - ), - ], - ); - } -} // platzung -class Platzung extends StatefulWidget { - final Function(String) onPlatzungChanged; - final String? initialPlatzung; - - const Platzung({ - super.key, - required this.onPlatzungChanged, - this.initialPlatzung, - }); - - @override - State createState() => _PlatzungState(); -} - -class _PlatzungState extends State { - String? _selectedPlatzung; - - @override - void initState() { - super.initState(); - if (widget.initialPlatzung != "") { - _selectedPlatzung = widget.initialPlatzung; - } - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.kirrung), - leading: Radio( - value: 'Kirrung', - groupValue: _selectedPlatzung, - onChanged: (value) { - setState(() { - _selectedPlatzung = value; - widget.onPlatzungChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.wasserstelle), - leading: Radio( - value: 'Wasserstelle', - groupValue: _selectedPlatzung, - onChanged: (value) { - setState(() { - _selectedPlatzung = value; - widget.onPlatzungChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.wald), - leading: Radio( - value: 'Wald', - groupValue: _selectedPlatzung, - onChanged: (value) { - setState(() { - _selectedPlatzung = value; - widget.onPlatzungChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.wildwechsel), - leading: Radio( - value: 'Wildwechsel', - groupValue: _selectedPlatzung, - onChanged: (value) { - setState(() { - _selectedPlatzung = value; - widget.onPlatzungChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.wegstrasse), - leading: Radio( - value: 'Weg/Straße', - groupValue: _selectedPlatzung, - onChanged: (value) { - setState(() { - _selectedPlatzung = value; - widget.onPlatzungChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.hofgarten), - leading: Radio( - value: 'Hof/Garten', - groupValue: _selectedPlatzung, - onChanged: (value) { - setState(() { - _selectedPlatzung = value; - widget.onPlatzungChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.wiesefeld), - leading: Radio( - value: 'Wiese/Feld/Offenfläche', - groupValue: _selectedPlatzung, - onChanged: (value) { - setState(() { - _selectedPlatzung = value; - widget.onPlatzungChanged(value!); - }); - }, - ), - ), - ], - ); - } -} // FotoFilm -class FotoFilm extends StatefulWidget { - final Function(String) onFotoFilmChanged; - final String initialFotoFilm; - - const FotoFilm( - {super.key, - required this.onFotoFilmChanged, - this.initialFotoFilm = 'foto'}); - - @override - State createState() => _FotoFilmState(); -} - -class _FotoFilmState extends State { - String? _selectedFotoFilm; - - @override - void initState() { - super.initState(); - _selectedFotoFilm = widget.initialFotoFilm; - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.foto), - leading: Radio( - value: 'Foto', - groupValue: _selectedFotoFilm, - onChanged: (value) { - setState(() { - _selectedFotoFilm = value; - widget.onFotoFilmChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.film), - leading: Radio( - value: 'Film', - groupValue: _selectedFotoFilm, - onChanged: (value) { - setState(() { - _selectedFotoFilm = value; - widget.onFotoFilmChanged(value!); - }); - }, - ), - ), - ], - ); - } -} // MEZ -class MEZ extends StatefulWidget { - final Function(String) onMEZChanged; - final String initialMEZ; - - const MEZ( - {super.key, required this.onMEZChanged, this.initialMEZ = 'sommerzeit'}); - - @override - State createState() => _MEZState(); -} - -class _MEZState extends State { - String? _selectedMEZ; - - @override - void initState() { - super.initState(); - _selectedMEZ = widget.initialMEZ; - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.sommerzeit), - leading: Radio( - value: 'Sommerzeit', - groupValue: _selectedMEZ, - onChanged: (value) { - setState(() { - _selectedMEZ = value; - widget.onMEZChanged(value!); - }); - }, - ), - ), - ListTile( - visualDensity: const VisualDensity(vertical: -4), - title: Text(AppLocalizations.of(context)!.winterzeit), - leading: Radio( - value: 'Winterzeit', - groupValue: _selectedMEZ, - onChanged: (value) { - setState(() { - _selectedMEZ = value; - widget.onMEZChanged(value!); - }); - }, - ), - ), - ], - ); - } -} // KontDat -class KontDat extends StatefulWidget { - final DateTime? initKontDat; - final Function(DateTime) onDateChanged; - - const KontDat( - {super.key, required this.initKontDat, required this.onDateChanged}); - - @override - State createState() => _KontDatState(); -} - -class _KontDatState extends State { - DateTime? kontDat; - - @override - void initState() { - super.initState(); - kontDat = widget.initKontDat; - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Row(children: [ - SizedBox( - width: 140, - child: ElevatedButton( - onPressed: () async { - final date = await pickDate(); - if (date == null) return; - setState(() { - kontDat = date; - }); - widget.onDateChanged(date); - }, - child: Text(AppLocalizations.of(context)!.pickkontdat)), - ), - const SizedBox( - width: 10, - ), - Text( - '${kontDat?.day}. ${kontDat?.month}. ${kontDat?.year}', - ), - ]), - ], - ); - } - - Future pickDate() async { - final date = await showDatePicker( - context: context, - initialDate: kontDat ?? DateTime.now(), - firstDate: DateTime(2000), - lastDate: DateTime(5000)); - - return date; - } -} // AbbauDat - -class AbbauDat extends StatefulWidget { - final DateTime? initAbbauDat; - final Function(DateTime) onDateChanged; - - const AbbauDat({super.key, required this.initAbbauDat, required this.onDateChanged}); - - @override - State createState() => _AbbauDatState(); -} - -class _AbbauDatState extends State { - DateTime? abbauDat; - - @override - void initState() { - super.initState(); - abbauDat = widget.initAbbauDat; - } - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Column(children: [ - SizedBox( - width: 140, - child: ElevatedButton( - onPressed: () async { - final date = await pickDate(); - if (date == null) return; - setState(() => abbauDat = date); - widget.onDateChanged(date); - }, - child: Text(AppLocalizations.of(context)!.pickabbaudat)), - ), - Row( - children: [ - const SizedBox( - width: 10, - ), - Builder(builder: (context) { - if (abbauDat != null) { - return Text( - '${abbauDat?.day}. ${abbauDat?.month}. ${abbauDat?.year}'); - } else { - return Text(AppLocalizations.of(context)!.nichts); - } - }), - const SizedBox( - width: 10, - ), - ElevatedButton( - onPressed: () { - setState(() { - abbauDat = null; - }); - }, - child: const Text("X")) - ]), - ], - ) - ], - ); - } - - Future pickDate() async { - final date = await showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(2000), - lastDate: DateTime(5000)); - if (date == null) return null; - - return date; - } -} diff --git a/lib/screens/addCam/widgets/abbau_dat.dart b/lib/screens/addCam/widgets/abbau_dat.dart new file mode 100644 index 0000000..dfd9df4 --- /dev/null +++ b/lib/screens/addCam/widgets/abbau_dat.dart @@ -0,0 +1,79 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class AbbauDat extends StatefulWidget { + final DateTime? initAbbauDat; + final Function(DateTime) onDateChanged; + + const AbbauDat({super.key, required this.initAbbauDat, required this.onDateChanged}); + + @override + State createState() => _AbbauDatState(); +} + +class _AbbauDatState extends State { + DateTime? abbauDat; + + @override + void initState() { + super.initState(); + abbauDat = widget.initAbbauDat; + } + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Column(children: [ + SizedBox( + width: 140, + child: ElevatedButton( + onPressed: () async { + final date = await pickDate(); + if (date == null) return; + setState(() => abbauDat = date); + widget.onDateChanged(date); + }, + child: Text(AppLocalizations.of(context)!.pickabbaudat)), + ), + Row( + children: [ + const SizedBox( + width: 10, + ), + Builder(builder: (context) { + if (abbauDat != null) { + return Text( + '${abbauDat?.day}. ${abbauDat?.month}. ${abbauDat?.year}'); + } else { + return Text(AppLocalizations.of(context)!.nichts); + } + }), + const SizedBox( + width: 10, + ), + ElevatedButton( + onPressed: () { + setState(() { + abbauDat = null; + }); + }, + child: const Text("X")) + ]), + ], + ) + ], + ); + } + + Future pickDate() async { + final date = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(5000)); + if (date == null) return null; + + return date; + } +} diff --git a/lib/screens/addCam/widgets/foto_film.dart b/lib/screens/addCam/widgets/foto_film.dart new file mode 100644 index 0000000..ae3765e --- /dev/null +++ b/lib/screens/addCam/widgets/foto_film.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class FotoFilm extends StatefulWidget { + final Function(String) onFotoFilmChanged; + final String initialFotoFilm; + + const FotoFilm( + {super.key, + required this.onFotoFilmChanged, + this.initialFotoFilm = 'foto'}); + + @override + State createState() => _FotoFilmState(); +} + +class _FotoFilmState extends State { + String? _selectedFotoFilm; + + @override + void initState() { + super.initState(); + _selectedFotoFilm = widget.initialFotoFilm; + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.foto), + leading: Radio( + value: 'Foto', + groupValue: _selectedFotoFilm, + onChanged: (value) { + setState(() { + _selectedFotoFilm = value; + widget.onFotoFilmChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.film), + leading: Radio( + value: 'Film', + groupValue: _selectedFotoFilm, + onChanged: (value) { + setState(() { + _selectedFotoFilm = value; + widget.onFotoFilmChanged(value!); + }); + }, + ), + ), + ], + ); + } +} diff --git a/lib/screens/addCam/widgets/karte.dart b/lib/screens/addCam/widgets/karte.dart new file mode 100644 index 0000000..ff03122 --- /dev/null +++ b/lib/screens/addCam/widgets/karte.dart @@ -0,0 +1,111 @@ +import 'package:fforte/screens/helper/snack_bar_helper.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_map/flutter_map.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:latlong2/latlong.dart'; +import 'package:geocoding/geocoding.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class Karte extends StatefulWidget { + final TextEditingController beiOrtC; + final TextEditingController ortInfoC; + final TextEditingController decLngC; + final TextEditingController decLatC; + final Position currentPosition; + + const Karte( + {super.key, + required this.currentPosition, + required this.beiOrtC, + required this.ortInfoC, + required this.decLngC, + required this.decLatC}); + + @override + KarteState createState() => KarteState(); +} + +class KarteState extends State { + Marker? currentMarker; + bool saveVisible = false; + + @override + void initState() { + super.initState(); + currentMarker = Marker( + point: LatLng( + widget.currentPosition.latitude, widget.currentPosition.longitude), + child: const Icon( + Icons.location_on, + color: Colors.red, + )); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(AppLocalizations.of(context)!.map), + actions: [ + Visibility( + visible: saveVisible, + child: Row( + children: [ + Text(AppLocalizations.of(context)!.saveMap), + TextButton( + onPressed: () async { + if (currentMarker != null) { + setState(() { + widget.decLatC.text = + currentMarker!.point.latitude.toString(); + widget.decLngC.text = + currentMarker!.point.longitude.toString(); + }); + } + if (context.mounted) Navigator.pop(context); + }, + child: const Icon(Icons.save), + ), + ], + ), + ), + ], + ), + body: FlutterMap( + mapController: MapController(), + options: MapOptions( + interactionOptions: const InteractionOptions( + flags: InteractiveFlag.pinchZoom | + InteractiveFlag.drag | + InteractiveFlag.pinchMove), + initialCenter: LatLng(widget.currentPosition.latitude, + widget.currentPosition.longitude), + initialZoom: 16.0, + onTap: _handleTap, + ), + children: [ + TileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + userAgentPackageName: 'com.example.app', + ), + MarkerLayer(markers: currentMarker != null ? [currentMarker!] : []), + ]), + ); + } + + _handleTap(TapPosition position, LatLng latlng) { + setState(() { + currentMarker = Marker( + width: 80.0, + height: 80.0, + point: latlng, + child: const Icon( + Icons.location_on, + color: Colors.red, + ), + ); + saveVisible = true; + }); + } +} + diff --git a/lib/screens/addCam/widgets/kont_dat.dart b/lib/screens/addCam/widgets/kont_dat.dart new file mode 100644 index 0000000..bb97eba --- /dev/null +++ b/lib/screens/addCam/widgets/kont_dat.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class KontDat extends StatefulWidget { + final DateTime? initKontDat; + final Function(DateTime) onDateChanged; + + const KontDat( + {super.key, required this.initKontDat, required this.onDateChanged}); + + @override + State createState() => _KontDatState(); +} + +class _KontDatState extends State { + DateTime? kontDat; + + @override + void initState() { + super.initState(); + kontDat = widget.initKontDat; + } + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Row(children: [ + SizedBox( + width: 140, + child: ElevatedButton( + onPressed: () async { + final date = await pickDate(); + if (date == null) return; + setState(() { + kontDat = date; + }); + widget.onDateChanged(date); + }, + child: Text(AppLocalizations.of(context)!.pickkontdat)), + ), + const SizedBox( + width: 10, + ), + Text( + '${kontDat?.day}. ${kontDat?.month}. ${kontDat?.year}', + ), + ]), + ], + ); + } + + Future pickDate() async { + final date = await showDatePicker( + context: context, + initialDate: kontDat ?? DateTime.now(), + firstDate: DateTime(2000), + lastDate: DateTime(5000)); + + return date; + } +} diff --git a/lib/screens/addCam/widgets/mez.dart b/lib/screens/addCam/widgets/mez.dart new file mode 100644 index 0000000..b0bd63d --- /dev/null +++ b/lib/screens/addCam/widgets/mez.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class MEZ extends StatefulWidget { + final Function(String) onMEZChanged; + final String initialMEZ; + + const MEZ( + {super.key, required this.onMEZChanged, this.initialMEZ = 'sommerzeit'}); + + @override + State createState() => _MEZState(); +} + +class _MEZState extends State { + String? _selectedMEZ; + + @override + void initState() { + super.initState(); + _selectedMEZ = widget.initialMEZ; + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.sommerzeit), + leading: Radio( + value: 'Sommerzeit', + groupValue: _selectedMEZ, + onChanged: (value) { + setState(() { + _selectedMEZ = value; + widget.onMEZChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.winterzeit), + leading: Radio( + value: 'Winterzeit', + groupValue: _selectedMEZ, + onChanged: (value) { + setState(() { + _selectedMEZ = value; + widget.onMEZChanged(value!); + }); + }, + ), + ), + ], + ); + } +} diff --git a/lib/screens/addCam/widgets/platzung.dart b/lib/screens/addCam/widgets/platzung.dart new file mode 100644 index 0000000..af4aed0 --- /dev/null +++ b/lib/screens/addCam/widgets/platzung.dart @@ -0,0 +1,134 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class Platzung extends StatefulWidget { + final Function(String) onPlatzungChanged; + final String? initialPlatzung; + + const Platzung({ + super.key, + required this.onPlatzungChanged, + this.initialPlatzung, + }); + + @override + State createState() => _PlatzungState(); +} + +class _PlatzungState extends State { + String? _selectedPlatzung; + + @override + void initState() { + super.initState(); + if (widget.initialPlatzung != "") { + _selectedPlatzung = widget.initialPlatzung; + } + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.kirrung), + leading: Radio( + value: 'Kirrung', + groupValue: _selectedPlatzung, + onChanged: (value) { + setState(() { + _selectedPlatzung = value; + widget.onPlatzungChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.wasserstelle), + leading: Radio( + value: 'Wasserstelle', + groupValue: _selectedPlatzung, + onChanged: (value) { + setState(() { + _selectedPlatzung = value; + widget.onPlatzungChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.wald), + leading: Radio( + value: 'Wald', + groupValue: _selectedPlatzung, + onChanged: (value) { + setState(() { + _selectedPlatzung = value; + widget.onPlatzungChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.wildwechsel), + leading: Radio( + value: 'Wildwechsel', + groupValue: _selectedPlatzung, + onChanged: (value) { + setState(() { + _selectedPlatzung = value; + widget.onPlatzungChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.wegstrasse), + leading: Radio( + value: 'Weg/Straße', + groupValue: _selectedPlatzung, + onChanged: (value) { + setState(() { + _selectedPlatzung = value; + widget.onPlatzungChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.hofgarten), + leading: Radio( + value: 'Hof/Garten', + groupValue: _selectedPlatzung, + onChanged: (value) { + setState(() { + _selectedPlatzung = value; + widget.onPlatzungChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.wiesefeld), + leading: Radio( + value: 'Wiese/Feld/Offenfläche', + groupValue: _selectedPlatzung, + onChanged: (value) { + setState(() { + _selectedPlatzung = value; + widget.onPlatzungChanged(value!); + }); + }, + ), + ), + ], + ); + } +} diff --git a/lib/screens/addCam/widgets/status.dart b/lib/screens/addCam/widgets/status.dart new file mode 100644 index 0000000..b559671 --- /dev/null +++ b/lib/screens/addCam/widgets/status.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +class Status extends StatefulWidget { + final Function(String) onStatusChanged; + final String initialStatus; + + const Status( + {super.key, required this.onStatusChanged, this.initialStatus = 'Aktiv'}); + + @override + State createState() => _StatusState(); +} + +class _StatusState extends State { + String? _selectedStatus; + + @override + void initState() { + super.initState(); + _selectedStatus = widget.initialStatus; + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.aktiv), + leading: Radio( + value: 'aktiv', + groupValue: _selectedStatus, + onChanged: (value) { + setState(() { + _selectedStatus = value; + widget.onStatusChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.inaktiv), + leading: Radio( + value: 'inaktiv', + groupValue: _selectedStatus, + onChanged: (value) { + setState(() { + _selectedStatus = value; + widget.onStatusChanged(value!); + }); + }, + ), + ), + ], + ); + } +} diff --git a/lib/screens/addCam/widgets/sttyp.dart b/lib/screens/addCam/widgets/sttyp.dart new file mode 100644 index 0000000..1c558f4 --- /dev/null +++ b/lib/screens/addCam/widgets/sttyp.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class STTyp extends StatefulWidget { + final Function(String) onSTTypChanged; + final String initialSTTyp; + + const STTyp( + {super.key, + required this.onSTTypChanged, + this.initialSTTyp = 'opportunistisch'}); + + @override + State createState() => _STTypState(); +} + +class _STTypState extends State { + String? _selectedSTTyp; + + @override + void initState() { + super.initState(); + _selectedSTTyp = widget.initialSTTyp; + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.opportunistisch), + leading: Radio( + value: 'opportunistisch', + groupValue: _selectedSTTyp, + onChanged: (value) { + setState(() { + _selectedSTTyp = value; + widget.onSTTypChanged(value!); + }); + }, + ), + ), + ListTile( + visualDensity: const VisualDensity(vertical: -4), + title: Text(AppLocalizations.of(context)!.systematisch), + leading: Radio( + value: 'systematisch', + groupValue: _selectedSTTyp, + onChanged: (value) { + setState(() { + _selectedSTTyp = value; + widget.onSTTypChanged(value!); + }); + }, + ), + ), + ], + ); + } +} diff --git a/time.txt b/time.txt index 78228f0..f15c57a 100644 --- a/time.txt +++ b/time.txt @@ -78,3 +78,4 @@ 6. mai 2h 15min 7. mai 2h 45min 9. mai 3h 40min +10.mai 2h