Support compact and hidden list panes in the shell
This commit is contained in:
@@ -179,6 +179,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
final bar = ListenableBuilder(
|
||||
listenable: Listenable.merge([_bar.badges, _bar.bar, _paneWidths]),
|
||||
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
|
||||
// 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.
|
||||
|
||||
@@ -95,9 +95,13 @@ class ListDetailPanes extends StatefulWidget {
|
||||
required this.list,
|
||||
required this.detail,
|
||||
this.detailIdentity,
|
||||
this.listWidthOverride,
|
||||
});
|
||||
|
||||
final Widget list;
|
||||
|
||||
/// Focus layouts may retain the list offstage at zero/compact width.
|
||||
final double? listWidthOverride;
|
||||
final Widget detail;
|
||||
|
||||
/// 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 available = constraints.maxWidth;
|
||||
final preferred = widths.widthFor(key);
|
||||
final listWidth = listDetailListWidth(window, available, preferred);
|
||||
final bodyWidth = math.max(0.0, available - 1 - listWidth);
|
||||
final bounds = listPaneWidthBounds(window, available);
|
||||
final normalWidth = listDetailListWidth(
|
||||
window,
|
||||
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;
|
||||
if (split) {
|
||||
// Beside the list the item is not under the shell's top bar (it
|
||||
@@ -171,18 +188,32 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox.expand(
|
||||
key: const ValueKey('list-detail-list'),
|
||||
child: Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
identifier: 'list-detail-list',
|
||||
child: widget.list,
|
||||
SizedBox(
|
||||
width: listWidth,
|
||||
child: ClipRect(
|
||||
child: OverflowBox(
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
minWidth: retainedWidth,
|
||||
maxWidth: retainedWidth,
|
||||
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(
|
||||
width: bodyWidth,
|
||||
child: SizedBox.expand(
|
||||
|
||||
@@ -19,6 +19,7 @@ class ShellBarSpec {
|
||||
this.onBack,
|
||||
this.actions = const [],
|
||||
this.barless = false,
|
||||
this.hideNavigation = false,
|
||||
this.titleWidget,
|
||||
this.titleWidgetMaxWidth = double.infinity,
|
||||
this.backgroundColor,
|
||||
@@ -52,6 +53,7 @@ class ShellBarSpec {
|
||||
/// The content draws its own floating bar: a detail page shows no bar of
|
||||
/// its own and lets the content reach the top edge.
|
||||
final bool barless;
|
||||
final bool hideNavigation;
|
||||
}
|
||||
|
||||
/// The bar contents each tab's open screen has published.
|
||||
@@ -190,6 +192,7 @@ class ShellBar extends StatefulWidget {
|
||||
this.actions = const [],
|
||||
this.active = true,
|
||||
this.barless = false,
|
||||
this.hideNavigation = false,
|
||||
this.titleWidget,
|
||||
this.titleWidgetMaxWidth = double.infinity,
|
||||
this.backgroundColor,
|
||||
@@ -205,6 +208,7 @@ class ShellBar extends StatefulWidget {
|
||||
|
||||
/// See [ShellBarSpec.barless].
|
||||
final bool barless;
|
||||
final bool hideNavigation;
|
||||
|
||||
/// False while the screen is kept mounted but hidden (a list under an open
|
||||
/// detail): it then gives the bar up.
|
||||
@@ -264,6 +268,7 @@ class _ShellBarState extends State<ShellBar> {
|
||||
onBack: widget.onBack,
|
||||
actions: widget.actions,
|
||||
barless: widget.barless,
|
||||
hideNavigation: widget.hideNavigation,
|
||||
titleWidget: widget.titleWidget,
|
||||
titleWidgetMaxWidth: widget.titleWidgetMaxWidth,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
|
||||
Reference in New Issue
Block a user