feat(app): open Search from the shell over the shared session

This commit is contained in:
2026-10-21 23:42:41 +01:00
parent a897065fec
commit fd380ef2f4
10 changed files with 1215 additions and 14 deletions
+31 -2
View File
@@ -10,6 +10,7 @@ class AdaptiveShell extends StatefulWidget {
this.cupertino = false,
this.destination,
this.onDestinationSelected,
this.onSearch,
});
final Map<AppDestination, WidgetBuilder> destinationBodies;
@@ -20,6 +21,10 @@ class AdaptiveShell extends StatefulWidget {
final AppDestination? destination;
final ValueChanged<AppDestination>? onDestinationSelected;
/// Opens the transient Search page. Null hides the action, so the plain
/// shell tests and compositions without routing keep their tab set only.
final VoidCallback? onSearch;
@override
State<AdaptiveShell> createState() => _AdaptiveShellState();
}
@@ -79,7 +84,20 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
final wide = constraints.maxWidth >= 600;
if (widget.cupertino) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(middle: Text(details.label)),
navigationBar: CupertinoNavigationBar(
middle: Text(details.label),
trailing: widget.onSearch == null
? null
: CupertinoButton(
key: const ValueKey('shell.search'),
padding: EdgeInsets.zero,
onPressed: widget.onSearch,
child: const Icon(
CupertinoIcons.search,
semanticLabel: 'Search',
),
),
),
child: SafeArea(
child: Column(
children: [
@@ -101,7 +119,18 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
);
}
return Scaffold(
appBar: AppBar(title: Text(details.label)),
appBar: AppBar(
title: Text(details.label),
actions: [
if (widget.onSearch != null)
IconButton(
key: const ValueKey('shell.search'),
onPressed: widget.onSearch,
tooltip: 'Search',
icon: const Icon(Icons.search),
),
],
),
body: Row(
children: [
if (wide)