Float glass tab bars everywhere the app has bottom tabs

One floating frosted tab bar (host NavigationBar / CupertinoTabBar in the
shared GlassPill) replaces the NavigationRail, the Cupertino sidebar and the
run detail, stage page and pipeline detail tab strips. Below 600px it spans
the width minus 16px margins; wider it is sized to its tabs at the right edge.
Content keeps the full width, scrolls behind the bar and learns its height as
bottom media padding; lists pad their end clear of it and FABs sit above it.

The bar now sizes itself from its own constraints instead of the screen size,
which fixes the widget_test failure where a MediaQuery without a size gave it
negative width constraints.
This commit is contained in:
2026-10-31 01:50:42 +00:00
parent 5fd42e803e
commit 963adec122
35 changed files with 1197 additions and 702 deletions
+44 -144
View File
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/segmented_bar.dart';
import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/floating_destination_bar.dart';
import 'attention_badge.dart';
import 'destination.dart';
@@ -43,8 +44,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
late AppDestination _selected;
final Set<AppDestination> _visited = {};
final ShellBarRegistry _bar = ShellBarRegistry();
// The Cupertino sidebar and tab layouts have different parents. Preserve
// destination selection/state while the same content moves between them.
// Keeps every destination's state if the stack's parent ever changes.
final GlobalKey _destinationStackKey = GlobalKey();
@override
@@ -82,9 +82,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
});
}
List<T> _items<T>(T Function(AppDestination) build) =>
AppDestination.values.map(build).toList();
/// The destination's icon; only Runs carries the attention count.
Widget _icon(AppDestination destination, IconData data) {
Widget icon = Icon(data);
@@ -137,97 +134,58 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
}).toList();
return ListenableBuilder(
listenable: _bar,
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
final wide = constraints.maxWidth >= 600;
if (widget.cupertino) {
final spec = _bar.specFor(_selected);
return CupertinoPageScaffold(
navigationBar: _segmentedBar(spec, details.label),
child: SafeArea(
child: wide
// The web keeps a destination rail on a wide window. A native
// Cupertino sidebar list is the same idea with the host's own
// controls; the tab bar stays the narrow-window navigation.
? Row(
children: [
_CupertinoSidebar(
selected: _selected,
onSelected: _select,
attentionCount: widget.attentionCount,
),
Expanded(child: _destinationStack(contents, index)),
],
)
: Column(
children: [
Expanded(child: _destinationStack(contents, index)),
// Keep the host's native tab semantics while giving
// the selector the same floating glass treatment as
// the top bar.
MediaQuery.withNoTextScaling(
child: FloatingDestinationBar(
cupertino: true,
currentIndex: index,
onTap: (value) =>
_select(AppDestination.values[value]),
items: _destinationItems(cupertino: true),
),
),
],
),
),
);
}
final spec = _bar.specFor(_selected);
return Scaffold(
extendBodyBehindAppBar: true,
appBar: _segmentedBar(spec, details.label),
// Destinations start below the floating bar.
body: SafeArea(
left: false,
right: false,
builder: (context, _) {
final spec = _bar.specFor(_selected);
// One floating glass tab bar at every width: full width on a phone,
// sized to its tabs at the right edge on a wide window (the bar judges
// that itself, live). Content keeps the whole width and scrolls behind
// it, learning the bar's height as its bottom media padding. Neither
// scaffold's structure depends on the width, so resizing never
// remounts a destination.
final bar = FloatingDestinationBar(
cupertino: widget.cupertino,
currentIndex: index,
onTap: (value) => _select(AppDestination.values[value]),
items: _destinationItems(),
);
if (widget.cupertino) {
return CupertinoPageScaffold(
navigationBar: _segmentedBar(spec, details.label),
child: SafeArea(
bottom: false,
child: Row(
children: [
if (wide)
NavigationRail(
selectedIndex: index,
onDestinationSelected: (value) =>
_select(AppDestination.values[value]),
labelType: NavigationRailLabelType.all,
destinations: _items((destination) {
final item = destinationDetails(destination);
return NavigationRailDestination(
icon: _icon(destination, item.icon),
label: Text(item.label),
);
}),
),
Expanded(child: _destinationStack(contents, index)),
],
child: FloatingBarOverlay(
bar: bar,
child: _destinationStack(contents, index),
),
),
extendBody: true,
bottomNavigationBar: wide
? null
: FloatingDestinationBar(
cupertino: false,
currentIndex: index,
onTap: (value) => _select(AppDestination.values[value]),
items: _destinationItems(),
),
);
},
),
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: _segmentedBar(spec, details.label),
// Destinations start below the floating top bar.
body: SafeArea(
left: false,
right: false,
bottom: false,
child: _destinationStack(contents, index),
),
extendBody: true,
bottomNavigationBar: bar,
);
},
);
}
List<FloatingDestinationItem> _destinationItems({bool cupertino = false}) =>
List<FloatingDestinationItem> _destinationItems() =>
AppDestination.values.map((destination) {
final item = destinationDetails(destination);
return FloatingDestinationItem(
icon: _icon(destination, cupertino ? item.cupertinoIcon : item.icon),
key: ValueKey('shell.destination.${destination.name}'),
icon: _icon(
destination,
widget.cupertino ? item.cupertinoIcon : item.icon,
),
label: item.label,
);
}).toList();
@@ -286,61 +244,3 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
Widget _destinationStack(List<Widget> contents, int index) =>
IndexedStack(key: _destinationStackKey, index: index, children: contents);
}
/// The wide-window Cupertino destination list: the web's 200px rail with the
/// host's own grouped list controls.
class _CupertinoSidebar extends StatelessWidget {
const _CupertinoSidebar({
required this.selected,
required this.onSelected,
this.attentionCount = 0,
});
final AppDestination selected;
final ValueChanged<AppDestination> onSelected;
final int attentionCount;
@override
Widget build(BuildContext context) {
final theme = CupertinoTheme.of(context);
return Container(
width: 200,
decoration: BoxDecoration(
color: CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
context,
),
border: Border(
right: BorderSide(
color: CupertinoColors.separator.resolveFrom(context),
),
),
),
child: ListView(
padding: const EdgeInsets.symmetric(vertical: 8),
children: [
for (final destination in AppDestination.values)
CupertinoListTile(
key: ValueKey('shell.destination.${destination.name}'),
leading: destination == AppDestination.runs
? AttentionDestinationIcon(
count: attentionCount,
cupertino: true,
child: Icon(
destinationDetails(destination).cupertinoIcon,
),
)
: Icon(destinationDetails(destination).cupertinoIcon),
title: Text(destinationDetails(destination).label),
trailing: destination == selected
? Icon(
CupertinoIcons.checkmark_alt,
color: theme.primaryColor,
)
: null,
onTap: () => onSelected(destination),
),
],
),
);
}
}
+5 -2
View File
@@ -143,16 +143,19 @@ class _DetailPaneState extends State<DetailPane> {
title: title,
actions: actions,
);
// The bottom inset (the system's, or a floating tab bar's when the
// pane sits beside a list) passes through: the open item's content
// floats its own tabs above it and pads its lists clear of it.
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: bar,
child: SafeArea(child: body),
child: SafeArea(bottom: false, child: body),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: SafeArea(child: body),
body: SafeArea(bottom: false, child: body),
);
},
);