feat: archive filter uses the shared project sheet, with search

- the archive page's horizontal project chips become the same project
  scope row as new-session / scheduled tasks / stats: tapping it opens the
  shared project bottomsheet (all projects, chat, every project with its
  icon, path and checkmark) and filters the archive
- the shared project sheet gains a search field over project name and path,
  so a long project list can be narrowed; it shows "no matching projects"
  when nothing matches
- version 0.6.1+601
- archive test covers filtering through the sheet
This commit is contained in:
blumia committed 2026-11-27 12:14:44 +08:00
1 parent a7e4ed8dd7
commit 83e09e8e25
7 files changed
+156 -109

No files matched your search

+40 -5
View File
@@ -103,12 +103,21 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
/// already up by then; only its body shows the spinner.
bool _refreshing = true;
final TextEditingController _searchCtrl = TextEditingController();
String _filter = '';
@override
void initState() {
super.initState();
_refresh();
}
@override
void dispose() {
_searchCtrl.dispose();
super.dispose();
}
Future<void> _refresh() async {
await Future.wait([
widget.app.refreshProjects(),
@@ -132,6 +141,15 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
final chat = widget.selected == AppState.chatTarget;
// A cached list is shown at once; the refresh updates it in place.
final projects = selectableProjects(widget.app);
final query = _filter.trim().toLowerCase();
final visible = query.isEmpty
? projects
: [
for (final project in projects)
if (project.label.toLowerCase().contains(query) ||
project.canonical.toLowerCase().contains(query))
project,
];
final loading = _refreshing && projects.isEmpty;
return Column(
children: [
@@ -155,6 +173,20 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(12, 2, 12, 6),
child: TextField(
controller: _searchCtrl,
onChanged: (value) => setState(() => _filter = value),
decoration: InputDecoration(
hintText: tr('Search projects'),
prefixIcon: const Icon(Icons.search, size: 18),
isDense: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10)),
),
),
),
Expanded(
child: loading
? const Center(
@@ -207,7 +239,7 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
onTap: () =>
Navigator.pop(context, const ProjectChoice.chat()),
),
for (final project in projects)
for (final project in visible)
ListTile(
dense: true,
leading: ProjectIcon(
@@ -224,10 +256,13 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
onTap: () => Navigator.pop(
context, ProjectChoice.project(project)),
),
if (!_refreshing && projects.isEmpty)
const Padding(
padding: EdgeInsets.all(24),
child: AppText('No projects available',
if (!_refreshing && visible.isEmpty)
Padding(
padding: const EdgeInsets.all(24),
child: AppText(
query.isEmpty
? 'No projects available'
: 'No matching projects',
textAlign: TextAlign.center),
),
],