Merge pull request #2698 from krille-chan/krille/add-config-search-field

chore: Add config search textfield
This commit is contained in:
Krille-chan 2026-03-13 09:41:05 +01:00 committed by GitHub
commit e68424e1e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,6 +16,8 @@ class ConfigViewer extends StatefulWidget {
} }
class _ConfigViewerState extends State<ConfigViewer> { class _ConfigViewerState extends State<ConfigViewer> {
String _searchQuery = '';
Future<void> _changeSetting( Future<void> _changeSetting(
AppSettings appSetting, AppSettings appSetting,
SharedPreferences store, SharedPreferences store,
@ -56,6 +58,14 @@ class _ConfigViewerState extends State<ConfigViewer> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final normalizedQuery = _searchQuery.trim().toLowerCase();
final filteredSettings = AppSettings.values
.where((setting) {
if (normalizedQuery.isEmpty) return true;
return setting.name.toLowerCase().contains(normalizedQuery);
})
.toList(growable: false);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(L10n.of(context).advancedConfigurations), title: Text(L10n.of(context).advancedConfigurations),
@ -76,12 +86,29 @@ class _ConfigViewerState extends State<ConfigViewer> {
style: TextStyle(color: theme.colorScheme.onErrorContainer), style: TextStyle(color: theme.colorScheme.onErrorContainer),
), ),
), ),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TextField(
onChanged: (value) => setState(() => _searchQuery = value),
decoration: InputDecoration(
hintText: 'Search config key',
prefixIcon: const Icon(Icons.search),
border: const OutlineInputBorder(),
isDense: true,
filled: true,
fillColor: theme.colorScheme.surfaceContainerHighest.withAlpha(
128,
),
),
),
),
const SizedBox(height: 8),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: AppSettings.values.length, itemCount: filteredSettings.length,
itemBuilder: (context, i) { itemBuilder: (context, i) {
final store = Matrix.of(context).store; final store = Matrix.of(context).store;
final appSetting = AppSettings.values[i]; final appSetting = filteredSettings[i];
var value = ''; var value = '';
if (appSetting is AppSettings<String>) { if (appSetting is AppSettings<String>) {
value = appSetting.value; value = appSetting.value;