let AI comment everything because well... yeah...
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
// * Settings screen for the LUPUS app
|
||||
// * Allows configuration of:
|
||||
// * - File storage location
|
||||
// * - GPS tracking interval
|
||||
// * All 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 the settings screen
|
||||
class Settings extends StatefulWidget {
|
||||
const Settings({super.key});
|
||||
|
||||
@@ -9,22 +16,28 @@ class Settings extends StatefulWidget {
|
||||
State<Settings> createState() => _SettingsState();
|
||||
}
|
||||
|
||||
// * State class for the settings screen
|
||||
class _SettingsState extends State<Settings> {
|
||||
// Default tracking interval in seconds
|
||||
int _trackingInterval = 60;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadSettings();
|
||||
_loadSettings(); // Load saved settings on start
|
||||
}
|
||||
|
||||
// * Load settings from SharedPreferences
|
||||
Future<void> _loadSettings() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
// Load tracking interval or use default (60 seconds)
|
||||
_trackingInterval = prefs.getInt('trackingInterval') ?? 60;
|
||||
});
|
||||
}
|
||||
|
||||
// * Save new tracking interval
|
||||
// * @param value The new interval in seconds
|
||||
Future<void> _saveTrackingInterval(int value) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt('trackingInterval', value);
|
||||
@@ -33,6 +46,8 @@ class _SettingsState extends State<Settings> {
|
||||
});
|
||||
}
|
||||
|
||||
// * Get configured save directory
|
||||
// * @return The configured directory or empty string
|
||||
Future<String> _getSaveDir() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final String saveDir = prefs.getString('saveDir') ?? "";
|
||||
@@ -42,15 +57,22 @@ class _SettingsState extends State<Settings> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(AppLocalizations.of(context)!.settings),),
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context)!.settings),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context)!.filelocation, style: const TextStyle(fontSize: 20),),
|
||||
// * File location section
|
||||
Text(
|
||||
AppLocalizations.of(context)!.filelocation,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
// Display current save directory
|
||||
FutureBuilder(
|
||||
future: _getSaveDir(),
|
||||
future: _getSaveDir(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return Text(snapshot.data ?? "");
|
||||
@@ -59,15 +81,22 @@ class _SettingsState extends State<Settings> {
|
||||
}
|
||||
}
|
||||
),
|
||||
// Button to open directory selection
|
||||
ElevatedButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {},
|
||||
child: Text(AppLocalizations.of(context)!.open)
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// * Tracking interval section
|
||||
const Text(
|
||||
'Tracking Interval (Sekunden)',
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
// Slider for interval adjustment
|
||||
// - Minimum: 10 seconds
|
||||
// - Maximum: 300 seconds (5 minutes)
|
||||
// - 29 divisions for precise control
|
||||
Slider(
|
||||
value: _trackingInterval.toDouble(),
|
||||
min: 10,
|
||||
@@ -78,6 +107,7 @@ class _SettingsState extends State<Settings> {
|
||||
_saveTrackingInterval(value.round());
|
||||
},
|
||||
),
|
||||
// Display current interval
|
||||
Text('Aktuelles Intervall: $_trackingInterval Sekunden'),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user