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"
|
||||
|
||||
Reference in New Issue
Block a user