Support compact and hidden list panes in the shell

This commit is contained in:
2026-11-06 19:11:28 +00:00
parent c4776657c8
commit 1106adbce2
3 changed files with 51 additions and 12 deletions
+3
View File
@@ -179,6 +179,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
final bar = ListenableBuilder( final bar = ListenableBuilder(
listenable: Listenable.merge([_bar.badges, _bar.bar, _paneWidths]), listenable: Listenable.merge([_bar.badges, _bar.bar, _paneWidths]),
builder: (context, _) { builder: (context, _) {
if (_bar.specFor(_selected)?.hideNavigation ?? false) {
return const SizedBox.shrink();
}
// On a wide window the bar stays under the list column even when no // On a wide window the bar stays under the list column even when no
// item is open (Search, a list alone), so it never jumps sides. A page // item is open (Search, a list alone), so it never jumps sides. A page
// (Settings) has no list column, so its bar stays at the right edge. // (Settings) has no list column, so its bar stays at the right edge.
+43 -12
View File
@@ -95,9 +95,13 @@ class ListDetailPanes extends StatefulWidget {
required this.list, required this.list,
required this.detail, required this.detail,
this.detailIdentity, this.detailIdentity,
this.listWidthOverride,
}); });
final Widget list; final Widget list;
/// Focus layouts may retain the list offstage at zero/compact width.
final double? listWidthOverride;
final Widget detail; final Widget detail;
/// Which item [detail] shows; selecting another item closes any page the /// Which item [detail] shows; selecting another item closes any page the
@@ -135,9 +139,22 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
final window = media.size.width; final window = media.size.width;
final available = constraints.maxWidth; final available = constraints.maxWidth;
final preferred = widths.widthFor(key); final preferred = widths.widthFor(key);
final listWidth = listDetailListWidth(window, available, preferred); final normalWidth = listDetailListWidth(
final bodyWidth = math.max(0.0, available - 1 - listWidth); window,
final bounds = listPaneWidthBounds(window, available); available,
preferred,
);
final listWidth = (widget.listWidthOverride ?? normalWidth)
.clamp(0.0, math.max(0.0, available - kDetailPaneMinWidth))
.toDouble();
final lineWidth = listWidth > 0 ? 1.0 : 0.0;
final bodyWidth = math.max(0.0, available - lineWidth - listWidth);
final retainedWidth = widget.listWidthOverride == null
? listWidth
: math.max(normalWidth, kListPaneMinWidth);
final bounds = widget.listWidthOverride == null
? listPaneWidthBounds(window, available)
: null;
Widget body = widget.detail; Widget body = widget.detail;
if (split) { if (split) {
// Beside the list the item is not under the shell's top bar (it // Beside the list the item is not under the shell's top bar (it
@@ -171,18 +188,32 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
Row( Row(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Expanded( SizedBox(
child: SizedBox.expand( width: listWidth,
key: const ValueKey('list-detail-list'), child: ClipRect(
child: Semantics( child: OverflowBox(
container: true, alignment: AlignmentDirectional.topStart,
explicitChildNodes: true, minWidth: retainedWidth,
identifier: 'list-detail-list', maxWidth: retainedWidth,
child: widget.list, child: ExcludeFocus(
excluding: listWidth == 0,
child: ExcludeSemantics(
excluding: listWidth == 0,
child: SizedBox.expand(
key: const ValueKey('list-detail-list'),
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-list',
child: widget.list,
),
),
),
),
), ),
), ),
), ),
const ListPaneDividerLine(), if (lineWidth > 0) const ListPaneDividerLine(),
SizedBox( SizedBox(
width: bodyWidth, width: bodyWidth,
child: SizedBox.expand( child: SizedBox.expand(
+5
View File
@@ -19,6 +19,7 @@ class ShellBarSpec {
this.onBack, this.onBack,
this.actions = const [], this.actions = const [],
this.barless = false, this.barless = false,
this.hideNavigation = false,
this.titleWidget, this.titleWidget,
this.titleWidgetMaxWidth = double.infinity, this.titleWidgetMaxWidth = double.infinity,
this.backgroundColor, this.backgroundColor,
@@ -52,6 +53,7 @@ class ShellBarSpec {
/// The content draws its own floating bar: a detail page shows no bar of /// The content draws its own floating bar: a detail page shows no bar of
/// its own and lets the content reach the top edge. /// its own and lets the content reach the top edge.
final bool barless; final bool barless;
final bool hideNavigation;
} }
/// The bar contents each tab's open screen has published. /// The bar contents each tab's open screen has published.
@@ -190,6 +192,7 @@ class ShellBar extends StatefulWidget {
this.actions = const [], this.actions = const [],
this.active = true, this.active = true,
this.barless = false, this.barless = false,
this.hideNavigation = false,
this.titleWidget, this.titleWidget,
this.titleWidgetMaxWidth = double.infinity, this.titleWidgetMaxWidth = double.infinity,
this.backgroundColor, this.backgroundColor,
@@ -205,6 +208,7 @@ class ShellBar extends StatefulWidget {
/// See [ShellBarSpec.barless]. /// See [ShellBarSpec.barless].
final bool barless; final bool barless;
final bool hideNavigation;
/// False while the screen is kept mounted but hidden (a list under an open /// False while the screen is kept mounted but hidden (a list under an open
/// detail): it then gives the bar up. /// detail): it then gives the bar up.
@@ -264,6 +268,7 @@ class _ShellBarState extends State<ShellBar> {
onBack: widget.onBack, onBack: widget.onBack,
actions: widget.actions, actions: widget.actions,
barless: widget.barless, barless: widget.barless,
hideNavigation: widget.hideNavigation,
titleWidget: widget.titleWidget, titleWidget: widget.titleWidget,
titleWidgetMaxWidth: widget.titleWidgetMaxWidth, titleWidgetMaxWidth: widget.titleWidgetMaxWidth,
backgroundColor: widget.backgroundColor, backgroundColor: widget.backgroundColor,