let AI comment everything because well... yeah...
This commit is contained in:
@@ -24,9 +24,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Main widget for managing excursion data entry
|
||||
/// Provides a multi-step form interface for recording excursion details
|
||||
class ExcursionMain extends StatefulWidget {
|
||||
/// Whether this is a template excursion
|
||||
final bool isTemplate;
|
||||
/// Whether the excursion data has been sent to the server
|
||||
final bool isSent;
|
||||
/// Existing excursion data for editing
|
||||
final Map<String, dynamic>? existingData;
|
||||
|
||||
const ExcursionMain({
|
||||
@@ -40,9 +45,13 @@ class ExcursionMain extends StatefulWidget {
|
||||
State<ExcursionMain> createState() => _ExcursionMainState();
|
||||
}
|
||||
|
||||
/// State class for the main excursion screen
|
||||
class _ExcursionMainState extends State<ExcursionMain> {
|
||||
/// Current step in the form
|
||||
int currentStep = 0;
|
||||
/// Whether this is a template excursion
|
||||
late bool isTemplate;
|
||||
/// Current GPS position
|
||||
Position currentPosition = Position(
|
||||
longitude: 10.0,
|
||||
latitude: 51.0,
|
||||
@@ -56,12 +65,14 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
headingAccuracy: 0.0,
|
||||
);
|
||||
|
||||
/// Whether to show extended BImA information
|
||||
bool bimaExtended = false;
|
||||
|
||||
// all TextEditingController because its easier
|
||||
/// Map of all form fields and their controllers
|
||||
/// Each field has a controller and required flag
|
||||
Map<String, Map<String, dynamic>> rmap = {
|
||||
"ID": {"controller": TextEditingController(), "required": false},
|
||||
// Step 1
|
||||
// Step 1 - Basic Information
|
||||
"Datum": {"controller": TextEditingController(), "required": false},
|
||||
"Rudel": {"controller": TextEditingController(), "required": false},
|
||||
"Teilnehmer": {"controller": TextEditingController(), "required": false},
|
||||
@@ -76,7 +87,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
"BimaNutzer": {"controller": TextEditingController(), "required": false},
|
||||
"BimaAGV": {"controller": TextEditingController(), "required": false},
|
||||
|
||||
// Step 2
|
||||
// Step 2 - Environmental Conditions and Observations
|
||||
"Weg": {"controller": TextEditingController(), "required": false},
|
||||
"Wetter": {"controller": TextEditingController(), "required": false},
|
||||
"Temperat": {"controller": TextEditingController(), "required": false},
|
||||
@@ -89,7 +100,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
"KmFuProz": {"controller": TextEditingController(), "required": false},
|
||||
"KmRaProz": {"controller": TextEditingController(), "required": false},
|
||||
|
||||
// Spur maybe own step?
|
||||
// Track Findings
|
||||
"SpGut": {"controller": TextEditingController(), "required": false},
|
||||
"SpMittel": {"controller": TextEditingController(), "required": false},
|
||||
"SpSchlecht": {"controller": TextEditingController(), "required": false},
|
||||
@@ -101,6 +112,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
"WelpenAnz": {"controller": TextEditingController(), "required": false},
|
||||
"WpSicher": {"controller": TextEditingController(), "required": false},
|
||||
|
||||
// Sample Counts
|
||||
"LosungGes": {"controller": TextEditingController(), "required": false},
|
||||
"LosungAnz": {"controller": TextEditingController(), "required": false},
|
||||
"LosungGen": {"controller": TextEditingController(), "required": false},
|
||||
@@ -114,7 +126,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
"GenetiKm": {"controller": TextEditingController(), "required": false},
|
||||
"Hinweise": {"controller": TextEditingController(), "required": false},
|
||||
|
||||
// Step 3
|
||||
// Step 3 - Notes and Communication
|
||||
"Bemerk": {"controller": TextEditingController(), "required": false},
|
||||
"IntKomm": {"controller": TextEditingController(), "required": false},
|
||||
"FallNum": {"controller": TextEditingController(), "required": false},
|
||||
@@ -123,6 +135,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// Initialize location services
|
||||
GeolocatorService.deteterminePosition(
|
||||
alwaysOnNeeded: false,
|
||||
).then((result) => currentPosition = result).catchError((error) async {
|
||||
@@ -156,13 +169,14 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
return currentPosition;
|
||||
});
|
||||
|
||||
// Load existing data or set defaults
|
||||
if (widget.existingData?.isNotEmpty ?? false) {
|
||||
for (var key in widget.existingData!.keys) {
|
||||
rmap[key]!["controller"]!.text =
|
||||
widget.existingData?[key].toString() ?? "";
|
||||
}
|
||||
} else {
|
||||
// Set BLand and default values if there is no existing data
|
||||
// Set default state and date
|
||||
SharedPreferences.getInstance().then((prefs) {
|
||||
rmap["BLand"]!["controller"]!.text = prefs.getString('bLand') ?? "";
|
||||
});
|
||||
@@ -178,12 +192,15 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// Dispose all controllers
|
||||
for (String key in rmap.keys) {
|
||||
rmap[key]!["controller"].dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Get all form field values as a map
|
||||
/// @return Map<String, String> Map of field names to values
|
||||
Map<String, String> getFieldsText() {
|
||||
Map<String, String> puff = {};
|
||||
|
||||
@@ -196,12 +213,14 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
/// Build the steps for the form
|
||||
/// @return List<Step> List of form steps
|
||||
List<Step> getSteps() => [
|
||||
Step(
|
||||
title: Text(AppLocalizations.of(context)!.dateandtime),
|
||||
content: Column(
|
||||
children: [
|
||||
// ---------- Date
|
||||
// Date picker
|
||||
Datum(
|
||||
initDatum: DateTime.now(),
|
||||
onDateChanged: (date) {
|
||||
@@ -210,7 +229,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
name: AppLocalizations.of(context)!.date,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Pack
|
||||
// Pack/Group field
|
||||
VarTextField(
|
||||
textController: rmap["Rudel"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.rudel,
|
||||
@@ -219,7 +238,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Participants
|
||||
// Participants field
|
||||
VarTextField(
|
||||
textController: rmap["Teilnehmer"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.teilnehmer,
|
||||
@@ -228,7 +247,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Duration
|
||||
// Duration field
|
||||
VarTextField(
|
||||
textController: rmap["Dauer"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.dauer,
|
||||
@@ -237,13 +256,13 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// ---------- Dog(leash)
|
||||
// Dog and leash selection
|
||||
HundULeine(
|
||||
mHund: rmap["MHund"]!["controller"]!,
|
||||
mLeine: rmap["MLeine"]!["controller"]!,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- State
|
||||
// State field
|
||||
VarTextField(
|
||||
textController: rmap["BLand"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.bland,
|
||||
@@ -252,7 +271,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Country
|
||||
// County field
|
||||
VarTextField(
|
||||
textController: rmap["Lkr"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.lkr,
|
||||
@@ -261,7 +280,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- By State
|
||||
// Nearby location field
|
||||
VarTextField(
|
||||
textController: rmap["BeiOrt"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.beiort,
|
||||
@@ -270,7 +289,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Bima number
|
||||
// BImA information section
|
||||
const Divider(),
|
||||
const SizedBox(height: 10),
|
||||
ClipRRect(
|
||||
@@ -307,7 +326,6 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Bima name
|
||||
VarTextField(
|
||||
textController:
|
||||
rmap["BimaName"]!["controller"]!,
|
||||
@@ -318,7 +336,6 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Bima user
|
||||
BimaNutzer(
|
||||
onBimaNutzerChanged: (value) {
|
||||
setState(() {
|
||||
@@ -328,7 +345,6 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Bima AGV
|
||||
VarTextField(
|
||||
textController: rmap["BimaAGV"]!["controller"]!,
|
||||
localization:
|
||||
@@ -351,7 +367,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
title: Text(AppLocalizations.of(context)!.umstaendeUndAktionen),
|
||||
content: Column(
|
||||
children: [
|
||||
// ---------- Tracking
|
||||
// GPS tracking button
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
// Check for always permission before starting tracking
|
||||
@@ -426,7 +442,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// ---------- Weather
|
||||
// Weather field
|
||||
VarTextField(
|
||||
textController: rmap["Wetter"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.wetter,
|
||||
@@ -435,7 +451,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Temperature
|
||||
// Temperature field
|
||||
VarTextField(
|
||||
textController: rmap["Temperat"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.temperatur,
|
||||
@@ -444,11 +460,11 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// ---------- Last precipitation
|
||||
// Last precipitation selection
|
||||
LetzterNiederschlag(
|
||||
controller: rmap["RegenVor"]!["controller"]!),
|
||||
const SizedBox(height: 20),
|
||||
// ---------- Track conditions
|
||||
// Distance and track conditions
|
||||
StreckeUSpurbedingungen(
|
||||
kmAutoController: rmap["KmAuto"]!["controller"]!,
|
||||
kmFussController: rmap["KmFuss"]!["controller"]!,
|
||||
@@ -459,7 +475,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Divider(),
|
||||
// ---------- Track found
|
||||
// Track findings
|
||||
SpurGefunden(
|
||||
spurFund: rmap["SpurFund"]!["controller"]!,
|
||||
spurLang: rmap["SpurLang"]!["controller"]!,
|
||||
@@ -471,7 +487,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
),
|
||||
const Divider(),
|
||||
const SizedBox(height: 20),
|
||||
// ---------- Counts
|
||||
// Sample counts
|
||||
Anzahlen(
|
||||
losungAnz: rmap["LosungAnz"]!["controller"]!,
|
||||
losungGes: rmap["LosungGes"]!["controller"]!,
|
||||
@@ -486,7 +502,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
const SizedBox(height: 20),
|
||||
const Divider(),
|
||||
const SizedBox(height: 20),
|
||||
// ---------- Clues
|
||||
// Observations section
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
@@ -502,7 +518,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
title: Text(AppLocalizations.of(context)!.intkomm),
|
||||
content: Column(
|
||||
children: [
|
||||
// ---------- Remarks
|
||||
// Remarks field
|
||||
VarTextField(
|
||||
textController: rmap["Bemerk"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.sonstbemerkungen,
|
||||
@@ -511,7 +527,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
dbDesignation: DatabasesEnum.excursion,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
// ---------- Internal communication
|
||||
// Internal communication field
|
||||
VarTextField(
|
||||
textController: rmap["IntKomm"]!["controller"]!,
|
||||
localization: AppLocalizations.of(context)!.intkomm,
|
||||
@@ -583,7 +599,6 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context)!.excursion),
|
||||
actions: [
|
||||
// Text(TrackingService().isTracking ? "Tracking" : "Not tracking")
|
||||
Image.asset(
|
||||
TrackingService().isTracking
|
||||
? "assets/icons/tracking_on.png"
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
// * Widget for tracking various wildlife monitoring quantities
|
||||
// * Features:
|
||||
// * - Tracking of droppings (Losung) counts and samples
|
||||
// * - Urine marking spot counts and samples
|
||||
// * - Estrus blood sample tracking
|
||||
// * - Hair sample tracking
|
||||
// * All fields support genetic sample counting
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
/// Widget for managing counts of various wildlife monitoring samples
|
||||
/// Provides input fields for different types of samples and their genetic subsets
|
||||
class Anzahlen extends StatefulWidget {
|
||||
/// Controller for number of droppings found
|
||||
final TextEditingController losungAnz;
|
||||
/// Controller for number of droppings collected
|
||||
final TextEditingController losungGes;
|
||||
/// Controller for number of genetic samples from droppings
|
||||
final TextEditingController losungGen;
|
||||
/// Controller for number of urine marking spots
|
||||
final TextEditingController urinAnz;
|
||||
/// Controller for number of genetic samples from urine
|
||||
final TextEditingController urinGen;
|
||||
/// Controller for number of estrus blood spots
|
||||
final TextEditingController oestrAnz;
|
||||
/// Controller for number of genetic samples from estrus blood
|
||||
final TextEditingController oestrGen;
|
||||
/// Controller for number of hair samples
|
||||
final TextEditingController haarAnz;
|
||||
/// Controller for number of genetic samples from hair
|
||||
final TextEditingController haarGen;
|
||||
|
||||
const Anzahlen(
|
||||
@@ -28,6 +47,7 @@ class Anzahlen extends StatefulWidget {
|
||||
AnzahlenState createState() => AnzahlenState();
|
||||
}
|
||||
|
||||
/// State class for the quantity tracking widget
|
||||
class AnzahlenState extends State<Anzahlen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -37,6 +57,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
// Droppings count section
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -46,9 +67,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.anzahlLosungen)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -57,9 +76,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
onTap: () => widget.losungAnz.selection = TextSelection(baseOffset: 0, extentOffset: widget.losungAnz.value.text.length),
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Align(
|
||||
@@ -67,9 +84,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.davonEingesammelt)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -78,11 +93,10 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
onTap: () => widget.losungGes.selection = TextSelection(baseOffset: 0, extentOffset: widget.losungGes.value.text.length),
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
// Genetic samples from droppings
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
@@ -94,9 +108,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
AppLocalizations.of(context)!.davonGenetikproben),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -107,9 +119,8 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(
|
||||
height: 40,
|
||||
),
|
||||
const Divider(height: 40),
|
||||
// Urine marking spots section
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -119,9 +130,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
child: Text(AppLocalizations.of(context)!
|
||||
.anzahlUrinMakierstellen)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -130,9 +139,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
onTap: () => widget.urinAnz.selection = TextSelection(baseOffset: 0, extentOffset: widget.urinAnz.value.text.length),
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Align(
|
||||
@@ -140,9 +147,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
child: Text(AppLocalizations.of(context)!
|
||||
.davonGenetikproben)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -151,14 +156,11 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
onTap: () => widget.urinGen.selection = TextSelection(baseOffset: 0, extentOffset: widget.urinGen.value.text.length),
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
const Divider(
|
||||
height: 40,
|
||||
),
|
||||
const Divider(height: 40),
|
||||
// Estrus blood section
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -168,9 +170,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.anzahlOestrusblut)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -179,9 +179,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
onTap: () => widget.oestrAnz.selection = TextSelection(baseOffset: 0, extentOffset: widget.oestrAnz.value.text.length),
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Align(
|
||||
@@ -189,9 +187,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
child: Text(AppLocalizations.of(context)!
|
||||
.davonGenetikproben)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -200,14 +196,11 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
onTap: () => widget.oestrGen.selection = TextSelection(baseOffset: 0, extentOffset: widget.oestrGen.value.text.length),
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
const Divider(
|
||||
height: 40,
|
||||
),
|
||||
const Divider(height: 40),
|
||||
// Hair samples section
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -217,9 +210,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.anzahlHaarproben)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -228,9 +219,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
onTap: () => widget.haarAnz.selection = TextSelection(baseOffset: 0, extentOffset: widget.haarAnz.value.text.length),
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Align(
|
||||
@@ -238,9 +227,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
child: Text(AppLocalizations.of(context)!
|
||||
.davonGenetikproben)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: TextField(
|
||||
@@ -249,9 +236,7 @@ class AnzahlenState extends State<Anzahlen> {
|
||||
onTap: () => widget.haarGen.selection = TextSelection(baseOffset: 0, extentOffset: widget.haarGen.value.text.length),
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
// * Widget for selecting BImA (Bundesanstalt für Immobilienaufgaben) property user type
|
||||
// * Features:
|
||||
// * - Radio button selection for different user categories
|
||||
// * - Localized labels for each user type
|
||||
// * Available user types:
|
||||
// * - Bundeswehr (German Armed Forces)
|
||||
// * - Gaststreitkräfte (Foreign Armed Forces)
|
||||
// * - NNE Bund (Federal non-civil use)
|
||||
// * - Geschäftsliegenschaft/AGV (Commercial property)
|
||||
// * - kein (none)
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
// Bundeswehr
|
||||
// Gastreitkraefte
|
||||
// NNE Bund
|
||||
// Geschaeftsliegenschaft/AGV
|
||||
// kein
|
||||
|
||||
/// Widget for selecting the type of BImA property user
|
||||
/// Used to categorize the property where monitoring takes place
|
||||
class BimaNutzer extends StatefulWidget {
|
||||
/// Callback function when user type selection changes
|
||||
final Function(String) onBimaNutzerChanged;
|
||||
/// Initial user type selection ('Bundeswehr' by default)
|
||||
final String initialStatus;
|
||||
|
||||
const BimaNutzer(
|
||||
@@ -18,7 +27,9 @@ class BimaNutzer extends StatefulWidget {
|
||||
State<BimaNutzer> createState() => _StatusState();
|
||||
}
|
||||
|
||||
/// State class for the BImA user selection widget
|
||||
class _StatusState extends State<BimaNutzer> {
|
||||
/// Currently selected user type
|
||||
String? _selectedStatus;
|
||||
|
||||
@override
|
||||
@@ -31,6 +42,7 @@ class _StatusState extends State<BimaNutzer> {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// German Armed Forces option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.bundeswehr),
|
||||
@@ -45,6 +57,7 @@ class _StatusState extends State<BimaNutzer> {
|
||||
},
|
||||
),
|
||||
),
|
||||
// Foreign Armed Forces option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.gaststreitkraefte),
|
||||
@@ -59,6 +72,7 @@ class _StatusState extends State<BimaNutzer> {
|
||||
},
|
||||
),
|
||||
),
|
||||
// Federal non-civil use option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.nneBund),
|
||||
@@ -73,6 +87,7 @@ class _StatusState extends State<BimaNutzer> {
|
||||
},
|
||||
),
|
||||
),
|
||||
// Commercial property option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.geschaeftsliegenschaftAGV),
|
||||
@@ -87,6 +102,7 @@ class _StatusState extends State<BimaNutzer> {
|
||||
},
|
||||
),
|
||||
),
|
||||
// No user option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.kein),
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
// * Widget for managing wildlife observation hints and indicators
|
||||
// * Features:
|
||||
// * - Checkbox selection for common observation types
|
||||
// * - Custom text input for additional observations
|
||||
// * - Automatic text aggregation of selected items
|
||||
// * Available observation types:
|
||||
// * - Resting places (Liegestelle)
|
||||
// * - Animal carcasses (Wildtierkadaver)
|
||||
// * - Direct sightings (Sichtung)
|
||||
// * - Howling (Heulen)
|
||||
// * - Other observations (Sonstiges)
|
||||
|
||||
import 'package:fforte/enums/databases.dart';
|
||||
import 'package:fforte/screens/sharedWidgets/var_text_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
/// Widget for recording various types of wildlife observations
|
||||
/// Combines predefined categories with custom input options
|
||||
class Hinweise extends StatefulWidget {
|
||||
/// Controller for the combined observation text
|
||||
final TextEditingController hinweise;
|
||||
|
||||
const Hinweise({super.key, required this.hinweise});
|
||||
@@ -11,21 +26,29 @@ class Hinweise extends StatefulWidget {
|
||||
@override
|
||||
State<Hinweise> createState() => _HinweiseState();
|
||||
}
|
||||
class _HinweiseState extends State<Hinweise> {
|
||||
// Vars for Checkboxes
|
||||
late bool liegestelleChecked;
|
||||
late bool kadaverChecked;
|
||||
late bool sichtungChecked;
|
||||
late bool heulenChecked;
|
||||
bool sonstigesChecked = false;
|
||||
|
||||
// for sonstiges textfield
|
||||
/// State class for the observations widget
|
||||
class _HinweiseState extends State<Hinweise> {
|
||||
// Checkbox state variables
|
||||
/// Whether resting place was observed
|
||||
late bool liegestelleChecked;
|
||||
/// Whether animal carcass was found
|
||||
late bool kadaverChecked;
|
||||
/// Whether direct sighting occurred
|
||||
late bool sichtungChecked;
|
||||
/// Whether howling was heard
|
||||
late bool heulenChecked;
|
||||
/// Whether other observations exist
|
||||
bool sonstigesChecked = false;
|
||||
|
||||
/// Controller for additional observations text
|
||||
TextEditingController sonstigesController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sonstigesController.addListener(updateController);
|
||||
|
||||
// Initialize checkboxes based on existing text
|
||||
liegestelleChecked = widget.hinweise.text.contains("Liegestelle") ? true : false;
|
||||
kadaverChecked = widget.hinweise.text.contains("Wildtierkadaver") ? true : false;
|
||||
sichtungChecked = widget.hinweise.text.contains("Sichtung") ? true : false;
|
||||
@@ -33,6 +56,7 @@ class _HinweiseState extends State<Hinweise> {
|
||||
|
||||
bool firstRun = true;
|
||||
|
||||
// Parse existing other observations
|
||||
for (String val in widget.hinweise.text.split(",")) {
|
||||
if (val != "Liegestelle" && val != "Wildtierkadaver" && val != "Sichtung" && val != "Heulen" && val != "") {
|
||||
sonstigesChecked = true;
|
||||
@@ -51,6 +75,8 @@ class _HinweiseState extends State<Hinweise> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Update the main controller text based on selected options
|
||||
/// Combines all checked items and additional text into a comma-separated string
|
||||
void updateController() {
|
||||
Map<String, bool> props = {
|
||||
"Liegestelle": liegestelleChecked,
|
||||
@@ -63,6 +89,7 @@ class _HinweiseState extends State<Hinweise> {
|
||||
|
||||
widget.hinweise.text = "";
|
||||
|
||||
// Build combined text from selected options
|
||||
for (String key in props.keys) {
|
||||
if (!firstRun && props[key]!) {
|
||||
widget.hinweise.text += ",";
|
||||
@@ -74,7 +101,6 @@ class _HinweiseState extends State<Hinweise> {
|
||||
} else if (props[key]!){
|
||||
widget.hinweise.text += key;
|
||||
}
|
||||
|
||||
}
|
||||
debugPrint(widget.hinweise.text);
|
||||
}
|
||||
@@ -83,6 +109,7 @@ class _HinweiseState extends State<Hinweise> {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// Resting place checkbox
|
||||
CheckboxListTile(
|
||||
title: Text(AppLocalizations.of(context)!.liegestelle),
|
||||
value: liegestelleChecked,
|
||||
@@ -90,6 +117,7 @@ class _HinweiseState extends State<Hinweise> {
|
||||
setState(() => liegestelleChecked = value ?? false);
|
||||
updateController();
|
||||
}),
|
||||
// Animal carcass checkbox
|
||||
CheckboxListTile(
|
||||
title: Text(AppLocalizations.of(context)!.wildtierKadaver),
|
||||
value: kadaverChecked,
|
||||
@@ -97,6 +125,7 @@ class _HinweiseState extends State<Hinweise> {
|
||||
setState(() => kadaverChecked = value ?? false);
|
||||
updateController();
|
||||
}),
|
||||
// Direct sighting checkbox
|
||||
CheckboxListTile(
|
||||
title: Text(AppLocalizations.of(context)!.sichtung),
|
||||
value: sichtungChecked,
|
||||
@@ -104,6 +133,7 @@ class _HinweiseState extends State<Hinweise> {
|
||||
setState(() => sichtungChecked = value ?? false);
|
||||
updateController();
|
||||
}),
|
||||
// Howling checkbox
|
||||
CheckboxListTile(
|
||||
title: Text(AppLocalizations.of(context)!.heulen),
|
||||
value: heulenChecked,
|
||||
@@ -111,6 +141,7 @@ class _HinweiseState extends State<Hinweise> {
|
||||
setState(() => heulenChecked = value ?? false);
|
||||
updateController();
|
||||
}),
|
||||
// Other observations checkbox and input field
|
||||
CheckboxListTile(
|
||||
title: Text(AppLocalizations.of(context)!.sonstiges),
|
||||
value: sonstigesChecked,
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
// * Widget for recording presence of dogs and their leash status during excursions
|
||||
// * Features:
|
||||
// * - Dog presence selection (yes/no)
|
||||
// * - Conditional leash status selection
|
||||
// * - State persistence via text controllers
|
||||
// * - Localized labels
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
/// Widget for managing information about dogs during wildlife monitoring
|
||||
/// Tracks both presence of dogs and whether they are leashed
|
||||
class HundULeine extends StatefulWidget {
|
||||
// 1. with dog (ja, bzw name oder nein) 2. with leash
|
||||
// if nothing selected null
|
||||
/// Controller for dog presence status (yes/name or no)
|
||||
final TextEditingController mHund;
|
||||
/// Controller for leash status
|
||||
final TextEditingController mLeine;
|
||||
|
||||
const HundULeine({super.key, required this.mHund, required this.mLeine});
|
||||
@@ -13,13 +22,18 @@ class HundULeine extends StatefulWidget {
|
||||
HundULeineState createState() => HundULeineState();
|
||||
}
|
||||
|
||||
/// State class for the dog and leash selection widget
|
||||
class HundULeineState extends State<HundULeine> {
|
||||
/// Currently selected dog presence value
|
||||
late String _selectedMHundValue;
|
||||
/// Currently selected leash status value
|
||||
late String _selectedMLeineValue;
|
||||
/// Whether to show leash selection options
|
||||
bool visible = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// Initialize dog presence selection
|
||||
if (widget.mHund.text == "") {
|
||||
_selectedMHundValue = "nein";
|
||||
} else {
|
||||
@@ -27,6 +41,7 @@ class HundULeineState extends State<HundULeine> {
|
||||
visible = true;
|
||||
}
|
||||
|
||||
// Initialize leash status selection
|
||||
if (widget.mLeine.text == "") {
|
||||
_selectedMLeineValue = "nein";
|
||||
} else {
|
||||
@@ -36,6 +51,9 @@ class HundULeineState extends State<HundULeine> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
/// Update widget state and controller values when selections change
|
||||
/// @param mHund New dog presence value
|
||||
/// @param mLeine New leash status value
|
||||
void onValueChanged(String mHund, String mLeine) {
|
||||
setState(() {
|
||||
visible = mHund == "ja" ? true : false;
|
||||
@@ -50,10 +68,12 @@ class HundULeineState extends State<HundULeine> {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// Dog presence section header
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(AppLocalizations.of(context)!.mHund),
|
||||
),
|
||||
// Dog presence - Yes option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.ja),
|
||||
@@ -65,6 +85,7 @@ class HundULeineState extends State<HundULeine> {
|
||||
},
|
||||
),
|
||||
),
|
||||
// Dog presence - No option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.nein),
|
||||
@@ -76,19 +97,14 @@ class HundULeineState extends State<HundULeine> {
|
||||
},
|
||||
),
|
||||
),
|
||||
// Conditional leash status section
|
||||
if (visible) ...[
|
||||
// TextField(
|
||||
// controller: controller,
|
||||
// onChanged: (value) {
|
||||
// onValueChanged("ja", _selectedMLeineValue);
|
||||
// },
|
||||
// decoration:
|
||||
// InputDecoration(hintText: AppLocalizations.of(context)!.name),
|
||||
// ),
|
||||
// Leash status section header
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(AppLocalizations.of(context)!.mLeine),
|
||||
),
|
||||
// Leash status - Yes option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.ja),
|
||||
@@ -100,6 +116,7 @@ class HundULeineState extends State<HundULeine> {
|
||||
},
|
||||
),
|
||||
),
|
||||
// Leash status - No option
|
||||
ListTile(
|
||||
visualDensity: const VisualDensity(vertical: -4),
|
||||
title: Text(AppLocalizations.of(context)!.nein),
|
||||
|
||||
@@ -1,7 +1,24 @@
|
||||
// * Widget for selecting the timing of last precipitation
|
||||
// * Features:
|
||||
// * - Dropdown menu for time selection
|
||||
// * - Multiple predefined time ranges
|
||||
// * - Localized time descriptions
|
||||
// * Available time ranges:
|
||||
// * - Currently raining
|
||||
// * - Same morning
|
||||
// * - Last night
|
||||
// * - Previous day/evening
|
||||
// * - 2-3 days ago
|
||||
// * - 4-6 days ago
|
||||
// * - 1 week or more
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
/// Widget for recording when the last precipitation occurred
|
||||
/// Used to track weather conditions during wildlife monitoring
|
||||
class LetzterNiederschlag extends StatefulWidget {
|
||||
/// Controller for storing the selected precipitation timing
|
||||
final TextEditingController controller;
|
||||
|
||||
const LetzterNiederschlag({super.key, required this.controller});
|
||||
@@ -10,11 +27,14 @@ class LetzterNiederschlag extends StatefulWidget {
|
||||
LetzterNiederschlagState createState() => LetzterNiederschlagState();
|
||||
}
|
||||
|
||||
/// State class for the last precipitation selection widget
|
||||
class LetzterNiederschlagState extends State<LetzterNiederschlag> {
|
||||
late String? selectedValue; // Variable für den ausgewählten Wert
|
||||
/// Currently selected precipitation timing value
|
||||
late String? selectedValue;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// Initialize selection from controller
|
||||
if (widget.controller.text == "") {
|
||||
selectedValue = null;
|
||||
} else {
|
||||
@@ -36,30 +56,37 @@ class LetzterNiederschlagState extends State<LetzterNiederschlag> {
|
||||
});
|
||||
},
|
||||
items: [
|
||||
// Currently raining option
|
||||
DropdownMenuItem<String>(
|
||||
value: "aktuell",
|
||||
child: Text(AppLocalizations.of(context)!.aktuell),
|
||||
),
|
||||
// Same morning option
|
||||
DropdownMenuItem<String>(
|
||||
value: "am selben Morgen",
|
||||
child: Text(AppLocalizations.of(context)!.selberMorgen),
|
||||
),
|
||||
// Last night option
|
||||
DropdownMenuItem<String>(
|
||||
value: "in der Nacht",
|
||||
child: Text(AppLocalizations.of(context)!.letzteNacht),
|
||||
),
|
||||
// Previous day/evening option
|
||||
DropdownMenuItem<String>(
|
||||
value: "am Tag oder Abend zuvor",
|
||||
child: Text(AppLocalizations.of(context)!.vortag),
|
||||
),
|
||||
// 2-3 days ago option
|
||||
DropdownMenuItem<String>(
|
||||
value: "vor 2 bis 3 Tagen",
|
||||
child: Text(AppLocalizations.of(context)!.vor23Tagen),
|
||||
),
|
||||
// 4-6 days ago option
|
||||
DropdownMenuItem<String>(
|
||||
value: "vor 4 bis 6 Tagen",
|
||||
child: Text(AppLocalizations.of(context)!.vor46Tagen),
|
||||
),
|
||||
// 1 week or more option
|
||||
DropdownMenuItem<String>(
|
||||
value: ">=1 Woche",
|
||||
child: Text(AppLocalizations.of(context)!.vor1Woche),
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
// * Widget for recording wildlife track findings during excursions
|
||||
// * Features:
|
||||
// * - Track presence recording
|
||||
// * - Track length measurement
|
||||
// * - Animal count estimation
|
||||
// * - Confidence level indication
|
||||
// * - Separate tracking for cubs/pups
|
||||
// * - Nested visibility based on selections
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
/// Widget for managing wildlife track findings and measurements
|
||||
/// Includes options for both adult and cub/pup tracks
|
||||
class SpurGefunden extends StatefulWidget {
|
||||
/// Controller for track presence status
|
||||
final TextEditingController spurFund;
|
||||
/// Controller for total track length
|
||||
final TextEditingController spurLang;
|
||||
/// Controller for estimated number of animals
|
||||
final TextEditingController spurTiere;
|
||||
/// Controller for track identification confidence
|
||||
final TextEditingController spSicher;
|
||||
/// Controller for cub/pup track length
|
||||
final TextEditingController welpenSp;
|
||||
/// Controller for estimated number of cubs/pups
|
||||
final TextEditingController welpenAnz;
|
||||
/// Controller for cub/pup track identification confidence
|
||||
final TextEditingController wpSicher;
|
||||
|
||||
const SpurGefunden({
|
||||
@@ -25,14 +43,20 @@ class SpurGefunden extends StatefulWidget {
|
||||
State<SpurGefunden> createState() => _SpurGefundenState();
|
||||
}
|
||||
|
||||
/// State class for the track findings widget
|
||||
class _SpurGefundenState extends State<SpurGefunden> {
|
||||
/// Whether any tracks were found
|
||||
late bool _spurFundChecked;
|
||||
/// Whether adult track identification is confident
|
||||
bool _spSicher = false;
|
||||
/// Whether cub/pup track identification is confident
|
||||
bool _wpSicher = false;
|
||||
/// Whether cub/pup tracks were found
|
||||
late bool _welpenSpFundChecked;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// Initialize track finding states
|
||||
if (widget.spurFund.text == "") {
|
||||
_spurFundChecked = false;
|
||||
_welpenSpFundChecked = false;
|
||||
@@ -53,6 +77,7 @@ class _SpurGefundenState extends State<SpurGefunden> {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// Track presence checkbox
|
||||
Row(
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.spurGefunden),
|
||||
@@ -65,22 +90,14 @@ class _SpurGefundenState extends State<SpurGefunden> {
|
||||
});
|
||||
},
|
||||
),
|
||||
// Text(AppLocalizations.of(context)!.welpenSpurGefunden),
|
||||
// Checkbox(
|
||||
// value: _welpenSpFundChecked,
|
||||
// onChanged: (val) {
|
||||
// setState(() {
|
||||
// _welpenSpFundChecked = val ?? false;
|
||||
// widget.welpenSp.text = val ?? false ? "WelpenSp" : "";
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
// Track details section (visible when tracks found)
|
||||
Visibility(
|
||||
visible: _spurFundChecked,
|
||||
child: Column(
|
||||
children: [
|
||||
// Total track length input
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -101,7 +118,7 @@ class _SpurGefundenState extends State<SpurGefunden> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// const SizedBox(height: 10),
|
||||
// Estimated animal count input
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -124,6 +141,7 @@ class _SpurGefundenState extends State<SpurGefunden> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Track identification confidence
|
||||
Row(
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.sicher),
|
||||
@@ -139,7 +157,7 @@ class _SpurGefundenState extends State<SpurGefunden> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// const SizedBox(height: 10),
|
||||
// Cub/pup track presence checkbox
|
||||
Row(
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.welpenSpurGefunden),
|
||||
@@ -153,10 +171,12 @@ class _SpurGefundenState extends State<SpurGefunden> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Cub/pup track details section
|
||||
Visibility(
|
||||
visible: _welpenSpFundChecked,
|
||||
child: Column(
|
||||
children: [
|
||||
// Cub/pup track length input
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -179,9 +199,7 @@ class _SpurGefundenState extends State<SpurGefunden> {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// const SizedBox(height: 10),
|
||||
|
||||
// Estimated cub/pup count input
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -204,6 +222,7 @@ class _SpurGefundenState extends State<SpurGefunden> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Cub/pup track identification confidence
|
||||
Row(
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.sicher),
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
// * Widget for recording travel distances and track conditions during excursions
|
||||
// * Features:
|
||||
// * - Distance tracking by transportation mode (car, foot, bicycle)
|
||||
// * - Track condition assessment (good, medium, poor)
|
||||
// * - Automatic validation of total distances
|
||||
// * - Input validation with user feedback
|
||||
|
||||
import 'package:fforte/screens/helper/snack_bar_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
/// Widget for managing travel distances and track conditions
|
||||
/// Tracks both how the distance was covered and the quality of tracks found
|
||||
class StreckeUSpurbedingungen extends StatefulWidget {
|
||||
/// Controller for distance traveled by car
|
||||
final TextEditingController kmAutoController;
|
||||
/// Controller for distance traveled on foot
|
||||
final TextEditingController kmFussController;
|
||||
/// Controller for distance traveled by bicycle
|
||||
final TextEditingController kmRadController;
|
||||
/// Controller for distance with good track conditions
|
||||
final TextEditingController spGutController;
|
||||
/// Controller for distance with medium track conditions
|
||||
final TextEditingController spMittelController;
|
||||
/// Controller for distance with poor track conditions
|
||||
final TextEditingController spSchlechtController;
|
||||
|
||||
const StreckeUSpurbedingungen({
|
||||
@@ -24,6 +39,7 @@ class StreckeUSpurbedingungen extends StatefulWidget {
|
||||
StreckeUSpurbedingungenState createState() => StreckeUSpurbedingungenState();
|
||||
}
|
||||
|
||||
/// State class for the distance and track conditions widget
|
||||
class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
// vars for percent text fields
|
||||
// String carPercent = "0";
|
||||
@@ -44,7 +60,7 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
// widget.kmFussController.addListener(onDistanceTravledUpdated);
|
||||
// widget.kmRadController.addListener(onDistanceTravledUpdated);
|
||||
|
||||
// if one of the values is "" the excursion is edited for the first time. On which value i check here is unnecessarry
|
||||
// Initialize distance values if not set
|
||||
if (widget.kmAutoController.text == "") {
|
||||
widget.kmAutoController.text = "0";
|
||||
widget.kmFussController.text = "0";
|
||||
@@ -56,7 +72,7 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
widget.spMittelController.addListener(onTrackConditionsUpdated);
|
||||
widget.spSchlechtController.addListener(onTrackConditionsUpdated);
|
||||
|
||||
// if one of the values is "" the excursion is edited for the first time. On which value i check here is unnecessarry
|
||||
// Initialize track condition values if not set
|
||||
if (widget.spGutController.text == "") {
|
||||
widget.spGutController.text = "0";
|
||||
widget.spMittelController.text = "0";
|
||||
@@ -87,20 +103,25 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
// }
|
||||
// }
|
||||
|
||||
/// Validate that track condition distances don't exceed total travel distance
|
||||
/// Shows warning if track conditions total is greater than distance traveled
|
||||
void onTrackConditionsUpdated() {
|
||||
try {
|
||||
// Parse track condition distances
|
||||
double kmGood = double.parse(widget.spGutController.text);
|
||||
double kmMiddle = double.parse(widget.spMittelController.text);
|
||||
double kmBad = double.parse(widget.spSchlechtController.text);
|
||||
|
||||
// Parse travel distances
|
||||
double kmAuto = double.parse(widget.kmAutoController.text);
|
||||
double kmFuss = double.parse(widget.kmFussController.text);
|
||||
double kmRad = double.parse(widget.kmRadController.text);
|
||||
|
||||
// Calculate totals
|
||||
double gesConditionsKm = (kmGood + kmMiddle + kmBad);
|
||||
double gesDistanceKm = (kmAuto + kmFuss + kmRad);
|
||||
|
||||
|
||||
// Show warning if track conditions exceed distance
|
||||
if (gesConditionsKm > gesDistanceKm) {
|
||||
SnackBarHelper.showSnackBarMessage(context, AppLocalizations.of(context)!.bedingungenGroesserAlsStrecke);
|
||||
}
|
||||
@@ -115,6 +136,7 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// Travel distance section header
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
@@ -124,8 +146,10 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// Travel distance inputs
|
||||
Row(
|
||||
children: [
|
||||
// Car distance input
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -145,6 +169,7 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
),
|
||||
),
|
||||
|
||||
// Foot distance input
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -164,6 +189,7 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
),
|
||||
),
|
||||
|
||||
// Bicycle distance input
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -189,6 +215,7 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Track conditions section header
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
@@ -198,8 +225,10 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
),
|
||||
const SizedBox(height: 10,),
|
||||
|
||||
// Track condition inputs
|
||||
Row(
|
||||
children: [
|
||||
// Good conditions input
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
@@ -215,6 +244,7 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// Medium conditions input
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
@@ -230,6 +260,7 @@ class StreckeUSpurbedingungenState extends State<StreckeUSpurbedingungen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// Poor conditions input
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
// * Widget for GPS tracking during wildlife monitoring excursions
|
||||
// * Features:
|
||||
// * - Real-time location tracking
|
||||
// * - Track visualization on map
|
||||
// * - Distance calculation
|
||||
// * - Location accuracy monitoring
|
||||
// * - Track recording controls (start/pause/stop)
|
||||
// * - Track data persistence
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
@@ -11,27 +20,40 @@ import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
/// Widget for managing GPS tracking functionality
|
||||
/// Provides map visualization and tracking controls
|
||||
class Tracking extends StatefulWidget {
|
||||
/// Initial position for the tracking session
|
||||
final Position startPosition;
|
||||
/// Controller for storing the tracked path
|
||||
final TextEditingController weg;
|
||||
|
||||
const Tracking({super.key, required this.startPosition, required this.weg});
|
||||
|
||||
@override
|
||||
State<Tracking> createState() => _TrackingState();
|
||||
}
|
||||
|
||||
/// State class for the tracking widget
|
||||
class _TrackingState extends State<Tracking> {
|
||||
/// Service for managing tracking functionality
|
||||
final TrackingService _trackingService = TrackingService();
|
||||
/// Current GPS position
|
||||
Position? currentPosition;
|
||||
/// Controller for the map widget
|
||||
MapController mapController = MapController();
|
||||
/// Subscription for position updates
|
||||
StreamSubscription? _positionSubscription;
|
||||
/// Subscription for tracking statistics updates
|
||||
StreamSubscription? _statsSubscription;
|
||||
/// Current tracking statistics
|
||||
TrackingStats? _currentStats;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Load existing track if available
|
||||
if (widget.weg.text.isNotEmpty) {
|
||||
for (var element in widget.weg.text.split(";")) {
|
||||
List<String> posSplit = element.split(",");
|
||||
@@ -50,24 +72,27 @@ class _TrackingState extends State<Tracking> {
|
||||
|
||||
currentPosition = widget.startPosition;
|
||||
|
||||
// Initialisiere die Statistiken sofort
|
||||
// Initialize tracking statistics
|
||||
setState(() {
|
||||
_currentStats = _trackingService.currentStats;
|
||||
});
|
||||
_trackingService.requestStatsUpdate();
|
||||
|
||||
// Subscribe to position updates
|
||||
_positionSubscription = _trackingService.positionStream$.listen((position) {
|
||||
setState(() {
|
||||
currentPosition = position;
|
||||
});
|
||||
});
|
||||
|
||||
// Subscribe to statistics updates
|
||||
_statsSubscription = _trackingService.statsStream$.listen((stats) {
|
||||
setState(() {
|
||||
_currentStats = stats;
|
||||
});
|
||||
});
|
||||
|
||||
// Check location permissions
|
||||
GeolocatorService.alwaysPositionEnabled().then((value) {
|
||||
if (!value && mounted) {
|
||||
Navigator.of(context).pop();
|
||||
@@ -84,6 +109,9 @@ class _TrackingState extends State<Tracking> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Format distance for display
|
||||
/// @param meters Distance in meters
|
||||
/// @return Formatted distance string with appropriate unit
|
||||
String _formatDistance(double meters) {
|
||||
if (meters >= 1000) {
|
||||
return '${(meters / 1000).toStringAsFixed(2)} km';
|
||||
@@ -99,6 +127,7 @@ class _TrackingState extends State<Tracking> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.tracking),
|
||||
// Display tracking statistics if available
|
||||
if (_currentStats != null)
|
||||
DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.bodySmall!,
|
||||
@@ -125,6 +154,7 @@ class _TrackingState extends State<Tracking> {
|
||||
icon: Icon(Icons.arrow_back_rounded)
|
||||
),
|
||||
actions: [
|
||||
// Delete track button (only when not tracking)
|
||||
if (!_trackingService.isTracking)
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
@@ -140,6 +170,7 @@ class _TrackingState extends State<Tracking> {
|
||||
color: Theme.of(context).colorScheme.errorContainer,
|
||||
),
|
||||
),
|
||||
// Stop tracking button (only when tracking)
|
||||
if (_trackingService.isTracking)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
@@ -149,6 +180,7 @@ class _TrackingState extends State<Tracking> {
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.trackingStop),
|
||||
),
|
||||
// Start/Pause tracking button
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -165,6 +197,7 @@ class _TrackingState extends State<Tracking> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Center on current location button
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
mapController.move(
|
||||
@@ -177,6 +210,7 @@ class _TrackingState extends State<Tracking> {
|
||||
},
|
||||
child: Icon(Icons.my_location),
|
||||
),
|
||||
// Map display
|
||||
body: FlutterMap(
|
||||
mapController: mapController,
|
||||
options: MapOptions(
|
||||
@@ -192,10 +226,12 @@ class _TrackingState extends State<Tracking> {
|
||||
initialZoom: 16.0,
|
||||
),
|
||||
children: [
|
||||
// Base map layer
|
||||
TileLayer(
|
||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
userAgentPackageName: 'de.lupus.apps',
|
||||
),
|
||||
// Track path layer
|
||||
if (_trackingService.pathList.isNotEmpty)
|
||||
PolylineLayer(
|
||||
polylines: [
|
||||
@@ -206,6 +242,7 @@ class _TrackingState extends State<Tracking> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Current position accuracy circle
|
||||
if (currentPosition != null)
|
||||
CircleLayer(
|
||||
circles: [
|
||||
@@ -231,6 +268,7 @@ class _TrackingState extends State<Tracking> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Current location marker
|
||||
CurrentLocationLayer(),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user