3136e5bb7e
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.
80 lines
2.3 KiB
Dart
80 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'settings_section.dart';
|
|
|
|
/// The Settings search field: filters the sections as the operator types.
|
|
class SettingsSearchField extends StatelessWidget {
|
|
const SettingsSearchField({
|
|
super.key,
|
|
required this.controller,
|
|
required this.onChanged,
|
|
});
|
|
|
|
final TextEditingController controller;
|
|
final ValueChanged<String> onChanged;
|
|
|
|
@override
|
|
Widget build(BuildContext context) =>
|
|
ValueListenableBuilder<TextEditingValue>(
|
|
valueListenable: controller,
|
|
builder: (context, value, _) => TextField(
|
|
key: const ValueKey<String>('settings.search'),
|
|
controller: controller,
|
|
onChanged: onChanged,
|
|
textInputAction: TextInputAction.search,
|
|
decoration: InputDecoration(
|
|
hintText: 'Search settings',
|
|
prefixIcon: const Icon(Icons.search),
|
|
suffixIcon: value.text.isEmpty
|
|
? null
|
|
: IconButton(
|
|
tooltip: 'Clear search',
|
|
icon: const Icon(Icons.close),
|
|
onPressed: () {
|
|
controller.clear();
|
|
onChanged('');
|
|
},
|
|
),
|
|
border: const OutlineInputBorder(),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// The wide layout's slim jump index: one link per visible section.
|
|
class SettingsSectionIndex extends StatelessWidget {
|
|
const SettingsSectionIndex({
|
|
super.key,
|
|
required this.sections,
|
|
required this.onJump,
|
|
});
|
|
|
|
final List<SettingsSection> sections;
|
|
final ValueChanged<String> onJump;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Semantics(
|
|
container: true,
|
|
label: 'Settings sections',
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
for (final section in sections)
|
|
TextButton(
|
|
key: ValueKey<String>('settings.index.${section.id}'),
|
|
onPressed: () => onJump(section.id),
|
|
style: TextButton.styleFrom(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
),
|
|
child: Text(
|
|
section.title,
|
|
textAlign: TextAlign.start,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|