Add settings page #46

Merged
Henry-Hiles merged 34 commits from settings-page into main 2026-07-17 20:36:42 -04:00
2 changed files with 61 additions and 19 deletions
Showing only changes of commit 1ea5899791 - Show all commits

WIP settings search

Henry Hiles 2026-07-17 00:35:30 -04:00
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -3,11 +3,14 @@ import "package:flutter/material.dart";
class Setting { class Setting {
final String title; final String title;
final String description; final String description;
final Widget Function(String title, String description) builder; final IconData icon;
final Widget Function(String title, String description, IconData icon)
builder;
Setting({ Setting({
required this.title, required this.title,
required this.description, required this.description,
required this.builder, required this.builder,
required this.icon,
}); });
} }

View file

@ -37,27 +37,31 @@ class SettingsPage extends ConsumerWidget {
title: "Theme", title: "Theme",
description: description:
"Toggle between Light Mode, Dark Mode, and System themes.", "Toggle between Light Mode, Dark Mode, and System themes.",
builder: (title, description) => DialogListTile<ThemeMode>( icon: Icons.contrast,
icon: Icon(Icons.contrast), builder: (title, description, icon) =>
title: title, DialogListTile<ThemeMode>(
subtitle: Text(description), icon: Icon(icon),
initialValue: settings.theme, title: title,
options: ThemeMode.values, subtitle: Text(description),
getName: (option) => toBeginningOfSentenceCase(option.name), initialValue: settings.theme,
onChanged: (value) => ref options: ThemeMode.values,
.watch(SettingsController.provider.notifier) getName: (option) =>
.set(settings.copyWith(theme: value)) toBeginningOfSentenceCase(option.name),
.onError(showError), onChanged: (value) => ref
), .watch(SettingsController.provider.notifier)
.set(settings.copyWith(theme: value))
.onError(showError),
),
), ),
Setting( Setting(
title: "Use Dynamic Theme", title: "Use Dynamic Theme",
icon: Icons.palette,
description: description:
"Toggle on or off Dynamic Theme. Only available on Android, Linux, Windows, or MacOS.", "Toggle on or off Dynamic Theme. Only available on Android, Linux, Windows, or MacOS.",
builder: (title, description) => SwitchListTile( builder: (title, description, icon) => SwitchListTile(
title: Text(title), title: Text(title),
subtitle: Text(description), subtitle: Text(description),
secondary: Icon(Icons.palette), secondary: Icon(icon),
value: settings.useDynamicTheming, value: settings.useDynamicTheming,
onChanged: onChanged:
(Platform.isAndroid || (Platform.isAndroid ||
@ -73,12 +77,13 @@ class SettingsPage extends ConsumerWidget {
), ),
Setting( Setting(
title: "Use System Font", title: "Use System Font",
icon: Icons.abc,
description: description:
"Use the system's sans and emoji fonts, instead of Flutter's bundled fonts. Turn this off if you are having issues rendering emoji.", "Use the system's sans and emoji fonts, instead of Flutter's bundled fonts. Turn this off if you are having issues rendering emoji.",
builder: (title, description) => SwitchListTile( builder: (title, description, icon) => SwitchListTile(
title: Text(title), title: Text(title),
subtitle: Text(description), subtitle: Text(description),
secondary: Icon(Icons.abc), secondary: Icon(icon),
value: settings.useSystemFont, value: settings.useSystemFont,
onChanged: (value) => ref onChanged: (value) => ref
.watch(SettingsController.provider.notifier) .watch(SettingsController.provider.notifier)
@ -98,8 +103,40 @@ class SettingsPage extends ConsumerWidget {
final searchBar = SearchAnchor.bar( final searchBar = SearchAnchor.bar(
barHintText: "Search...", barHintText: "Search...",
suggestionsBuilder: (context, controller) { suggestionsBuilder: (context, controller) {
// TODO final categories = buildCategories(Settings());
return []; final query = controller.text.toLowerCase();
final matches = categories.values
.expand((categoryList) => categoryList.asMap().entries)
.expand(
(categoryEntry) => categoryEntry.value.settings
.asMap()
.entries
.where(
(settingEntry) =>
settingEntry.value.title.toLowerCase().contains(
query,
) ||
settingEntry.value.description
.toLowerCase()
.contains(query),
)
.map(
(settingEntry) => (
(categoryEntry.key, settingEntry.key),
settingEntry.value,
),
),
)
.toIList();
return matches.map(
(match) => ListTile(
leading: Icon(match.$2.icon),
title: Text(match.$2.title),
subtitle: Text(match.$2.description),
),
);
}, },
); );
@ -164,6 +201,7 @@ class SettingsPage extends ConsumerWidget {
child: setting.builder( child: setting.builder(
setting.title, setting.title,
setting.description, setting.description,
setting.icon,
), ),
), ),
) )
@ -223,6 +261,7 @@ class SettingsPage extends ConsumerWidget {
child: setting.builder( child: setting.builder(
setting.title, setting.title,
setting.description, setting.description,
setting.icon,
), ),
), ),
) )