feat(app): open Search from the shell over the shared session
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user