fApp/lib/screens/settings_screen.dart
Flummi 089fe1f8df
All checks were successful
Flutter Schmutter / build (push) Successful in 3m50s
v1.3.2+58
2025-06-16 19:10:00 +02:00

166 lines
6.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:get/get.dart';
import 'package:f0ckapp/controller/media_controller.dart';
import 'package:f0ckapp/controller/localization_controller.dart';
import 'package:f0ckapp/utils/animatedtransition.dart';
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
@override
State<StatefulWidget> createState() => _SettingsPageState();
}
class _SettingsPageState extends State<SettingsPage> {
final MediaController controller = Get.find();
final LocalizationController localizationController = Get.find();
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
floating: false,
pinned: true,
title: Text('settings_title'.tr),
),
SliverList(
delegate: SliverChildListDelegate([
ListTile(
title: Text('settings_numberofcolumns_title'.tr),
trailing: Obx(
() => DropdownButton<int>(
value: controller.crossAxisCount.value,
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
iconEnabledColor: Colors.white,
items: [0, 3, 4, 5].map((int value) {
return DropdownMenuItem<int>(
value: value,
child: Text(
value == 0
? 'auto'
: 'settings_numberofcolumns_columns'.trParams({
'count': value.toString(),
}),
),
);
}).toList(),
onChanged: (int? newValue) async {
if (newValue != null) {
await controller.setCrossAxisCount(newValue);
setState(() {});
}
},
),
),
),
const Divider(),
ListTile(
title: Text('settings_pageanimation_title'.tr),
trailing: Obx(
() => DropdownButton<PageTransition>(
value: controller.transitionType.value,
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
iconEnabledColor: Colors.white,
items: PageTransition.values.map((PageTransition type) {
String label;
switch (type) {
case PageTransition.opacity:
label = 'Opacity';
break;
case PageTransition.scale:
label = 'Scale';
break;
case PageTransition.slide:
label = 'Slide';
break;
case PageTransition.rotate:
label = 'Rotate';
break;
case PageTransition.flip:
label = 'Flip';
break;
}
return DropdownMenuItem<PageTransition>(
value: type,
child: Text(label),
);
}).toList(),
onChanged: (PageTransition? newValue) async {
if (newValue != null) {
await controller.setTransitionType(newValue);
setState(() {});
}
},
),
),
),
const Divider(),
SwitchListTile(
title: Text('settings_drawer_title'.tr),
subtitle: Text('settings_drawer_subtitle'.tr),
value: controller.drawerSwipeEnabled.value,
onChanged: (bool value) async {
await controller.setDrawerSwipeEnabled(value);
setState(() {});
},
),
const Divider(),
ListTile(
title: Text('settings_language'.tr),
trailing: Obx(
() => DropdownButton<Locale>(
value: localizationController.currentLocale.value,
dropdownColor: const Color.fromARGB(255, 43, 43, 43),
iconEnabledColor: Colors.white,
items: const [
DropdownMenuItem<Locale>(
value: Locale('en', 'US'),
child: Text('English'),
),
DropdownMenuItem<Locale>(
value: Locale('de', 'DE'),
child: Text('Deutsch'),
),
DropdownMenuItem<Locale>(
value: Locale('fr', 'FR'),
child: Text('Français'),
),
DropdownMenuItem<Locale>(
value: Locale('nl', 'NL'),
child: Text('Nederlands'),
),
],
onChanged: (Locale? newLocale) async {
if (newLocale != null) {
await localizationController.changeLocale(newLocale);
}
},
),
),
),
const Divider(),
ListTile(
title: Text('settings_cache_title'.tr),
trailing: ElevatedButton(
onPressed: () async {
await DefaultCacheManager().emptyCache();
if (!mounted) return;
Get.snackbar('', 'der Cache wurde geleert.');
},
child: Text('settings_cache_clear_button'.tr),
),
),
]),
),
],
),
);
}
}