Files
fforte/lib/screens/intro_screen.dart
2025-06-03 22:31:55 +02:00

257 lines
10 KiB
Dart

import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:fforte/l10n/app_localizations.dart';
class IntroScreen extends StatefulWidget {
const IntroScreen({super.key});
@override
State<IntroScreen> createState() => _IntroScreenState();
}
class _IntroScreenState extends State<IntroScreen> {
TextEditingController addresse1C = TextEditingController();
TextEditingController bLandC = TextEditingController();
TextEditingController ffApiAddress = TextEditingController();
TextEditingController exApiAddress = TextEditingController();
String selectedFFApiAddress = "Test";
String selectedEXApiAddress = "Test";
String? selectedBLand = "Sachsen";
Future<void> _saveData() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
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') ?? "";
exApiAddress.text = prefs.getString('exkursionenApiAddress') ?? "";
addresse1C.text = prefs.getString('addresse1') ?? "";
bLandC.text = prefs.getString('bLand') ?? "Sachsen";
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('LUPUS'),
),
body: Center(
child: Container(
padding: const EdgeInsets.all(31),
child: Column(
children: [
TextField(
decoration: InputDecoration(
hintText: AppLocalizations.of(context)!.benutzername),
controller: addresse1C,
onChanged: (value) => setState(() {
addresse1C.text = value;
}),
),
const SizedBox(
height: 15,
),
Column(
children: [
Row(
children: [
Expanded(
flex: 4,
child: TextField(
readOnly: true,
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: 15,
),
Row(
children: [
Expanded(
flex: 4,
child: TextField(
decoration: InputDecoration(
hintText:
AppLocalizations.of(context)!.ffApiAddress),
controller: ffApiAddress,
),
),
Expanded(
flex: 1,
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: "...",
child: Text(
AppLocalizations.of(context)!.notest))
],
))
],
),
Row(
children: [
Expanded(
flex: 4,
child: TextField(
decoration: InputDecoration(
hintText:
AppLocalizations.of(context)!.exApiAddress),
controller: exApiAddress,
),
),
Expanded(
flex: 1,
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: "...",
child: Text(
AppLocalizations.of(context)!.notest))
],
))
],
)
],
),
const SizedBox(
height: 15,
),
ElevatedButton(
onPressed: () {
_saveData();
Navigator.pushNamedAndRemoveUntil(
context, '/home', (route) => false);
},
child: Text(AppLocalizations.of(context)!.continueB))
],
),
),
),
);
}
}