136 lines
4.3 KiB
Dart
136 lines
4.3 KiB
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});
|
|
|
|
@override
|
|
State<IntroScreen> createState() => _IntroScreenState();
|
|
}
|
|
|
|
/// State class for the intro screen
|
|
class _IntroScreenState extends State<IntroScreen> {
|
|
// 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 {
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
// Save user inputs
|
|
await prefs.setString('addresse1', addresse1C.text);
|
|
await prefs.setString('bLand', bLandC.text);
|
|
await prefs.setString('fotofallenApiAddress', ffApiAddress.text);
|
|
await prefs.setString('exkursionenApiAddress', exApiAddress.text);
|
|
|
|
// Mark app as initialized
|
|
await prefs.setBool('isFirstLaunch', false);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
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
|
|
),
|
|
controller: addresse1C,
|
|
onChanged: (value) => setState(() {
|
|
addresse1C.text = value;
|
|
}),
|
|
),
|
|
const SizedBox(height: 15),
|
|
|
|
// Region settings
|
|
Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 4,
|
|
child: TextField(
|
|
readOnly: true,
|
|
controller: bLandC,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 35),
|
|
|
|
// Camera trap API endpoint
|
|
Align(
|
|
alignment: Alignment.bottomLeft,
|
|
child: Text(AppLocalizations.of(context)!.ffApiAddress)
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: TextField(
|
|
controller: ffApiAddress,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
const SizedBox(height: 10),
|
|
|
|
// Excursion API endpoint
|
|
Align(
|
|
alignment: Alignment.bottomLeft,
|
|
child: Text(AppLocalizations.of(context)!.exApiAddress)
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: TextField(
|
|
controller: exApiAddress,
|
|
),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
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)
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|