Float detail tabs at the bottom of the split detail pane and keep its bars below the status bar
This commit is contained in:
@@ -165,25 +165,34 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
split: split,
|
||||
bar: _segmentedBar(spec, details.label),
|
||||
);
|
||||
// The scaffolds below swap the system insets for their bars'
|
||||
// heights; panes beside a list read the real ones from here.
|
||||
final system = MediaQuery.paddingOf(context);
|
||||
if (widget.cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: topBar,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: FloatingBarOverlay(
|
||||
bar: bar,
|
||||
child: _destinationStack(contents, index),
|
||||
return ShellSystemInsets(
|
||||
padding: system,
|
||||
child: CupertinoPageScaffold(
|
||||
navigationBar: topBar,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: FloatingBarOverlay(
|
||||
bar: bar,
|
||||
child: _destinationStack(contents, index),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: topBar,
|
||||
body: _destinationStack(contents, index),
|
||||
extendBody: true,
|
||||
bottomNavigationBar: bar,
|
||||
return ShellSystemInsets(
|
||||
padding: system,
|
||||
child: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: topBar,
|
||||
body: _destinationStack(contents, index),
|
||||
extendBody: true,
|
||||
bottomNavigationBar: bar,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -36,6 +36,33 @@ double listDetailBodyWidth(double window, double available) {
|
||||
double listDetailListWidth(double window, double available) =>
|
||||
math.max(0, available - 1 - listDetailBodyWidth(window, available));
|
||||
|
||||
/// The system's own insets (status bar, navigation bar) as the shell saw
|
||||
/// them, before its scaffold replaced them with its bars' heights.
|
||||
///
|
||||
/// A Material [Scaffold] with an app bar and a bottom bar removes the top and
|
||||
/// bottom padding *and* view padding from its body, so a pane beside the list
|
||||
/// cannot recover the status-bar inset from its own [MediaQuery]. The shell
|
||||
/// publishes the insets here; outside a shell the view padding stands in.
|
||||
class ShellSystemInsets extends InheritedWidget {
|
||||
const ShellSystemInsets({
|
||||
super.key,
|
||||
required this.padding,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
final EdgeInsets padding;
|
||||
|
||||
static EdgeInsets of(BuildContext context) =>
|
||||
context
|
||||
.dependOnInheritedWidgetOfExactType<ShellSystemInsets>()
|
||||
?.padding ??
|
||||
MediaQuery.viewPaddingOf(context);
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(ShellSystemInsets oldWidget) =>
|
||||
padding != oldWidget.padding;
|
||||
}
|
||||
|
||||
/// Narrows a shell bar to the list pane while [split] (the tab shows its list
|
||||
/// beside an open item), placing it at the pane's [alignment]; otherwise the
|
||||
/// bar keeps the whole width it is given. The bar keeps its place in the tree
|
||||
@@ -76,8 +103,8 @@ class ListPaneWidth extends StatelessWidget {
|
||||
/// Under the shell, the list keeps the shell's bars (both narrowed to the list
|
||||
/// pane through [ShellPaneSplit], see [ListPaneWidth]) and the open item owns
|
||||
/// the rest of the window: the detail starts at the top edge and reaches the
|
||||
/// bottom edge with only the system insets as its padding, and its own tabs
|
||||
/// float at its top ([PageTabsEdge]).
|
||||
/// bottom edge with only the system insets ([ShellSystemInsets]) as its
|
||||
/// padding, and its own tabs float at its bottom, as on a phone.
|
||||
class ListDetailPanes extends StatelessWidget {
|
||||
const ListDetailPanes({super.key, required this.list, required this.detail});
|
||||
|
||||
@@ -103,19 +130,20 @@ class ListDetailPanes extends StatelessWidget {
|
||||
);
|
||||
Widget body = detail;
|
||||
if (split) {
|
||||
// Beside the list the item is not under the shell's bar: it keeps
|
||||
// only the system's own inset and draws its bar at the top edge.
|
||||
// The shell's destination bar stays over the list pane too, so the
|
||||
// item keeps only the system's bottom inset: its own composer or
|
||||
// controls own the pane's bottom edge.
|
||||
// Beside the list the item is under neither of the shell's bars
|
||||
// (both stay over the list pane): it keeps only the system's own
|
||||
// insets, so its bar sits just below the status bar at the top
|
||||
// edge, and its tabs or composer own the pane's bottom edge,
|
||||
// floating just above the system inset.
|
||||
final system = ShellSystemInsets.of(context);
|
||||
body = MediaQuery(
|
||||
data: media.copyWith(
|
||||
padding: media.padding.copyWith(
|
||||
top: media.viewPadding.top,
|
||||
bottom: media.viewPadding.bottom,
|
||||
top: system.top,
|
||||
bottom: system.bottom,
|
||||
),
|
||||
),
|
||||
child: PageTabsEdge(edge: FloatingBarEdge.top, child: body),
|
||||
child: PageTabsEdge(edge: FloatingBarEdge.bottom, child: body),
|
||||
);
|
||||
}
|
||||
return Row(
|
||||
|
||||
Reference in New Issue
Block a user