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 createState() => _SettingsPageState(); } class _SettingsPageState extends State { 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( 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( 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( 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( 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( value: localizationController.currentLocale.value, dropdownColor: const Color.fromARGB(255, 43, 43, 43), iconEnabledColor: Colors.white, items: const [ DropdownMenuItem( value: Locale('en', 'US'), child: Text('English'), ), DropdownMenuItem( value: Locale('de', 'DE'), child: Text('Deutsch'), ), DropdownMenuItem( value: Locale('fr', 'FR'), child: Text('Français'), ), DropdownMenuItem( 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), ), ), ]), ), ], ), ); } }