Add phone bottom navigation bar
Replace the narrow-layout floating destination pill with a full-width Material 3 NavigationBar. Reuse the shell destination model and badge wiring while preserving re-selection callbacks and hiding the bar for keyboard/detail states.
This commit is contained in:
@@ -8,6 +8,7 @@ import 'attention_badge.dart';
|
||||
import 'destination.dart';
|
||||
import 'list_detail.dart';
|
||||
import 'navigation_rail.dart';
|
||||
import 'shell_navigation_bar.dart';
|
||||
import 'shell_rail_scope.dart';
|
||||
import 'list_pane_widths.dart';
|
||||
import 'shell_bar.dart';
|
||||
@@ -149,7 +150,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
// only after the outgoing page has finished its native animation.
|
||||
// Settings is shown as a page of the Pipelines tab: the tab bar keeps
|
||||
// Pipelines selected and the bar offers Back to it.
|
||||
final index = shellTabDestinations.indexOf(shellTabFor(_selected));
|
||||
final page = !shellTabDestinations.contains(_selected);
|
||||
final details = destinationDetails(_selected);
|
||||
final contents = AppDestination.values.map((destination) {
|
||||
@@ -175,23 +175,29 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
// Only the bar shows the registry's state, so a published bar or badge
|
||||
// rebuilds its bar alone; the destinations and scaffold stay as built.
|
||||
_bar.focus = _selected;
|
||||
// One floating glass tab bar at every width: sized to its tabs at the
|
||||
// right edge, near the thumb. Content keeps the whole width and scrolls
|
||||
// behind it, learning the bar's height as its bottom media padding.
|
||||
// A phone (narrower than the list-detail split) gets a full-width Material
|
||||
// NavigationBar at the bottom, with Settings as its last destination. Wider
|
||||
// windows without the rail keep the floating glass tab bar, which the list
|
||||
// beside an open item needs (see below). Content keeps the whole width and
|
||||
// scrolls behind the bar, learning its height as its bottom media padding.
|
||||
// Neither scaffold's structure depends on the width, so resizing never
|
||||
// remounts a destination.
|
||||
//
|
||||
// While the tab shows its list beside an open item the bar moves under
|
||||
// the leading edge of the list pane, so the open item
|
||||
// keeps its whole height: the list clears the bar and the item clears
|
||||
// only the system inset (see ListDetailPanes). The bar keeps its place
|
||||
// in the tree, so a split never replays its entrance.
|
||||
// remounts a destination. Pushed detail routes cover the shell, and a
|
||||
// bar-less spec (a chat workspace) hides the bar.
|
||||
final phone = !showsListBesideDetail(context);
|
||||
final bar = ListenableBuilder(
|
||||
listenable: Listenable.merge([_bar.badges, _bar.bar, _paneWidths]),
|
||||
builder: (context, _) {
|
||||
if (_bar.specFor(_selected)?.hideNavigation ?? false) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
if (phone) {
|
||||
return ShellNavigationBar(
|
||||
selected: _selected,
|
||||
icon: (destination) =>
|
||||
_icon(destination, destinationDetails(destination).icon),
|
||||
onSelected: _select,
|
||||
);
|
||||
}
|
||||
// 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.
|
||||
@@ -203,7 +209,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
alignment: AlignmentDirectional.bottomStart,
|
||||
child: FloatingDestinationBar(
|
||||
showLabels: true,
|
||||
currentIndex: index,
|
||||
currentIndex: shellTabDestinations.indexOf(shellTabFor(_selected)),
|
||||
onTap: (value) => _select(shellTabDestinations[value]),
|
||||
items: _destinationItems(),
|
||||
alignment: split ? AlignmentDirectional.bottomStart : null,
|
||||
|
||||
Reference in New Issue
Block a user