Commit 1d2801e
Changed files (3)
lib
components
screens
subsettings
lib/components/settings_widgets.dart
@@ -70,41 +70,43 @@ class SettingsTile extends StatelessWidget {
}
}
-class ColorSelectionSettingsTile extends StatelessWidget {
- final Widget title;
- final ValueChanged<Color>? onMainColorChanged;
- final Color initialColor;
- final Widget? trailing;
- final Widget? description;
- final bool disabled;
-
- const ColorSelectionSettingsTile(
+/// A ListTile that shows a color preview and allows changing it.
+class ColorSelectionListTile extends StatelessWidget {
+ /// Creates a ListTile with a color preview that opens a color picker on tap.
+ const ColorSelectionListTile(
{super.key,
required this.title,
required this.onMainColorChanged,
required this.initialColor,
- this.trailing,
- this.description,
- this.disabled = false});
+ this.subtitle});
+
+ /// The primary label of the list tile.
+ final Widget title;
+
+ /// Additional content displayed below the title.
+ final Widget? subtitle;
+
+ /// Gets called when a color gets successfully picked.
+ final ValueChanged<Color> onMainColorChanged;
+
+ /// Initial color displayed in the preview.
+ final Color initialColor;
@override
Widget build(BuildContext context) {
- return SettingsTile(
+ return ListTile(
+ title: title,
+ subtitle: subtitle,
leading: Container(
- width: 25.0,
- height: 25.0,
decoration: BoxDecoration(
color: initialColor,
shape: BoxShape.circle,
),
+ child: const SizedBox.square(dimension: 24,),
),
- title: title,
- trailing: trailing,
- description: description,
- disabled: disabled,
- onPressed: (context) async {
+ onTap: () async {
final color = await showColorPickerDialog(context, initialColor);
- if (color != null) onMainColorChanged?.call(color);
+ if (color != null) onMainColorChanged(color);
},
);
}
lib/screens/subsettings/export_import_screen.dart
@@ -54,7 +54,8 @@ class ExportImportScreen extends StatelessWidget {
initialValue: settings.exportAfterEveryEntry,
onToggle: (value) {
settings.exportAfterEveryEntry = value;
- }),
+ },
+ ),
DropDownSettingsTile<ExportFormat>(
key: const Key('exportFormat'),
title: Text(localizations.exportFormat),
lib/screens/settings.dart
@@ -66,7 +66,7 @@ class SettingsPage extends StatelessWidget {
if (value != null) settings.themeMode = value;
},
),
- ColorSelectionSettingsTile(
+ ColorSelectionListTile(
key: const Key('accentColor'),
onMainColorChanged: (color) => settings.accentColor = color,
initialColor: settings.accentColor,
@@ -109,17 +109,17 @@ class SettingsPage extends StatelessWidget {
end: 1000,
stepSize: 50,
),
- ColorSelectionSettingsTile(
+ ColorSelectionListTile(
key: const Key('sysColor'),
onMainColorChanged: (color) => settings.sysColor = color,
initialColor: settings.sysColor,
title: Text(localizations.sysColor)),
- ColorSelectionSettingsTile(
+ ColorSelectionListTile(
key: const Key('diaColor'),
onMainColorChanged: (color) => settings.diaColor = color,
initialColor: settings.diaColor,
title: Text(localizations.diaColor)),
- ColorSelectionSettingsTile(
+ ColorSelectionListTile(
key: const Key('pulColor'),
onMainColorChanged: (color) => settings.pulColor = color,
initialColor: settings.pulColor,