let AI comment everything because well... yeah...

This commit is contained in:
Nico
2025-06-06 21:00:32 +02:00
parent 9c84d0c375
commit cc110ac104
44 changed files with 1230 additions and 646 deletions

View File

@@ -1,7 +1,15 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:fforte/l10n/app_localizations.dart';
// * Initial setup screen shown on first app launch
// * Allows users to configure:
// * - Username/Address
// * - Region settings
// * - API endpoints for server communication
// * Settings are persisted using SharedPreferences
import 'package:flutter/material.dart';
import 'package:fforte/l10n/app_localizations.dart';
import 'package:shared_preferences/shared_preferences.dart';
/// Widget for initial app configuration
class IntroScreen extends StatefulWidget {
const IntroScreen({super.key});
@@ -9,65 +17,52 @@ class IntroScreen extends StatefulWidget {
State<IntroScreen> createState() => _IntroScreenState();
}
/// State class for the intro screen
class _IntroScreenState extends State<IntroScreen> {
TextEditingController addresse1C = TextEditingController();
TextEditingController bLandC = TextEditingController();
TextEditingController ffApiAddress = TextEditingController();
TextEditingController exApiAddress = TextEditingController();
String selectedFFApiAddress = "https://data.dbb-wolf.de/app24.php";
String selectedEXApiAddress = "https://data.dbb-wolf.de/api_exkursion.php";
String? selectedBLand = "Sachsen";
// Text controllers for input fields
final TextEditingController addresse1C = TextEditingController();
final TextEditingController bLandC = TextEditingController();
final TextEditingController ffApiAddress = TextEditingController();
final TextEditingController exApiAddress = TextEditingController();
/// Save configuration data to SharedPreferences
Future<void> _saveData() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final SharedPreferences prefs = await SharedPreferences.getInstance();
// Save user inputs
await prefs.setString('addresse1', addresse1C.text);
await prefs.setString('bLand', bLandC.text);
await prefs.setBool('isFirstLaunch', false);
await prefs.setString('fotofallenApiAddress', ffApiAddress.text);
await prefs.setString('exkursionenApiAddress', exApiAddress.text);
}
@override
void initState() {
super.initState();
_loadPrefs();
}
void _loadPrefs() {
Future.delayed(Duration.zero, () async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
ffApiAddress.text = prefs.getString('fotofallenApiAddress') ?? "https://data.dbb-wolf.de/app24.php";
exApiAddress.text = prefs.getString('exkursionenApiAddress') ?? "https://data.dbb-wolf.de/api_exkursion.php";
addresse1C.text = prefs.getString('addresse1') ?? "";
bLandC.text = prefs.getString('bLand') ?? "Sachsen";
});
});
// Mark app as initialized
await prefs.setBool('isFirstLaunch', false);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('LUPUS'),
title: const Text('LUPUS'),
),
body: Center(
child: Container(
padding: const EdgeInsets.all(31),
child: Column(
children: [
// Username/Address input
TextField(
decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.benutzername),
hintText: AppLocalizations.of(context)!.benutzername
),
controller: addresse1C,
onChanged: (value) => setState(() {
addresse1C.text = value;
}),
),
const SizedBox(
height: 15,
),
const SizedBox(height: 15),
// Region settings
Column(
children: [
Row(
@@ -79,193 +74,58 @@ class _IntroScreenState extends State<IntroScreen> {
controller: bLandC,
),
),
// Expanded(
// flex: 1,
// child: PopupMenuButton(
// icon: const Icon(Icons.arrow_drop_down),
// initialValue: selectedBLand,
// onSelected: (value) {
// setState(() {
// selectedBLand = value;
// bLandC.text = value;
// });
// },
// itemBuilder: (context) => const <PopupMenuEntry>[
// PopupMenuItem(
// value: 'Baden-Württemberg',
// child: Text('Baden-Württemberg'),
// ),
// PopupMenuItem(
// value: 'Bayern',
// child: Text('Bayern'),
// ),
// PopupMenuItem(
// value: 'Berlin',
// child: Text('Berlin'),
// ),
// PopupMenuItem(
// value: 'Brandenburg',
// child: Text('Brandenburg'),
// ),
// PopupMenuItem(
// value: 'Bremen',
// child: Text('Bremen'),
// ),
// PopupMenuItem(
// value: 'Hamburg',
// child: Text('Hamburg'),
// ),
// PopupMenuItem(
// value: 'Hessen',
// child: Text('Hessen'),
// ),
// PopupMenuItem(
// value: 'Mecklenburg-Vorpommern',
// child: Text('Mecklenburg-Vorpommern'),
// ),
// PopupMenuItem(
// value: 'Niedersachsen',
// child: Text('Niedersachsen'),
// ),
// PopupMenuItem(
// value: 'Nordrhein-Westfalen',
// child: Text('Nordrhein-Westfalen'),
// ),
// PopupMenuItem(
// value: 'Rheinland-Pfalz',
// child: Text('Rheinland-Pfalz'),
// ),
// PopupMenuItem(
// value: 'Saarland',
// child: Text('Saarland'),
// ),
// PopupMenuItem(
// value: 'Sachsen',
// child: Text('Sachsen'),
// ),
// PopupMenuItem(
// value: 'Sachsen-Anhalt',
// child: Text('Sachsen-Anhalt'),
// ),
// PopupMenuItem(
// value: 'Schleswig-Holstein',
// child: Text('Schleswig-Holstein'),
// ),
// PopupMenuItem(
// value: 'Thüringen',
// child: Text('Thüringen'),
// ),
// ],
// ),
// ),
],
),
const SizedBox(
height: 35,
),
const SizedBox(height: 35),
// Camera trap API endpoint
Align(
alignment: Alignment.bottomLeft,
child: Text(AppLocalizations.of(context)!.ffApiAddress)),
alignment: Alignment.bottomLeft,
child: Text(AppLocalizations.of(context)!.ffApiAddress)
),
Row(
children: [
// Expanded(
// flex: 4,
// child: TextField(
// decoration: InputDecoration(
// hintText:
// AppLocalizations.of(context)!.ffApiAddress),
// controller: ffApiAddress,
// ),
// ),
Expanded(
flex: 1,
child: TextField(
controller: ffApiAddress,
),
// child: PopupMenuButton(
// icon: const Icon(Icons.arrow_drop_down),
// initialValue: selectedFFApiAddress,
// onSelected: (value) {
// setState(() {
// selectedFFApiAddress = value;
// ffApiAddress.text = value;
// });
// },
// itemBuilder: (context) => <PopupMenuEntry>[
// // PopupMenuItem(
// // value:
// // "http://192.168.1.106/www.dbb-wolf.de/data/app24.php",
// // child:
// // Text(AppLocalizations.of(context)!.test)),
// PopupMenuItem(
// value: "https://data.dbb-wolf.de/app24.php",
// child: Text(
// AppLocalizations.of(context)!.notest))
// ],
// ),
//)
)
],
),
const SizedBox(
height: 10,
),
const SizedBox(height: 10),
// Excursion API endpoint
Align(
alignment: Alignment.bottomLeft,
child: Text(AppLocalizations.of(context)!.exApiAddress)),
alignment: Alignment.bottomLeft,
child: Text(AppLocalizations.of(context)!.exApiAddress)
),
Row(
children: [
// Expanded(
// flex: 4,
// child: TextField(
// decoration: InputDecoration(
// hintText:
// AppLocalizations.of(context)!.exApiAddress),
// controller: exApiAddress,
// ),
// ),
Expanded(
flex: 1,
flex: 1,
child: TextField(
controller: exApiAddress,
),
// child: PopupMenuButton(
// icon: const Icon(Icons.arrow_drop_down),
// initialValue: selectedEXApiAddress,
// onSelected: (value) {
// setState(() {
// selectedEXApiAddress = value;
// exApiAddress.text = value;
// });
// },
// itemBuilder: (context) => <PopupMenuEntry>[
// // PopupMenuItem(
// // value:
// // "http://192.168.1.106/www.dbb-wolf.de/data/app24.php",
// // child:
// // Text(AppLocalizations.of(context)!.test)),
// PopupMenuItem(
// value:
// "https://data.dbb-wolf.de/api_exkursion.php",
// child: Text(
// AppLocalizations.of(context)!.notest))
// ],
// )
)
)
],
)
],
),
const SizedBox(
height: 15,
),
const SizedBox(height: 15),
// Continue button - saves settings and goes to home
ElevatedButton(
onPressed: () {
_saveData();
Navigator.pushNamedAndRemoveUntil(
context, '/home', (route) => false);
},
child: Text(AppLocalizations.of(context)!.continueB))
onPressed: () {
_saveData();
Navigator.pushNamedAndRemoveUntil(
context,
'/home',
(route) => false,
);
},
child: Text(AppLocalizations.of(context)!.continueB)
)
],
),
),