remove dupe code

This commit is contained in:
Dr.Blank 2025-05-22 07:12:39 +05:30
parent 32e2be4b95
commit 6bd2ebfc10
No known key found for this signature in database
GPG key ID: BA5F87FF0560C57B

View file

@ -32,47 +32,35 @@ class ThemeSettingsPage extends HookConsumerWidget {
// choose system , light or dark theme // choose system , light or dark theme
SettingsTile( SettingsTile(
title: const Text('Theme Mode'), title: const Text('Theme Mode'),
description: Padding( description: SegmentedButton(
padding: const EdgeInsets.only(top: 8.0), expandedInsets: const EdgeInsets.only(top: 8.0),
child: SegmentedButton<ThemeMode>( showSelectedIcon: true,
segments: [ selectedIcon: const Icon(Icons.check),
ButtonSegment<ThemeMode>( selected: {themeSettings.themeMode},
value: ThemeMode.light, onSelectionChanged: (newSelection) {
icon: Icon( ref.read(appSettingsProvider.notifier).update(
themeSettings.themeMode == ThemeMode.light appSettings.copyWith.themeSettings(
? Icons.check themeMode: newSelection.first,
: Icons.light_mode, ),
), );
label: const Text('Light'), },
), segments: [
ButtonSegment<ThemeMode>( ButtonSegment(
value: ThemeMode.system, value: ThemeMode.light,
icon: Icon( icon: Icon(Icons.light_mode),
themeSettings.themeMode == ThemeMode.system label: const Text('Light'),
? Icons.check ),
: Icons.auto_awesome, ButtonSegment(
), value: ThemeMode.system,
label: const Text('System'), icon: Icon(Icons.auto_awesome),
), label: const Text('System'),
ButtonSegment<ThemeMode>( ),
value: ThemeMode.dark, ButtonSegment(
icon: Icon( value: ThemeMode.dark,
themeSettings.themeMode == ThemeMode.dark icon: Icon(Icons.dark_mode),
? Icons.check label: const Text('Dark'),
: Icons.dark_mode, ),
), ],
label: const Text('Dark'),
),
],
selected: {themeSettings.themeMode},
onSelectionChanged: (Set<ThemeMode> newSelection) {
ref.read(appSettingsProvider.notifier).update(
appSettings.copyWith.themeSettings(
themeMode: newSelection.first,
),
);
},
),
), ),
leading: Icon( leading: Icon(
themeSettings.themeMode == ThemeMode.light themeSettings.themeMode == ThemeMode.light