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 onChanged; @override Widget build(BuildContext context) => ValueListenableBuilder( valueListenable: controller, builder: (context, value, _) => TextField( key: const ValueKey('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 sections; final ValueChanged onJump; @override Widget build(BuildContext context) => Semantics( container: true, label: 'Settings sections', child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: [ for (final section in sections) TextButton( key: ValueKey('settings.index.${section.id}'), onPressed: () => onJump(section.id), style: TextButton.styleFrom( alignment: AlignmentDirectional.centerStart, ), child: Text( section.title, textAlign: TextAlign.start, overflow: TextOverflow.ellipsis, ), ), ], ), ); }