Files
pipelines/app/lib/features/settings/settings_section.dart
T
alan 3136e5bb7e Redesign Settings as grouped searchable page
Replace the tabbed Settings flow with a single grouped page that searches and lazily loads server-backed sections. Preserve existing settings behavior while adding inline loading and retry states and updating coverage for the new navigation model.
2026-11-12 02:54:07 +00:00

45 lines
1.4 KiB
Dart

import 'package:flutter/widgets.dart';
/// One headed group of the single Settings page.
///
/// A section is searchable by its [title] and [keywords], listed in the wide
/// layout's jump index, and built on demand when it is [lazy]: a server-backed
/// section shows a skeleton until the page is scrolled near it or a search
/// matches it, so the page never waits for the server.
class SettingsSection {
const SettingsSection({
required this.id,
required this.title,
required this.builder,
this.keywords = '',
this.lazy = false,
});
/// A stable identifier for keys and jump links.
final String id;
/// The heading shown in the index, the skeleton and the group.
final String title;
/// Extra words the search also matches (setting names, descriptions).
final String keywords;
/// Whether this section reads the server and loads only when near or searched.
final bool lazy;
final WidgetBuilder builder;
/// Whether every word of [query] appears in the title or keywords, ignoring
/// case. An empty query matches every section.
bool matches(String query) {
final words = query
.trim()
.toLowerCase()
.split(RegExp(r'\s+'))
.where((word) => word.isNotEmpty);
if (words.isEmpty) return true;
final haystack = '$title $keywords'.toLowerCase();
return words.every(haystack.contains);
}
}