Files
pipelines/app/lib/shell/navigation_rail.dart
T
alan 545291e04a App: run failure reasons, Run again, labelled tabs, actionable errors, nav fixes
- Run rows show a failed run's reason (else its diagnostic's first line,
  full text in a tooltip) or a short result preview; the Summary leads
  with "Why it failed".
- Run again for succeeded/canceled/interrupted runs opens the New run form
  pre-filled (prompt, workspace, report format) at the latest version with
  the original offered.
- Run detail and stage tabs show their names; touch shows captions on the
  Runs header and artifact viewer actions (desktop keeps tooltips).
- ErrorNotice maps not connected / server too old / permission / timeout
  to what to do, raw detail behind Details (Schedules, create chat, Runs,
  Pipelines banners).
- Settings has no Back arrow; Schedules keeps the rail on wide windows;
  phone Settings leads with Connection and Notifications and has a
  Jump to topic menu.
- Walkthrough: Open Connection (skipped when connected), labelled Copy.
- Pluralised counts; no duplicate status/rail names for screen readers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 20:16:22 +00:00

184 lines
6.9 KiB
Dart

import 'package:flutter/material.dart';
import 'destination.dart';
import 'list_detail_policy.dart';
/// The width of the destination rail on a wide window.
const double kNavigationRailWidth = 96;
/// The rail with its divider: what the rail takes from a wide window's width.
const double kNavigationRailSpace = kNavigationRailWidth + 1;
/// The narrowest window that shows the destination rail: the list-detail
/// minimum for the body beside it, plus the rail and its divider (the space the
/// shell takes from the window). Narrower windows keep the floating destination
/// bar, unchanged.
const double kNavigationRailMinWindowWidth =
kListDetailMinWidth + kNavigationRailSpace;
/// The rail's height below which Settings scrolls with the tabs instead of
/// staying pinned to the rail's foot: room for Settings and about two tabs.
const double kNavigationRailPinnedSettingsMinHeight = 240;
/// Whether the window at [context] shows the destination rail. Read from the
/// window's own [MediaQuery], so the shell and the floating windows layer
/// (which sits above the shell) agree.
bool showsNavigationRail(BuildContext context) =>
MediaQuery.sizeOf(context).width >= kNavigationRailMinWindowWidth;
/// Whether the window shows the floating tab bar alone: wide enough for a list
/// beside an open item, too narrow for the rail. That bar lists the tabs only,
/// so there Settings is reached from the Pipelines bar's gear.
bool showsFloatingTabBarOnly(BuildContext context) =>
showsListBesideDetail(context) && !showsNavigationRail(context);
/// The wide layout's left-edge navigation: a Material [NavigationRail] with
/// an icon and a label per tab, the selected tab marked by the rail's
/// indicator, and Settings pinned to its bottom.
///
/// The tabs scroll when the rail is too short for them (a tall terminal
/// panel shrinks the app above it), and on a very short rail Settings
/// scrolls with them, so items never overlap at any height.
///
/// [icon] builds each tab's icon (its running or unread badge included), so
/// the rail shows the same counts the floating bar did. [selected] is the
/// shell's destination: Settings (a page, not a tab) selects no tab but its
/// own item.
class ShellNavigationRail extends StatelessWidget {
const ShellNavigationRail({
super.key,
required this.selected,
required this.icon,
required this.onSelected,
this.padding = EdgeInsets.zero,
});
final AppDestination selected;
final Widget Function(AppDestination destination) icon;
final ValueChanged<AppDestination> onSelected;
/// The system insets the rail keeps clear of: the status bar above and the
/// navigation bar below.
final EdgeInsets padding;
@override
Widget build(BuildContext context) {
final index = shellTabDestinations.indexOf(selected);
final surface = Theme.of(context).colorScheme.surface;
// The surface runs under the top inset too: the padding only moves the
// rail's content below the system's top, so no unpainted strip shows above
// the rail's background.
return ColoredBox(
key: const ValueKey('shell.navigation-rail.surface'),
color: surface,
child: Padding(
padding: padding,
child: SizedBox(
width: kNavigationRailWidth,
child: LayoutBuilder(
builder: (context, constraints) => _rail(
index,
surface,
pinSettings:
constraints.maxHeight >=
kNavigationRailPinnedSettingsMinHeight,
),
),
),
),
);
}
Widget _rail(int index, Color surface, {required bool pinSettings}) =>
NavigationRail(
key: const ValueKey('shell.navigation-rail'),
backgroundColor: surface,
minWidth: kNavigationRailWidth,
labelType: NavigationRailLabelType.all,
selectedIndex: index < 0 ? null : index,
onDestinationSelected: (value) =>
onSelected(shellTabDestinations[value]),
destinations: [
for (final destination in shellTabDestinations)
NavigationRailDestination(
icon: KeyedSubtree(
key: ValueKey('shell.destination.${destination.name}'),
// The bar it replaces named each tab in a tooltip too.
// The destination's label already names it for assistive
// technology; the tooltip must not repeat it.
child: Tooltip(
message: destinationDetails(destination).label,
excludeFromSemantics: true,
child: icon(destination),
),
),
label: Text(destinationDetails(destination).label),
),
],
scrollable: true,
trailingAtBottom: pinSettings,
trailing: _SettingsRailItem(
selected: selected == AppDestination.settings,
onTap: () => onSelected(AppDestination.settings),
),
);
}
/// Settings at the rail's foot, drawn as a [NavigationRailDestination] is: an
/// icon on a stadium indicator with its label under it, and the same colours.
/// It is not a [NavigationRailDestination] itself because the rail's
/// destination list is the tabs, and `trailing` is what the rail pins.
class _SettingsRailItem extends StatelessWidget {
const _SettingsRailItem({required this.selected, required this.onTap});
final bool selected;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final item = destinationDetails(AppDestination.settings);
final foreground = selected
? scheme.onSecondaryContainer
: scheme.onSurfaceVariant;
final textStyle = Theme.of(context).textTheme.labelMedium?.copyWith(
color: foreground,
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
);
return Semantics(
button: true,
selected: selected,
label: item.label,
child: ExcludeSemantics(
child: InkWell(
key: const ValueKey('shell.destination.settings'),
onTap: onTap,
child: SizedBox(
width: kNavigationRailWidth,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 56,
height: 32,
alignment: Alignment.center,
decoration: ShapeDecoration(
shape: const StadiumBorder(),
color: selected ? scheme.secondaryContainer : null,
),
child: Icon(item.icon, color: foreground),
),
const SizedBox(height: 4),
Text(item.label, style: textStyle),
],
),
),
),
),
),
);
}
}