extract SettingsDropdownTile for settings dropdowns
This commit is contained in:
@@ -5,6 +5,7 @@ import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../../storage/haptic_settings.dart';
|
||||
import '../../../../theming/app_theme.dart';
|
||||
import '../../../../utils/haptics.dart';
|
||||
import '../widgets/settings_dropdown_tile.dart';
|
||||
|
||||
class AppearanceSection extends StatelessWidget {
|
||||
const AppearanceSection({super.key});
|
||||
@@ -14,57 +15,27 @@ class AppearanceSection extends StatelessWidget {
|
||||
final settings = context.watch<SettingsCubit>();
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.dark_mode_outlined),
|
||||
title: const Text('Farbgebung'),
|
||||
trailing: DropdownButton<ThemeMode>(
|
||||
value: settings.val().appTheme,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
items: ThemeMode.values
|
||||
.map(
|
||||
(e) => DropdownMenuItem<ThemeMode>(
|
||||
value: e,
|
||||
enabled: e != settings.val().appTheme,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(AppTheme.getDisplayOptions(e).icon),
|
||||
const SizedBox(width: 10),
|
||||
Text(AppTheme.getDisplayOptions(e).displayName),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (e) => settings.val(write: true).appTheme = e!,
|
||||
),
|
||||
SettingsDropdownTile<ThemeMode>(
|
||||
icon: Icons.dark_mode_outlined,
|
||||
title: 'Farbgebung',
|
||||
value: settings.val().appTheme,
|
||||
options: ThemeMode.values,
|
||||
optionIcon: (e) => AppTheme.getDisplayOptions(e).icon,
|
||||
optionLabel: (e) => AppTheme.getDisplayOptions(e).displayName,
|
||||
onChanged: (e) => settings.val(write: true).appTheme = e,
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.vibration_outlined),
|
||||
title: const Text('Haptisches Feedback'),
|
||||
trailing: DropdownButton<HapticLevel>(
|
||||
value: settings.val().hapticSettings.level,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
items: HapticLevel.values
|
||||
.map(
|
||||
(e) => DropdownMenuItem<HapticLevel>(
|
||||
value: e,
|
||||
enabled: e != settings.val().hapticSettings.level,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(_hapticIcon(e)),
|
||||
const SizedBox(width: 10),
|
||||
Text(_hapticLabel(e)),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (e) {
|
||||
settings.val(write: true).hapticSettings.level = e!;
|
||||
// Sofortiges Probe-Feedback in der neu gewählten Stufe.
|
||||
Haptics.longPress();
|
||||
},
|
||||
),
|
||||
SettingsDropdownTile<HapticLevel>(
|
||||
icon: Icons.vibration_outlined,
|
||||
title: 'Haptisches Feedback',
|
||||
value: settings.val().hapticSettings.level,
|
||||
options: HapticLevel.values,
|
||||
optionIcon: _hapticIcon,
|
||||
optionLabel: _hapticLabel,
|
||||
onChanged: (e) {
|
||||
settings.val(write: true).hapticSettings.level = e;
|
||||
// Sofortiges Probe-Feedback in der neu gewählten Stufe.
|
||||
Haptics.longPress();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user