fix(app): float content behind top bars and give each wide pane its own bar row

- Top-bar clearance helpers (withTopBarClearance, withBarClearance,
  SliverTopBarClearance, BelowTopBar, TopBarNotices); shell, DetailPane and
  the runs/pipelines/templates/artifacts/stage definition/filter/usage pages
  drop their top SafeArea and pad their own lists, pinned headers pin at the
  inset.
- Wide windows: the shell bar narrows to the list pane (ShellPaneSplit) and
  the open item's bar shares its row; item tabs float at the pane's top
  (PageTabsEdge) instead of stacking on the shell's tab bar; the floating
  tab pill no longer swells over leftover media padding.
- Pipeline detail is a DetailPane on wide too; Run/Runs move from FABs into
  the bar's actions; name and identity live in the title pill.
- Run detail title pill shows the real title with Run N, pipeline and
  version (the pill links to the pipeline); the body keeps only status,
  actions and notices; standalone detail draws the same segmented bar.
- One Runs tab badge: attention outranks running.
- Tests for content-behind-bar padding and the no-stacking wide layout;
  notes/app-chrome-fixes.md.
This commit is contained in:
2026-10-31 03:36:22 +00:00
parent ea0f22dfc7
commit c6c6dcfe18
49 changed files with 1791 additions and 693 deletions
+156 -37
View File
@@ -19,6 +19,77 @@ EdgeInsetsGeometry withFloatingBarClearance(
EdgeInsetsGeometry padding,
) => padding.add(EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom));
/// [padding] with the top bar's clearance added at the top.
///
/// A page whose top bar floats over its content (a `SegmentedBar` in a
/// scaffold with `extendBodyBehindAppBar`, a `SegmentedBarOverlay`, the
/// shell's bar) reads the bar's height as [MediaQuery.paddingOf] top. Adding
/// it to a list's own padding starts the first item below the bar at rest
/// while scrolled content passes behind the glass pieces. Lists without
/// explicit padding (`ListView`'s default) already do this themselves.
EdgeInsetsGeometry withTopBarClearance(
BuildContext context,
EdgeInsetsGeometry padding,
) => padding.add(EdgeInsets.only(top: MediaQuery.paddingOf(context).top));
/// [padding] with both the top bar's and the floating tab bar's clearance:
/// for a list that scrolls behind a bar at each edge.
EdgeInsetsGeometry withBarClearance(
BuildContext context,
EdgeInsetsGeometry padding,
) {
final media = MediaQuery.paddingOf(context);
return padding.add(EdgeInsets.only(top: media.top, bottom: media.bottom));
}
/// Empty space as tall as the top bar's clearance ([MediaQuery.paddingOf]
/// top), starting a scrolling column so its first item sits below the bar at
/// rest and scrolls behind it.
class TopBarClearance extends StatelessWidget {
const TopBarClearance({super.key});
@override
Widget build(BuildContext context) =>
SizedBox(height: MediaQuery.paddingOf(context).top);
}
/// [TopBarClearance] as the first sliver of a [CustomScrollView]: the first
/// item starts below the bar at rest and scrolls behind it.
///
/// The clearance stays pinned (it paints nothing and takes no taps), so a
/// pinned header further down (`PinnedHeaderSliver`, a sticky section title)
/// pins just below the bar rather than behind it.
class SliverTopBarClearance extends StatelessWidget {
const SliverTopBarClearance({super.key});
@override
Widget build(BuildContext context) =>
const PinnedHeaderSliver(child: TopBarClearance());
}
/// The top bar's height over the content at [context]: where a pinned
/// header must stop so it stays below the bar.
double topBarInset(BuildContext context) => MediaQuery.paddingOf(context).top;
/// Content that cannot scroll behind the top bar (a fixed header, a canvas
/// with its own overlay controls): it starts below the bar, and its subtree no
/// longer sees the bar's height as padding.
class BelowTopBar extends StatelessWidget {
const BelowTopBar({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) => Padding(
padding: EdgeInsets.only(top: MediaQuery.paddingOf(context).top),
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: child,
),
);
}
/// Empty space as tall as the floating bar's clearance
/// ([MediaQuery.paddingOf] bottom), ending a scrolling column so its last item
/// comes clear of the bar at rest.
@@ -39,49 +110,91 @@ class SliverFloatingBarClearance extends StatelessWidget {
const SliverToBoxAdapter(child: FloatingBarClearance());
}
/// Floats [bar] over the bottom of [child], the way a scaffold with
/// `extendBody` floats its bottom bar, for a bar that is not a scaffold's.
/// The edge a page's own floating tab bar sits at.
enum FloatingBarEdge {
/// Above the bottom safe area: a phone page, or a page covering the shell.
bottom,
/// Just below the page's top bar: a detail pane beside a list, where the
/// shell's own tab bar already floats at the bottom.
top,
}
/// Where the pages' own tab bars float in this subtree ([FloatingBarEdge]).
///
/// [child] fills the whole area and scrolls behind the bar; it learns the
/// bar's measured height (bottom safe area and margins included) as its
/// [MediaQuery.paddingOf] bottom, so a list can pad its last item clear of the
/// bar at rest (see [withFloatingBarClearance]). Taps the bar does not take,
/// such as beside a bar narrower than the area, reach [child].
/// A detail pane beside a list says [FloatingBarEdge.top], so an open item's
/// tabs never stack on the shell's tab bar; everywhere else they float at the
/// bottom.
class PageTabsEdge extends InheritedWidget {
const PageTabsEdge({super.key, required this.edge, required super.child});
final FloatingBarEdge edge;
static FloatingBarEdge of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<PageTabsEdge>()?.edge ??
FloatingBarEdge.bottom;
@override
bool updateShouldNotify(PageTabsEdge oldWidget) => edge != oldWidget.edge;
}
/// Floats [bar] over [child] at [edge], the way a scaffold with `extendBody`
/// floats its bottom bar, for a bar that is not a scaffold's.
///
/// [child] fills the whole area and scrolls behind the bar. At the bottom it
/// learns the bar's measured height (bottom safe area and margins included)
/// as its [MediaQuery.paddingOf] bottom, so a list can pad its last item clear
/// of the bar at rest (see [withFloatingBarClearance]). At the top the bar
/// sits below the area's own top inset (the page's top bar) and the content's
/// top padding grows by the bar's height (see [withTopBarClearance]). Taps the
/// bar does not take, such as beside a bar narrower than the area, reach
/// [child].
class FloatingBarOverlay extends StatelessWidget {
const FloatingBarOverlay({super.key, required this.bar, required this.child});
const FloatingBarOverlay({
super.key,
required this.bar,
required this.child,
this.edge = FloatingBarEdge.bottom,
});
final Widget bar;
final Widget child;
final FloatingBarEdge edge;
@override
Widget build(BuildContext context) => CustomMultiChildLayout(
delegate: _OverlayLayout(),
children: [
// Painted first, so the bar draws (and takes taps) above it.
LayoutId(
id: _Slot.content,
child: LayoutBuilder(
builder: (context, constraints) {
final barHeight = constraints is _ContentConstraints
? constraints.barHeight
: 0.0;
final media = MediaQuery.of(context);
return MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(
bottom: barHeight > media.padding.bottom
? barHeight
: media.padding.bottom,
),
),
child: child,
);
},
Widget build(BuildContext context) {
final top = edge == FloatingBarEdge.top;
final inset = top ? MediaQuery.paddingOf(context).top : 0.0;
return CustomMultiChildLayout(
delegate: _OverlayLayout(top: top, inset: inset),
children: [
// Painted first, so the bar draws (and takes taps) above it.
LayoutId(
id: _Slot.content,
child: LayoutBuilder(
builder: (context, constraints) {
final barHeight = constraints is _ContentConstraints
? constraints.barHeight
: 0.0;
final media = MediaQuery.of(context);
final padding = top
? media.padding.copyWith(top: inset + barHeight)
: media.padding.copyWith(
bottom: barHeight > media.padding.bottom
? barHeight
: media.padding.bottom,
);
return MediaQuery(
data: media.copyWith(padding: padding),
child: child,
);
},
),
),
),
LayoutId(id: _Slot.bar, child: bar),
],
);
LayoutId(id: _Slot.bar, child: bar),
],
);
}
}
enum _Slot { content, bar }
@@ -110,6 +223,11 @@ class _ContentConstraints extends BoxConstraints {
}
class _OverlayLayout extends MultiChildLayoutDelegate {
_OverlayLayout({required this.top, required this.inset});
final bool top;
final double inset;
@override
void performLayout(Size size) {
final bar = layoutChild(
@@ -120,7 +238,7 @@ class _OverlayLayout extends MultiChildLayoutDelegate {
maxHeight: size.height,
),
);
positionChild(_Slot.bar, Offset(0, size.height - bar.height));
positionChild(_Slot.bar, Offset(0, top ? inset : size.height - bar.height));
layoutChild(
_Slot.content,
_ContentConstraints(size, barHeight: bar.height),
@@ -129,5 +247,6 @@ class _OverlayLayout extends MultiChildLayoutDelegate {
}
@override
bool shouldRelayout(_OverlayLayout oldDelegate) => false;
bool shouldRelayout(_OverlayLayout oldDelegate) =>
oldDelegate.top != top || oldDelegate.inset != inset;
}
@@ -28,9 +28,15 @@ class FloatingDestinationBar extends StatelessWidget {
required this.currentIndex,
required this.onTap,
required this.items,
this.edge = FloatingBarEdge.bottom,
});
final bool cupertino;
/// The edge the bar floats at. At [FloatingBarEdge.top] (an open item's
/// tabs under its pane's top bar) a wide bar sits at the leading edge, in
/// line with the bar's title, and keeps no bottom safe area.
final FloatingBarEdge edge;
final int currentIndex;
final ValueChanged<int> onTap;
final List<FloatingDestinationItem> items;
@@ -41,8 +47,61 @@ class FloatingDestinationBar extends StatelessWidget {
/// Height of the Cupertino bar inside the pill (the stock bar is 50).
static const double cupertinoHeight = 54;
/// The side margin at [FloatingBarEdge.top], matching the top bar's own.
static const double topMargin = 12;
@override
Widget build(BuildContext context) {
final top = edge == FloatingBarEdge.top;
final margins = 2 * (top ? topMargin : kFloatingBarMargin);
final bar = LayoutBuilder(
builder: (context, constraints) {
// Wide is judged on the space the bar is given, margins included,
// the way the shell and the pages judge their own layouts.
final available = constraints.maxWidth;
final wide = available + margins >= kFloatingBarWideWidth;
final width = wide
? math.min(available, _tabsWidth(context))
: available;
return Align(
// As tall as the pill, so a scaffold or overlay measures the bar
// and not the whole area it may grow into.
heightFactor: 1,
alignment: !wide
? Alignment.bottomCenter
: top
? AlignmentDirectional.topStart
: AlignmentDirectional.bottomEnd,
child: SizedBox(
width: math.max(0, width),
// The insets are handled around the pill. The host bars pad
// themselves by any media padding left over (a page's top bar,
// another floating bar below a pane), which would swell the pill.
child: MediaQuery.removePadding(
context: context,
removeTop: true,
removeBottom: true,
removeLeft: true,
removeRight: true,
child: GlassPill(
cupertino: cupertino,
child: cupertino
? _cupertinoBar(context)
: _materialBar(context),
),
),
),
);
},
);
if (top) {
// Under a top bar: no safe area to keep clear of, only the gap to the
// content below.
return Padding(
padding: const EdgeInsets.fromLTRB(topMargin, 0, topMargin, 8),
child: bar,
);
}
return SafeArea(
top: false,
minimum: const EdgeInsets.fromLTRB(
@@ -51,35 +110,7 @@ class FloatingDestinationBar extends StatelessWidget {
kFloatingBarMargin,
kFloatingBarMargin,
),
child: LayoutBuilder(
builder: (context, constraints) {
// Wide is judged on the space the bar is given, margins included,
// the way the shell and the pages judge their own layouts.
final available = constraints.maxWidth;
final wide =
available + 2 * kFloatingBarMargin >= kFloatingBarWideWidth;
final width = wide
? math.min(available, _tabsWidth(context))
: available;
return Align(
// As tall as the pill, so a scaffold or overlay measures the bar
// and not the whole area it may grow into.
heightFactor: 1,
alignment: wide
? AlignmentDirectional.bottomEnd
: Alignment.bottomCenter,
child: SizedBox(
width: math.max(0, width),
child: GlassPill(
cupertino: cupertino,
child: cupertino
? _cupertinoBar(context)
: _materialBar(context),
),
),
);
},
),
child: bar,
);
}
+47
View File
@@ -0,0 +1,47 @@
import 'package:flutter/widgets.dart';
/// Content that scrolls behind a floating top bar, with optional [notices]
/// (a connection banner, a refused refresh) that stay put above it.
///
/// Without notices [child] reaches the top edge and keeps the bar's height as
/// its [MediaQuery.paddingOf] top, so its list starts below the bar at rest
/// and scrolls behind it. With notices they sit below the bar and [child]
/// below them, no longer seeing the bar's height. [child] keeps its place in
/// the tree either way, so a banner coming or going never remounts it.
class TopBarNotices extends StatelessWidget {
const TopBarNotices({
super.key,
this.notices = const [],
required this.child,
});
final List<Widget> notices;
final Widget child;
@override
Widget build(BuildContext context) {
final media = MediaQuery.of(context);
final inset = media.padding.top;
final shown = notices.isNotEmpty;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: EdgeInsets.only(top: shown ? inset : 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: notices,
),
),
Expanded(
child: MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(top: shown ? 0 : inset),
),
child: child,
),
),
],
);
}
}