Merge branch 'main' into run-chat-info-header

This commit is contained in:
2026-10-31 15:10:50 +00:00
40 changed files with 1057 additions and 228 deletions
+4 -1
View File
@@ -479,6 +479,7 @@ class _PipelinesAppState extends State<PipelinesApp>
onViewPipelineRuns: (id) => onViewPipelineRuns: (id) =>
_delegate.goTo(AppRoute.runsForPipeline(id)), _delegate.goTo(AppRoute.runsForPipeline(id)),
onOpenSchedules: _delegate.openSchedules, onOpenSchedules: _delegate.openSchedules,
onOpenSettings: () => _delegate.goTo(AppRoute.settings),
// The open pipeline is part of the route, so Back steps out of it. // The open pipeline is part of the route, so Back steps out of it.
onSelectionChanged: (id) { onSelectionChanged: (id) {
final current = _delegate.route; final current = _delegate.route;
@@ -529,13 +530,15 @@ class _PipelinesAppState extends State<PipelinesApp>
onSessionSelected: (id) => _delegate.goTo(AppRoute.chatSession(id)), onSessionSelected: (id) => _delegate.goTo(AppRoute.chatSession(id)),
onBack: () => _delegate.goTo(AppRoute.chat), onBack: () => _delegate.goTo(AppRoute.chat),
), ),
// Search is the fifth tab; a result opens its destination. // Search is the fourth tab; a result opens its destination.
AppDestination.search: (_) => SearchDestination( AppDestination.search: (_) => SearchDestination(
session: _session, session: _session,
server: widget.server, server: widget.server,
onOpen: _openSearchResult, onOpen: _openSearchResult,
embedded: true, embedded: true,
), ),
// Settings is a page of the Pipelines tab (its bar's gear), not a
// tab; the shell shows it with Back to Pipelines.
AppDestination.settings: (_) => SettingsScreen( AppDestination.settings: (_) => SettingsScreen(
client: _session.client, client: _session.client,
// A phone signs in at the web login; a browser has its own. // A phone signs in at the web login; a browser has its own.
@@ -23,6 +23,7 @@ class PipelinesDestination extends StatelessWidget {
this.onRunStarted, this.onRunStarted,
this.onViewPipelineRuns, this.onViewPipelineRuns,
this.onOpenSchedules, this.onOpenSchedules,
this.onOpenSettings,
this.onSelectionChanged, this.onSelectionChanged,
this.initialPipelineId, this.initialPipelineId,
this.initialVersion = 0, this.initialVersion = 0,
@@ -42,6 +43,9 @@ class PipelinesDestination extends StatelessWidget {
final ValueChanged<int>? onRunStarted; final ValueChanged<int>? onRunStarted;
final ValueChanged<int>? onViewPipelineRuns; final ValueChanged<int>? onViewPipelineRuns;
final VoidCallback? onOpenSchedules; final VoidCallback? onOpenSchedules;
/// Opens Settings as a page from the Pipelines bar's gear.
final VoidCallback? onOpenSettings;
final ValueChanged<int?>? onSelectionChanged; final ValueChanged<int?>? onSelectionChanged;
/// The pipeline and pinned version a deep link names. /// The pipeline and pinned version a deep link names.
@@ -95,6 +99,7 @@ class PipelinesDestination extends StatelessWidget {
onRunStarted: onRunStarted, onRunStarted: onRunStarted,
onViewPipelineRuns: onViewPipelineRuns, onViewPipelineRuns: onViewPipelineRuns,
onOpenSchedules: onOpenSchedules, onOpenSchedules: onOpenSchedules,
onOpenSettings: onOpenSettings,
onSelectionChanged: onSelectionChanged, onSelectionChanged: onSelectionChanged,
initialPipelineId: initialPipelineId, initialPipelineId: initialPipelineId,
initialVersion: initialVersion, initialVersion: initialVersion,
+15 -20
View File
@@ -12,6 +12,7 @@ import 'pipeline_models.dart';
import 'pipeline_repository.dart'; import 'pipeline_repository.dart';
import 'pipelines_controller.dart'; import 'pipelines_controller.dart';
import 'pending_run_store.dart'; import 'pending_run_store.dart';
import 'widgets/pipeline_bar_buttons.dart';
import 'widgets/pipeline_controls.dart'; import 'widgets/pipeline_controls.dart';
import 'widgets/pipeline_detail_panel.dart'; import 'widgets/pipeline_detail_panel.dart';
import 'widgets/pipeline_list_panel.dart'; import 'widgets/pipeline_list_panel.dart';
@@ -36,6 +37,7 @@ class PipelinesScreen extends StatefulWidget {
this.onViewPipelineRuns, this.onViewPipelineRuns,
this.onSelectionChanged, this.onSelectionChanged,
this.onOpenSchedules, this.onOpenSchedules,
this.onOpenSettings,
this.initialPipelineId, this.initialPipelineId,
this.initialVersion = 0, this.initialVersion = 0,
this.initialStageKey, this.initialStageKey,
@@ -66,6 +68,9 @@ class PipelinesScreen extends StatefulWidget {
/// Opens every schedule; shown in the bar while the list is visible. /// Opens every schedule; shown in the bar while the list is visible.
final VoidCallback? onOpenSchedules; final VoidCallback? onOpenSchedules;
/// Opens Settings as a page; a gear in the bar while the list is visible.
final VoidCallback? onOpenSettings;
/// The pipeline a deep link names, opened after the list read starts. /// The pipeline a deep link names, opened after the list read starts.
final int? initialPipelineId; final int? initialPipelineId;
@@ -281,6 +286,8 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
if (listShown && widget.onOpenSchedules != null) if (listShown && widget.onOpenSchedules != null)
_schedulesButton(context), _schedulesButton(context),
_refreshButton(context), _refreshButton(context),
if (listShown && widget.onOpenSettings != null)
_settingsButton(context),
], ],
child: body, child: body,
); );
@@ -298,6 +305,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
...pipelineListActions(context, _controller), ...pipelineListActions(context, _controller),
if (widget.onOpenSchedules != null) _schedulesButton(context), if (widget.onOpenSchedules != null) _schedulesButton(context),
_refreshButton(context), _refreshButton(context),
if (widget.onOpenSettings != null) _settingsButton(context),
], ],
), ),
), ),
@@ -307,26 +315,11 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
); );
} }
Widget _schedulesButton(BuildContext context) { Widget _schedulesButton(BuildContext context) =>
if (useCupertinoControls(context)) { pipelineSchedulesButton(context, widget.onOpenSchedules);
return Semantics(
button: true, Widget _settingsButton(BuildContext context) =>
label: 'Schedules', pipelineSettingsButton(context, widget.onOpenSettings);
child: CupertinoButton(
key: const Key('pipelines-open-schedules'),
padding: EdgeInsets.zero,
onPressed: widget.onOpenSchedules,
child: const Icon(CupertinoIcons.calendar),
),
);
}
return IconButton(
key: const Key('pipelines-open-schedules'),
tooltip: 'Schedules',
onPressed: widget.onOpenSchedules,
icon: const Icon(Icons.schedule),
);
}
Widget _refreshButton(BuildContext context) { Widget _refreshButton(BuildContext context) {
if (useCupertinoControls(context)) { if (useCupertinoControls(context)) {
@@ -357,6 +350,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
...pipelineListActions(context, _controller), ...pipelineListActions(context, _controller),
if (widget.onOpenSchedules != null) _schedulesButton(context), if (widget.onOpenSchedules != null) _schedulesButton(context),
_refreshButton(context), _refreshButton(context),
if (widget.onOpenSettings != null) _settingsButton(context),
], ],
), ),
body: SafeArea(top: false, child: body), body: SafeArea(top: false, child: body),
@@ -372,6 +366,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
...pipelineListActions(context, _controller), ...pipelineListActions(context, _controller),
if (widget.onOpenSchedules != null) _schedulesButton(context), if (widget.onOpenSchedules != null) _schedulesButton(context),
_refreshButton(context), _refreshButton(context),
if (widget.onOpenSettings != null) _settingsButton(context),
], ],
), ),
child: SafeArea(top: false, child: body), child: SafeArea(top: false, child: body),
@@ -0,0 +1,57 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'pipeline_controls.dart';
/// One icon action in the Pipelines bar's actions pill: a Material
/// [IconButton] with its tooltip, or a Cupertino button named for
/// accessibility.
Widget pipelineBarIconButton(
BuildContext context, {
required Key key,
required String label,
required IconData icon,
required IconData cupertinoIcon,
required VoidCallback? onPressed,
}) {
if (useCupertinoControls(context)) {
return Semantics(
button: true,
label: label,
child: CupertinoButton(
key: key,
padding: EdgeInsets.zero,
onPressed: onPressed,
child: Icon(cupertinoIcon),
),
);
}
return IconButton(
key: key,
tooltip: label,
onPressed: onPressed,
icon: Icon(icon),
);
}
/// Opens every schedule.
Widget pipelineSchedulesButton(BuildContext context, VoidCallback? onPressed) =>
pipelineBarIconButton(
context,
key: const Key('pipelines-open-schedules'),
label: 'Schedules',
icon: Icons.schedule,
cupertinoIcon: CupertinoIcons.calendar,
onPressed: onPressed,
);
/// Opens Settings as a page (it is not a tab of the shell).
Widget pipelineSettingsButton(BuildContext context, VoidCallback? onPressed) =>
pipelineBarIconButton(
context,
key: const Key('pipelines-open-settings'),
label: 'Settings',
icon: Icons.settings_outlined,
cupertinoIcon: CupertinoIcons.gear,
onPressed: onPressed,
);
@@ -4,14 +4,15 @@ import 'package:flutter/material.dart';
/// The detail sections: Summary, the pinned definition Graph and Source. /// The detail sections: Summary, the pinned definition Graph and Source.
enum PipelineDetailTab { enum PipelineDetailTab {
summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text), summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text),
graph('Graph', Icons.account_tree_outlined, CupertinoIcons.arrow_branch), graph('Graph', Icons.hub_outlined, CupertinoIcons.flowchart),
source('Source', Icons.code, CupertinoIcons.chevron_left_slash_chevron_right); source('Source', Icons.code, CupertinoIcons.chevron_left_slash_chevron_right);
const PipelineDetailTab(this.label, this.icon, this.cupertinoIcon); const PipelineDetailTab(this.label, this.icon, this.cupertinoIcon);
final String label; final String label;
/// The tab's glyph, shown above its name in the bottom bar. /// The tab's glyph, the only thing the bottom bar draws (the label is its
/// accessible name); distinct from the shell's Pipelines tab beneath it.
final IconData icon; final IconData icon;
final IconData cupertinoIcon; final IconData cupertinoIcon;
} }
@@ -29,7 +29,7 @@ enum RunVisitSection {
Icons.difference_outlined, Icons.difference_outlined,
CupertinoIcons.arrow_right_arrow_left, CupertinoIcons.arrow_right_arrow_left,
), ),
session('Session', Icons.forum_outlined, CupertinoIcons.chat_bubble_2), session('Session', Icons.forum_outlined, CupertinoIcons.text_bubble),
definition( definition(
'Definition', 'Definition',
Icons.description_outlined, Icons.description_outlined,
+61 -38
View File
@@ -117,7 +117,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
// Full-screen detail routes cover the shell themselves. Keep the root tabs // Full-screen detail routes cover the shell themselves. Keep the root tabs
// mounted/layout-ready underneath, so Back does not resize or reveal them // mounted/layout-ready underneath, so Back does not resize or reveal them
// only after the outgoing page has finished its native animation. // only after the outgoing page has finished its native animation.
final index = AppDestination.values.indexOf(_selected); // 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 details = destinationDetails(_selected);
final contents = AppDestination.values.map((destination) { final contents = AppDestination.values.map((destination) {
final item = destinationDetails(destination); final item = destinationDetails(destination);
@@ -144,62 +147,75 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
// scaffold's structure depends on the width, so resizing never // scaffold's structure depends on the width, so resizing never
// remounts a destination. // remounts a destination.
// //
// While the tab shows its list beside an open item, the bar floats // While the tab shows its list beside an open item the bar keeps
// over the list pane only (judging its placement on that width), so // the same place, bottom right near the thumb: the item pane learns
// it never covers the item or stacks on the item's own composer. // the bar's height (see ListDetailPanes) and floats its own tabs or
// composer above it, so the two never overlap.
final split = _bar.split(_selected); final split = _bar.split(_selected);
final bar = ListPaneWidth( final bar = FloatingDestinationBar(
split: split, cupertino: widget.cupertino,
alignment: AlignmentDirectional.bottomStart, currentIndex: index,
child: FloatingDestinationBar( onTap: (value) => _select(shellTabDestinations[value]),
cupertino: widget.cupertino, items: _destinationItems(),
currentIndex: index,
onTap: (value) => _select(AppDestination.values[value]),
items: _destinationItems(),
),
); );
// Destinations reach the top edge and scroll behind the floating top // Destinations reach the top edge and scroll behind the floating top
// bar too: each learns the bar's height as its top media padding and // bar too: each learns the bar's height as its top media padding and
// pads its own lists by it (see withTopBarClearance). // pads its own lists by it (see withTopBarClearance).
final topBar = _ListPaneBar( final topBar = _ListPaneBar(
split: split, split: split,
bar: _segmentedBar(spec, details.label), bar: _segmentedBar(spec, details.label, page: page),
); );
// The scaffolds below swap the system insets for their bars' // The scaffolds below swap the system insets for their bars'
// heights; panes beside a list read the real ones from here. // heights; panes beside a list read the real ones from here.
final system = MediaQuery.paddingOf(context); final system = MediaQuery.paddingOf(context);
// A page (Settings) closes to Pipelines on the system Back too. The
// scope is always there, so opening the page never remounts the shell.
Widget backable(Widget child) => PopScope(
canPop: !page,
onPopInvokedWithResult: (didPop, _) {
if (!didPop) _closePage();
},
child: child,
);
if (widget.cupertino) { if (widget.cupertino) {
return ShellSystemInsets( return backable(
padding: system, ShellSystemInsets(
child: CupertinoPageScaffold( padding: system,
navigationBar: topBar, child: CupertinoPageScaffold(
child: SafeArea( navigationBar: topBar,
top: false, child: SafeArea(
bottom: false, top: false,
child: FloatingBarOverlay( bottom: false,
bar: bar, child: FloatingBarOverlay(
child: _destinationStack(contents, index), bar: bar,
child: _destinationStack(contents),
),
), ),
), ),
), ),
); );
} }
return ShellSystemInsets( return backable(
padding: system, ShellSystemInsets(
child: Scaffold( padding: system,
extendBodyBehindAppBar: true, child: Scaffold(
appBar: topBar, extendBodyBehindAppBar: true,
body: _destinationStack(contents, index), appBar: topBar,
extendBody: true, body: _destinationStack(contents),
bottomNavigationBar: bar, extendBody: true,
bottomNavigationBar: bar,
),
), ),
); );
}, },
); );
} }
/// Leaves a page destination (Settings) for the tab it belongs to.
void _closePage() => _select(shellTabFor(_selected));
List<FloatingDestinationItem> _destinationItems() => List<FloatingDestinationItem> _destinationItems() =>
AppDestination.values.map((destination) { shellTabDestinations.map((destination) {
final item = destinationDetails(destination); final item = destinationDetails(destination);
return FloatingDestinationItem( return FloatingDestinationItem(
key: ValueKey('shell.destination.${destination.name}'), key: ValueKey('shell.destination.${destination.name}'),
@@ -213,9 +229,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
/// The open screen's own bar: its Back, title and actions, or the tab's /// The open screen's own bar: its Back, title and actions, or the tab's
/// name with Search. /// name with Search.
SegmentedBar _segmentedBar(ShellBarSpec? spec, String label) { SegmentedBar _segmentedBar(
ShellBarSpec? spec,
String label, {
required bool page,
}) {
final cupertino = widget.cupertino; final cupertino = widget.cupertino;
final onBack = spec?.onBack; final onBack = spec?.onBack ?? (page ? _closePage : null);
final published = spec?.actions ?? const <Widget>[]; final published = spec?.actions ?? const <Widget>[];
final onSearch = widget.onSearch; final onSearch = widget.onSearch;
return SegmentedBar( return SegmentedBar(
@@ -251,7 +271,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
) )
// A screen whose main pill is its own field (Search) needs no // A screen whose main pill is its own field (Search) needs no
// separate Search action. // separate Search action.
else if (onSearch != null && spec?.titleWidget == null) else if (onSearch != null && spec?.titleWidget == null && !page)
cupertino cupertino
? CupertinoButton( ? CupertinoButton(
key: const ValueKey('shell.search'), key: const ValueKey('shell.search'),
@@ -272,8 +292,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
); );
} }
Widget _destinationStack(List<Widget> contents, int index) => Widget _destinationStack(List<Widget> contents) => IndexedStack(
IndexedStack(key: _destinationStackKey, index: index, children: contents); key: _destinationStackKey,
index: AppDestination.values.indexOf(_selected),
children: contents,
);
} }
/// The shell's top bar, over the list pane only while the tab shows a list /// The shell's top bar, over the list pane only while the tab shows a list
+17
View File
@@ -3,6 +3,23 @@ import 'package:flutter/cupertino.dart';
enum AppDestination { pipelines, runs, chat, search, settings } enum AppDestination { pipelines, runs, chat, search, settings }
/// The destinations the shell's tab bar offers, in order. Settings is a
/// destination the shell can show (its route is `/settings`), but it opens
/// as a page from the Pipelines bar's gear instead of being a tab.
const List<AppDestination> shellTabDestinations = [
AppDestination.pipelines,
AppDestination.runs,
AppDestination.chat,
AppDestination.search,
];
/// The tab that owns [destination] in the tab bar: itself, or Pipelines for
/// Settings (reached from the Pipelines bar).
AppDestination shellTabFor(AppDestination destination) =>
shellTabDestinations.contains(destination)
? destination
: AppDestination.pipelines;
({String label, IconData icon, IconData cupertinoIcon}) destinationDetails( ({String label, IconData icon, IconData cupertinoIcon}) destinationDetails(
AppDestination value, AppDestination value,
) => switch (value) { ) => switch (value) {
+45
View File
@@ -0,0 +1,45 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/host.dart';
/// The open item's own navigator beside a list on a wide window.
///
/// A page the item opens (a run's stage page, an artifact, a file) is pushed
/// here, so it fills the item's pane while the list and the shell's tab bar
/// stay in place: the page's own tabs then float above the shell's bar, as
/// the item's tabs do. Dialogs still use the root navigator.
///
/// The item is this navigator's first page under a fixed key, so a rebuilt
/// item updates in place and is never remounted. The system Back pops a page
/// pushed here before it leaves the item.
class DetailPaneNavigator extends StatefulWidget {
const DetailPaneNavigator({super.key, required this.child});
final Widget child;
@override
State<DetailPaneNavigator> createState() => _DetailPaneNavigatorState();
}
class _DetailPaneNavigatorState extends State<DetailPaneNavigator> {
final GlobalKey<NavigatorState> _navigator = GlobalKey();
static const _rootKey = ValueKey<String>('list-detail-root');
@override
Widget build(BuildContext context) {
final Page<void> root = usesCupertinoHost(context)
? CupertinoPage<void>(key: _rootKey, child: widget.child)
: MaterialPage<void>(key: _rootKey, child: widget.child);
return NavigatorPopHandler(
onPopWithResult: (_) => _navigator.currentState?.maybePop(),
child: Navigator(
key: _navigator,
pages: [root],
// The item is never popped from here: its pane closes with the
// selection, which the owning screen controls.
onDidRemovePage: (_) {},
),
);
}
}
+30 -12
View File
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import '../ui/adaptive/floating_bar_layout.dart'; import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/host.dart'; import '../ui/adaptive/host.dart';
import 'detail_pane_navigator.dart';
import 'shell_bar.dart'; import 'shell_bar.dart';
/// At least this wide, a destination keeps its list beside the open item /// At least this wide, a destination keeps its list beside the open item
@@ -100,11 +101,14 @@ class ListPaneWidth extends StatelessWidget {
/// One body-priority policy for all destinations, derived from the full window /// One body-priority policy for all destinations, derived from the full window
/// and actual available space after navigation. No fixed pixel pane widths. /// and actual available space after navigation. No fixed pixel pane widths.
/// ///
/// Under the shell, the list keeps the shell's bars (both narrowed to the list /// Under the shell, the list keeps the shell's top bar (narrowed to the list
/// pane through [ShellPaneSplit], see [ListPaneWidth]) and the open item owns /// 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 /// the rest of the window: the detail starts at the top edge below the status
/// bottom edge with only the system insets ([ShellSystemInsets]) as its /// bar ([ShellSystemInsets]). The shell's tab bar stays at the bottom right,
/// padding, and its own tabs float at its bottom, as on a phone. /// over the detail pane, so the detail learns that bar's height plus
/// [kStackedBarGap] as its bottom padding: its own tabs (or the chat
/// composer) float above the shell's bar, never on it, and its content clears
/// both. Pages the item opens stay in its pane ([DetailPaneNavigator]).
class ListDetailPanes extends StatelessWidget { class ListDetailPanes extends StatelessWidget {
const ListDetailPanes({super.key, required this.list, required this.detail}); const ListDetailPanes({super.key, required this.list, required this.detail});
@@ -129,21 +133,35 @@ class ListDetailPanes extends StatelessWidget {
constraints.maxWidth, constraints.maxWidth,
); );
Widget body = detail; Widget body = detail;
Widget listPane = list;
if (split) { if (split) {
// Beside the list the item is under neither of the shell's bars // Beside the list the item is not under the shell's top bar (it
// (both stay over the list pane): it keeps only the system's own // stays over the list pane): it keeps the system's own top inset,
// insets, so its bar sits just below the status bar at the top // so its bar sits just below the status bar at the top edge. The
// edge, and its tabs or composer own the pane's bottom edge, // shell's tab bar floats at the bottom right, over this pane; its
// floating just above the system inset. // height (the shell's bottom padding here) plus a gap lifts the
// item's tabs or composer above it.
final system = ShellSystemInsets.of(context); final system = ShellSystemInsets.of(context);
body = MediaQuery( body = MediaQuery(
data: media.copyWith( data: media.copyWith(
padding: media.padding.copyWith( padding: media.padding.copyWith(
top: system.top, top: system.top,
bottom: system.bottom, bottom: media.padding.bottom + kStackedBarGap,
), ),
), ),
child: PageTabsEdge(edge: FloatingBarEdge.bottom, child: body), child: PageTabsEdge(
edge: FloatingBarEdge.bottom,
child: DetailPaneNavigator(child: body),
),
);
// The tab bar sits over the detail pane, never the list (the
// detail is at least half the window, wider than the bar), so
// the list clears only the system's bottom inset.
listPane = MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(bottom: system.bottom),
),
child: list,
); );
} }
return Row( return Row(
@@ -156,7 +174,7 @@ class ListDetailPanes extends StatelessWidget {
container: true, container: true,
explicitChildNodes: true, explicitChildNodes: true,
identifier: 'list-detail-list', identifier: 'list-detail-list',
child: list, child: listPane,
), ),
), ),
), ),
@@ -7,6 +7,11 @@ const double kFloatingBarWideWidth = 600;
/// The gap between a floating tab bar and the edges (and bottom safe area). /// The gap between a floating tab bar and the edges (and bottom safe area).
const double kFloatingBarMargin = 16; const double kFloatingBarMargin = 16;
/// The gap between two floating bars stacked at the bottom right of a wide
/// window: the shell's tab bar and, above it, an open item's own tabs (the
/// chat composer adds its own padding on top of this).
const double kStackedBarGap = 12;
/// [padding] with the floating bar's clearance added at the bottom. /// [padding] with the floating bar's clearance added at the bottom.
/// ///
/// A scrollable under a floating bar (see [FloatingBarOverlay] and the shell) /// A scrollable under a floating bar (see [FloatingBarOverlay] and the shell)
@@ -17,6 +17,10 @@ import 'glass_pill.dart';
/// way it keeps [kFloatingBarMargin] above the bottom safe area. Only the pill /// way it keeps [kFloatingBarMargin] above the bottom safe area. Only the pill
/// takes taps: the space beside it reaches the content behind. /// takes taps: the space beside it reaches the content behind.
/// ///
/// The tabs show icons only. Each tab's label stays its accessible name (and
/// the Material tooltip), so screen readers still announce it; the icons must
/// be distinct within a bar.
///
/// The controls inside remain the platform navigation controls (Material /// The controls inside remain the platform navigation controls (Material
/// [NavigationBar], Cupertino [CupertinoTabBar]), so tab semantics (selected /// [NavigationBar], Cupertino [CupertinoTabBar]), so tab semantics (selected
/// state, "tab n of m") come from the host. The Cupertino path builds no /// state, "tab n of m") come from the host. The Cupertino path builds no
@@ -41,11 +45,17 @@ class FloatingDestinationBar extends StatelessWidget {
final ValueChanged<int> onTap; final ValueChanged<int> onTap;
final List<FloatingDestinationItem> items; final List<FloatingDestinationItem> items;
/// Height of the Material bar inside the pill (the stock bar is 80). /// Height of the Material bar inside the pill (the stock bar is 80; with
static const double materialHeight = 64; /// labels hidden the icon and its indicator need less).
static const double materialHeight = 56;
/// Height of the Cupertino bar inside the pill (the stock bar is 50). /// Height of the Cupertino bar inside the pill (the stock bar's 50).
static const double cupertinoHeight = 54; static const double cupertinoHeight = 50;
/// Width of one icon-only tab on a wide window: a comfortable touch target
/// around the Material indicator (64) or the Cupertino selection capsule.
static const double materialTabWidth = 72;
static const double cupertinoTabWidth = 64;
/// The side margin at [FloatingBarEdge.top], matching the top bar's own. /// The side margin at [FloatingBarEdge.top], matching the top bar's own.
static const double topMargin = 12; static const double topMargin = 12;
@@ -114,41 +124,10 @@ class FloatingDestinationBar extends StatelessWidget {
); );
} }
/// The width the tabs need side by side: every tab as wide as the widest /// The width the icon-only tabs need side by side. Icons do not scale with
/// label (as the host lays them out), never narrower than a comfortable /// text, so the pill keeps its size at any text scale.
/// touch target. double _tabsWidth(BuildContext context) =>
double _tabsWidth(BuildContext context) { (cupertino ? cupertinoTabWidth : materialTabWidth) * items.length;
final TextStyle? style;
final TextScaler scaler;
final double minimum;
if (cupertino) {
style = CupertinoTheme.of(context).textTheme.tabLabelTextStyle;
scaler = TextScaler.noScaling;
minimum = 76;
} else {
final theme = Theme.of(context);
style =
theme.navigationBarTheme.labelTextStyle?.resolve(const {
WidgetState.selected,
}) ??
theme.textTheme.labelMedium;
// NavigationBar clamps its labels at 1.3x.
scaler = MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.3);
minimum = 88;
}
var widest = 0.0;
for (final item in items) {
final painter = TextPainter(
text: TextSpan(text: item.label, style: style),
textScaler: scaler,
textDirection: Directionality.of(context),
maxLines: 1,
)..layout();
widest = math.max(widest, painter.width);
painter.dispose();
}
return math.max(minimum, widest + 24) * items.length;
}
Widget _materialBar(BuildContext context) { Widget _materialBar(BuildContext context) {
final scheme = Theme.of(context).colorScheme; final scheme = Theme.of(context).colorScheme;
@@ -159,7 +138,9 @@ class FloatingDestinationBar extends StatelessWidget {
surfaceTintColor: Colors.transparent, surfaceTintColor: Colors.transparent,
indicatorColor: scheme.secondaryContainer, indicatorColor: scheme.secondaryContainer,
height: materialHeight, height: materialHeight,
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow, // Icons only; the label remains each tab's accessible name and its
// tooltip.
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
), ),
child: NavigationBar( child: NavigationBar(
selectedIndex: currentIndex, selectedIndex: currentIndex,
@@ -177,10 +158,10 @@ class FloatingDestinationBar extends StatelessWidget {
); );
} }
/// The stock Cupertino bar, transparent inside the pill. Each tab's label is /// The stock Cupertino bar, transparent inside the pill. Each tab shows its
/// drawn with its icon (in the bar's own label style and colours) so the /// icon only, named by its label for accessibility; the item's key covers
/// item's key covers the whole tab, and the selected tab's icon sits in a /// the whole tab, and the selected tab's icon sits in a tinted capsule so
/// tinted capsule so the selection reads at a glance, not by colour alone. /// the selection reads at a glance, not by colour alone.
Widget _cupertinoBar(BuildContext context) { Widget _cupertinoBar(BuildContext context) {
final active = CupertinoTheme.of(context).primaryColor; final active = CupertinoTheme.of(context).primaryColor;
Widget tab(FloatingDestinationItem item, {required bool selected}) { Widget tab(FloatingDestinationItem item, {required bool selected}) {
@@ -199,14 +180,7 @@ class FloatingDestinationBar extends StatelessWidget {
} }
return KeyedSubtree( return KeyedSubtree(
key: item.key, key: item.key,
child: Column( child: Semantics(label: item.label, child: icon),
mainAxisSize: MainAxisSize.min,
children: [
icon,
const SizedBox(height: 2),
Text(item.label, maxLines: 1, softWrap: false),
],
),
); );
} }
@@ -218,7 +192,7 @@ class FloatingDestinationBar extends StatelessWidget {
// Secondary-label translucency over glass falls below text contrast // Secondary-label translucency over glass falls below text contrast
// requirements. The host label role remains readable in both themes. // requirements. The host label role remains readable in both themes.
inactiveColor: CupertinoColors.label.resolveFrom(context), inactiveColor: CupertinoColors.label.resolveFrom(context),
iconSize: 24, iconSize: 26,
height: cupertinoHeight, height: cupertinoHeight,
currentIndex: currentIndex, currentIndex: currentIndex,
onTap: onTap, onTap: onTap,
@@ -244,9 +218,11 @@ class FloatingDestinationItem {
}); });
final Widget icon; final Widget icon;
/// The tab's accessible name (and Material tooltip); not drawn.
final String label; final String label;
final Widget? selectedIcon; final Widget? selectedIcon;
/// Identifies the whole tab (icon and label), for tests and automation. /// Identifies the whole tab, for tests and automation.
final Key? key; final Key? key;
} }
+160
View File
@@ -0,0 +1,160 @@
# Tab bars v2 (operator feedback)
Follows `notes/floating-tab-bars.md` and `notes/wide-shell-fixes.md`. Where they
disagree, this note wins: the shell's tab bar no longer stays over the list
pane.
## 1. Settings is a page, not a tab
- `shellTabDestinations` (`lib/shell/destination.dart`) is the tab bar:
Pipelines, Runs, Chat, Search. `AppDestination.settings` still exists, so the
shell can show it. The `/settings` route, deep link, `SettingsScreen` and its
keys are unchanged, and Templates and Schedules still open above it.
- Pipelines bar: there is a gear action after Refresh (key
`pipelines-open-settings`, `PipelinesScreen.onOpenSettings` /
`PipelinesDestination.onOpenSettings`). It is shown while the list is
visible. The Schedules and Settings buttons live in
`features/pipelines/widgets/pipeline_bar_buttons.dart`.
- While Settings is shown, the shell keeps Pipelines selected in the tab bar
(`shellTabFor`), so Settings reads as a page of Pipelines.
- The top bar gets a Back button (`shell.back`) and no Search action.
- The system Back (`PopScope` around the shell, present at all times so
nothing remounts) also returns to Pipelines, instead of leaving the app.
- Tapping the Pipelines tab returns to Pipelines as well.
## 2. Icons only
`FloatingDestinationBar` no longer draws labels.
- Material uses `NavigationDestinationLabelBehavior.alwaysHide`. The label is
still the tab's semantics label and its tooltip.
- Cupertino draws the icon alone, inside `Semantics(label:)`. It has no
tooltip, because a tooltip would be a Material widget.
- Selected state, "tab n of m", badges and every test key are unchanged.
- Sizes:
- Pill height is 56 for Material and 50 for Cupertino.
- On a wide window each tab is 72 wide (Material) or 64 (Cupertino), so the
pill no longer depends on text scale.
- Icons changed so that no detail tab repeats a shell tab it can float above:
- Pipeline Graph: `Icons.hub_outlined` / `CupertinoIcons.flowchart`. The old
icon was the Pipelines tab's.
- Stage Session (Cupertino): `CupertinoIcons.text_bubble`. The old icon was
the Chat tab's.
## 3–4. Main bar bottom right; detail bars above it
- The shell no longer wraps its bottom bar in `ListPaneWidth`. The bar gets the
full window width, so at 600 and wider it is compact at the bottom right,
whether the list is split or not.
- In `ListDetailPanes` (split, under a shell):
- **Detail pane:** its bottom padding is the shell bar's height (the shell's
own bottom padding) plus `kStackedBarGap` (12). As a result:
- The item's floating tabs sit 12 above the main pill, trailing-aligned.
- The chat composer's box starts 12 above the pill, and its pill adds
another 12 inside.
- Content clears both bars.
- **Top inset:** this is still `ShellSystemInsets` (status bar).
- **List pane:** gets only the system bottom inset. The bar never covers the
list, because the detail is at least half the window and wider than the
pill.
- `DetailPaneNavigator` (`lib/shell/detail_pane_navigator.dart`):
- The split detail now has its own `Navigator`. The item is its first page,
under a fixed key, so it updates in place.
- Pages the item pushes (the stage page from the timeline, artifact/diff
viewers, the expanded graph) open inside the pane. The list and the main
bar stay visible, and the stage page's tabs float above the main bar like
the run tabs do.
- `NavigatorPopHandler` makes the system Back pop such a page first.
- Dialogs still use the root navigator.
- Phones are unchanged. A detail is a pushed full-screen page, with its tabs at
the bottom and no shell bar.
## 5. Kept
- `ShellSystemInsets`, the status-bar inset in the split detail.
- Content scrolling behind both bars.
- No remount when the width changes. The shell's scaffold structure, the
`PopScope` and the bar do not depend on width or split.
- The Cupertino bar still builds no Material widget.
- 320px at 2x text: the existing tests pass, and icon tabs do not scale.
## Tests
Full suite: 2233 passed (`flutter test`); `flutter analyze` clean;
`flutter build web` OK.
New:
- `test/application/settings_page_test.dart`, on both hosts at 390 and 1200:
- The gear opens `/settings`.
- Settings shows Back and has no Search, and Pipelines stays selected.
- Back returns to `/pipelines`.
- The tab bar labels are exactly Pipelines/Runs/Chat/Search.
- The `/settings` deep link opens Settings, and the system Back is handled
and returns to Pipelines.
- `test/shell/split_detail_pages_test.dart`: the real run detail in a 1200
split under the shell, on both hosts.
- The run tabs are trailing-aligned and sit 12 above the main pill, which
keeps the bottom right.
- The stage page opens inside the pane: the root navigator cannot pop and the
list stays visible. Its tabs are 12 above the main pill, with no overlap.
- The stage page's Back returns to the run.
- `test/ui/adaptive/icon_only_tab_bars_test.dart`, covering the run detail,
stage page and pipeline detail bars on both hosts:
- No label is drawn (Cupertino has no `Text`; Material uses `alwaysHide`).
- Each tab's semantics label starts with its name, and the selected state is
correct.
- The icons are distinct, and no detail icon equals a shell tab icon.
- `test/shell/split_destination_bar_test.dart` (rewritten), at 1200 and 1600 on
both hosts:
- The main pill is at the bottom right, over the detail, never the list.
- The composer box is 12 above it.
- Detail tabs are 12 above it, no overlap, and the item list clears both.
- The list pane pads only the system inset.
- At 600 and 840 split with 2x text, there is no overflow.
Updated for the intentional changes:
- `shell_bar_test`: Search is the fourth tab and Settings is not a tab.
- `floating_tab_bar_test`: the wide pill is exactly 4 tab widths, and the
semantics test uses tab keys and the label.
- `split_status_bar_test`: a 24px bottom inset; the item tabs sit 12 above the
main pill, which is at 800 − 24.
- `pane_bar_row_test`: the item tabs are above the main pill.
- `attention_badge_test`: tabs are tapped by key.
- Tests that tapped tab label text now tap tab keys:
- Pipeline tests use `pipeline-detail-tab-*`.
- App tests use `shell.destination.*`; Settings is opened by
`pipelines-open-settings`.
- Run detail tests use `run-detail-tab-*`.
- `list_detail_consistency_test` and `chat_list_detail_test` use the root
navigator (`find.byType(Navigator).first`), because the split pane now has
its own.
## Evidence
`/tmp/tabs-v2-evidence/` holds 84 PNGs taken with headless Chrome, using
`/tmp/app-style-review-r2/shoot.mjs` over a web build of
`tool/app_host_probe_entry.dart` (`build/tabs2-app_host`). The specs are in
`scripts/`.
- Runs fixture (wave2-e, `RICH=1`): `{m,c}-{runs,run1,stage,thread}-{560,1200,1600}-{light,dark}`.
- Pipelines fixture (`pipelines_wiring_probe_server`): `{m,c}-{plist,pdetail}-…`.
- Settings opened by clicking the gear: `{m,c}-settings-via-bar-…`.
What the captures show:
- At 1200 and 1600:
- The main pill is at the bottom right.
- The run, stage and pipeline tabs sit above it with a visible gap.
- The chat composer sits above it.
- The stage page opens in the detail pane, beside the list.
- At 560 the bars are full width and icon-only.
- Settings shows Back, with Pipelines selected.
Known gaps:
- There was no device run, so the Android and iOS hardware Back for the
Settings page and the in-pane pages are covered by widget tests only.
- Headless Chrome has no status bar, so the status-bar inset is again covered
by tests only.
@@ -52,7 +52,9 @@ void main() {
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse); expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
expect(find.bySemanticsLabel(needingAttention), findsNothing); expect(find.bySemanticsLabel(needingAttention), findsNothing);
await tester.tap(find.text('Pipelines').last); await tester.tap(
find.byKey(const ValueKey('shell.destination.pipelines')),
);
await tester.pump(); await tester.pump();
expect(provider.value.uri.path, '/pipelines'); expect(provider.value.uri.path, '/pipelines');
await waitForRequest(tester, channel, 'list_pipelines'); await waitForRequest(tester, channel, 'list_pipelines');
@@ -159,7 +159,9 @@ void main() {
expect(tester.getSize(list).width, closeTo(before, 0.01)); expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01)); expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01));
expect( expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(), tester
.state<NavigatorState>(find.byType(Navigator).first)
.canPop(),
isFalse, isFalse,
); );
for (final rowKey in rowKeys) { for (final rowKey in rowKeys) {
@@ -224,7 +226,9 @@ void main() {
tester.view.physicalSize = const Size(390, 900); tester.view.physicalSize = const Size(390, 900);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(), tester
.state<NavigatorState>(find.byType(Navigator).first)
.canPop(),
isTrue, isTrue,
reason: '$destination should push its selected item on a phone', reason: '$destination should push its selected item on a phone',
); );
@@ -235,7 +239,9 @@ void main() {
tester.view.physicalSize = Size(width, 900); tester.view.physicalSize = Size(width, 900);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(), tester
.state<NavigatorState>(find.byType(Navigator).first)
.canPop(),
isFalse, isFalse,
); );
expect(tester.getSize(list).width, closeTo(before, 0.01)); expect(tester.getSize(list).width, closeTo(before, 0.01));
+1 -1
View File
@@ -239,7 +239,7 @@ void main() {
final pipelinesRunsId = final pipelinesRunsId =
pipelineRequest(channel, 'list_runs')!['id'] as String; pipelineRequest(channel, 'list_runs')!['id'] as String;
await tester.tap(find.text('Runs').last); await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pump(); await tester.pump();
expect(provider.value.uri.path, '/runs'); expect(provider.value.uri.path, '/runs');
@@ -77,7 +77,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(find.text('hash-alpha'), findsOneWidget); expect(find.text('hash-alpha'), findsOneWidget);
await tester.tap(find.text('Source')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump(); await tester.pump();
expect( expect(
selectableText( selectableText(
+4 -9
View File
@@ -1,7 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../features/runs/ui/run_detail_finders.dart'; import '../features/runs/ui/run_detail_finders.dart';
import '../native_back.dart'; import '../native_back.dart';
@@ -87,15 +86,11 @@ Future<void> replyRun7List(WidgetTester tester, FakeChannel channel) => reply(
}, },
); );
/// Taps a tab by its label: the bottom bar or, on a wide window, the rail. /// Taps a shell tab by its label (the tabs show icons only, keyed by name).
Future<void> tapTab(WidgetTester tester, String label) async { Future<void> tapTab(WidgetTester tester, String label) async {
final bar = find.byWidgetPredicate( await tester.tap(
(widget) => find.byKey(ValueKey('shell.destination.${label.toLowerCase()}')),
widget is NavigationBar ||
widget is NavigationRail ||
widget is CupertinoTabBar,
); );
await tester.tap(find.descendant(of: bar, matching: find.text(label)));
} }
/// Opens Search, sends `report` and answers with the artifact hit for run 7. /// Opens Search, sends `report` and answers with the artifact hit for run 7.
@@ -300,7 +295,7 @@ void main() {
// On a phone an open run fills the screen and the tabs step aside, so // On a phone an open run fills the screen and the tabs step aside, so
// switching tabs with a run open is a wide-window move. // switching tabs with a run open is a wide-window move.
// Search is the fifth tab. // Search is the fourth tab.
await tapTab(tester, 'Search'); await tapTab(tester, 'Search');
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 600)); await tester.pump(const Duration(milliseconds: 600));
@@ -0,0 +1,125 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/settings/settings_screen.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
import 'pipelines_app_test.dart' show webServer;
import 'pipelines_replies.dart';
/// Settings is not a tab: it opens as a page from the gear in the Pipelines
/// bar, keeps its `/settings` route (and deep link), and closes back to
/// Pipelines. The tab bar keeps Pipelines selected meanwhile.
void main() {
Future<PlatformRouteInformationProvider> pumpApp(
WidgetTester tester, {
required bool cupertino,
required String location,
required Size size,
}) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final channel = FakeChannel()..readyCompleter.complete();
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse(location)),
);
addTearDown(provider.dispose);
await tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: PipelinesClient(channelFactory: (_) => channel),
cupertino: cupertino,
routeInformationProvider: provider,
),
);
await tester.pump();
if (location == '/pipelines') {
await replyPipelines(tester, channel, PipelineFixture());
}
return provider;
}
int selectedTab(WidgetTester tester) => tester
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
.currentIndex;
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final size in [const Size(390, 844), const Size(1200, 800)]) {
testWidgets('$host ${size.width}: the Pipelines bar gear opens Settings '
'as a page and Back returns', (tester) async {
final provider = await pumpApp(
tester,
cupertino: cupertino,
location: '/pipelines',
size: size,
);
// Four tabs; Settings is none of them.
expect(
tester
.widget<FloatingDestinationBar>(
find.byType(FloatingDestinationBar),
)
.items
.map((item) => item.label),
['Pipelines', 'Runs', 'Chat', 'Search'],
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.tap(find.byKey(const Key('pipelines-open-settings')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.text('Server URL'), findsOneWidget);
// A page of Pipelines: Back in its bar, Pipelines still selected.
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(selectedTab(tester), 0);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
expect(find.byKey(const Key('pipelines-open-settings')), findsWidgets);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
testWidgets('$host: the /settings deep link opens the Settings page and '
'the system Back closes it to Pipelines', (tester) async {
final provider = await pumpApp(
tester,
cupertino: cupertino,
location: '/settings',
size: const Size(390, 844),
);
await tester.pump();
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(selectedTab(tester), 0);
final handled = await tester.binding.handlePopRoute();
expect(handled, isTrue, reason: 'Back closes the page, not the app');
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
}
@@ -51,7 +51,7 @@ void main() {
); );
await replyPipelines(tester, channel, PipelineFixture()); await replyPipelines(tester, channel, PipelineFixture());
await tester.tap(find.text('Settings').last); await tester.tap(find.byKey(const Key('pipelines-open-settings')));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(provider.value.uri.path, '/settings'); expect(provider.value.uri.path, '/settings');
@@ -93,7 +93,7 @@ Future<void> openSettings(
FakeChannel channel, FakeChannel channel,
PlatformRouteInformationProvider provider, PlatformRouteInformationProvider provider,
) async { ) async {
await tester.tap(find.text('Settings').last); await tester.tap(find.byKey(const Key('pipelines-open-settings')));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(provider.value.uri.path, '/settings'); expect(provider.value.uri.path, '/settings');
@@ -354,7 +354,7 @@ void main() {
await tester.pump(); await tester.pump();
await tester.tap(find.byKey(templatesPageBackKey)); await tester.tap(find.byKey(templatesPageBackKey));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.text('Pipelines').last); await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(provider.value.uri.path, '/pipelines'); expect(provider.value.uri.path, '/pipelines');
@@ -64,7 +64,9 @@ void main() {
await tester.tap(find.text('First chat')); await tester.tap(find.text('First chat'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final navigator = tester.state<NavigatorState>(find.byType(Navigator)); final navigator = tester.state<NavigatorState>(
find.byType(Navigator).first,
);
expect(navigator.canPop(), isFalse, reason: 'No page covers the shell'); expect(navigator.canPop(), isFalse, reason: 'No page covers the shell');
expect(find.byType(NavigationRail), findsNothing); expect(find.byType(NavigationRail), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget); expect(find.byType(FloatingDestinationBar), findsOneWidget);
@@ -106,7 +108,7 @@ void main() {
expect(navigator.canPop(), isFalse); expect(navigator.canPop(), isFalse);
// The rail still switches destinations with a chat open. // The rail still switches destinations with a chat open.
await tester.tap(find.text('Runs')); await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('chat-thread-b')), findsNothing); expect(find.byKey(const ValueKey('chat-thread-b')), findsNothing);
@@ -120,7 +122,9 @@ void main() {
await tester.tap(find.text('First chat')); await tester.tap(find.text('First chat'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final navigator = tester.state<NavigatorState>(find.byType(Navigator)); final navigator = tester.state<NavigatorState>(
find.byType(Navigator).first,
);
expect(navigator.canPop(), isTrue); expect(navigator.canPop(), isTrue);
expect(findNativeBack(), findsOneWidget); expect(findNativeBack(), findsOneWidget);
expect(find.byType(NavigationBar), findsNothing); expect(find.byType(NavigationBar), findsNothing);
@@ -46,9 +46,11 @@ Future<void> _pumpScreen(WidgetTester tester) async {
Future<void> _openGraphTab(WidgetTester tester, int pipelineId) async { Future<void> _openGraphTab(WidgetTester tester, int pipelineId) async {
await tester.tap(find.byKey(Key('pipeline-row-$pipelineId'))); await tester.tap(find.byKey(Key('pipeline-row-$pipelineId')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.ensureVisible(find.text('Graph')); await tester.ensureVisible(
find.byKey(const Key('pipeline-detail-tab-graph')),
);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.text('Graph')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
} }
@@ -61,9 +61,11 @@ Future<void> _openGraphTab(WidgetTester tester, int pipelineId) async {
// The detail header scrolls when content-driven title/tab height needs it // The detail header scrolls when content-driven title/tab height needs it
// (the header gained the native Run action), so reach the tab like an // (the header gained the native Run action), so reach the tab like an
// operator would instead of requiring it to fit without scrolling. // operator would instead of requiring it to fit without scrolling.
await tester.ensureVisible(find.text('Graph')); await tester.ensureVisible(
find.byKey(const Key('pipeline-detail-tab-graph')),
);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.text('Graph')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
} }
@@ -203,9 +205,9 @@ void main() {
// The selection belongs to the panel, so an in-place tab round trip keeps // The selection belongs to the panel, so an in-place tab round trip keeps
// the same node marked (the web keeps its graph selection across tabs). // the same node marked (the web keeps its graph selection across tabs).
await tester.tap(find.text('Summary')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.text('Graph')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(tester.widget<GraphStageNode>(_node('review')).selected, isTrue); expect(tester.widget<GraphStageNode>(_node('review')).selected, isTrue);
@@ -227,14 +229,14 @@ void main() {
// The selection belongs to the pinned definition: changing version must not // The selection belongs to the pinned definition: changing version must not
// carry a same-named node's mark into the other version. // carry a same-named node's mark into the other version.
await tester.tap(find.text('Summary')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.ensureVisible(find.byKey(const Key('pipeline-version-1'))); await tester.ensureVisible(find.byKey(const Key('pipeline-version-1')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-version-1'))); await tester.tap(find.byKey(const Key('pipeline-version-1')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget); expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
await tester.tap(find.text('Graph')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(tester.widget<GraphStageNode>(_node('review')).selected, isFalse); expect(tester.widget<GraphStageNode>(_node('review')).selected, isFalse);
@@ -75,14 +75,14 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(gateway.callsOf('list_schedules').single.fields, {'pipeline_id': 1}); expect(gateway.callsOf('list_schedules').single.fields, {'pipeline_id': 1});
await tester.tap(find.text('Source')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump(); await tester.pump();
expect(find.text('name: alpha'), findsOneWidget); expect(find.text('name: alpha'), findsOneWidget);
await tester.tap(find.text('Graph')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(find.byKey(scheduleAddKey), findsNothing); expect(find.byKey(scheduleAddKey), findsNothing);
await tester.tap(find.text('Summary')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Research batteries'), findsOneWidget); expect(find.text('Research batteries'), findsOneWidget);
}); });
@@ -81,7 +81,7 @@ void main() {
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name); expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name); expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
} }
await tester.tap(find.text('Source')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(selected, PipelineDetailTab.source); expect(selected, PipelineDetailTab.source);
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
@@ -68,9 +68,11 @@ void main() {
await tester.tap(find.byKey(const Key('pipeline-row-1'))); await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
await tester.ensureVisible(find.text('Source')); await tester.ensureVisible(
find.byKey(const Key('pipeline-detail-tab-source')),
);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.text('Source')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
expect( expect(
@@ -153,7 +155,7 @@ void main() {
await tester.tap(find.byKey(const Key('pipeline-version-1'))); await tester.tap(find.byKey(const Key('pipeline-version-1')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget); expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
await tester.tap(find.text('Source')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump(); await tester.pump();
expect( expect(
selectableText( selectableText(
@@ -199,9 +201,11 @@ void main() {
// The header scrolls instead of squeezing the tab out; the tabs stay // The header scrolls instead of squeezing the tab out; the tabs stay
// reachable inside it and the tab keeps a bounded slot. // reachable inside it and the tab keeps a bounded slot.
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
await tester.ensureVisible(find.text('Graph')); await tester.ensureVisible(
find.byKey(const Key('pipeline-detail-tab-graph')),
);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.text('Graph')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph')));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
@@ -45,7 +45,7 @@ void main() {
'version': 2, 'version': 2,
}); });
await tester.tap(find.text('Source')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump(); await tester.pump();
expect( expect(
selectableText('name: Alpha review\nstages:\n review:\n type: model'), selectableText('name: Alpha review\nstages:\n review:\n type: model'),
@@ -73,7 +73,7 @@ void main() {
}); });
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget); expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
await tester.tap(find.text('Source')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump(); await tester.pump();
expect( expect(
selectableText( selectableText(
@@ -83,7 +83,7 @@ void main() {
findsOneWidget, findsOneWidget,
); );
await tester.tap(find.text('Summary')); await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary')));
await tester.pump(); await tester.pump();
await tester.tap(find.byKey(const Key('pipeline-latest-version'))); await tester.tap(find.byKey(const Key('pipeline-latest-version')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@@ -112,7 +112,10 @@ void main() {
await tester.tap(find.byKey(const ValueKey('run-detail-tab-changes'))); await tester.tap(find.byKey(const ValueKey('run-detail-tab-changes')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Changes'), findsOneWidget); expect(
find.byKey(const ValueKey('run-detail-tab-changes')),
findsOneWidget,
);
expect(find.text('lib/feature.dart'), findsOneWidget); expect(find.text('lib/feature.dart'), findsOneWidget);
expect( expect(
find.text('1 file changed · +2 -2 · capture incomplete'), find.text('1 file changed · +2 -2 · capture incomplete'),
@@ -24,21 +24,31 @@ void main() {
RunDetailTab.changes, RunDetailTab.changes,
]); ]);
final strip = find.byKey(const Key('run-detail-tabs')); final strip = find.byKey(const Key('run-detail-tabs'));
for (final label in ['Summary', 'Timeline', 'Artifacts', 'Changes']) { // Icon-only tabs, each keyed by its name.
for (final name in ['summary', 'timeline', 'artifacts', 'changes']) {
expect( expect(
find.descendant(of: strip, matching: find.text(label)), find.descendant(
of: strip,
matching: find.byKey(ValueKey('run-detail-tab-$name')),
),
findsOneWidget, findsOneWidget,
); );
} }
expect( expect(
find.descendant(of: strip, matching: find.text('Graph')), find.descendant(
of: strip,
matching: find.byKey(const ValueKey('run-detail-tab-graph')),
),
findsNothing, findsNothing,
); );
expect(find.byKey(runGraphPreviewKey), findsOneWidget); expect(find.byKey(runGraphPreviewKey), findsOneWidget);
// Input and Output are Summary sections now, never separate tabs. // Input and Output are Summary sections now, never separate tabs.
for (final label in ['Input', 'Output']) { for (final name in ['input', 'output']) {
expect( expect(
find.descendant(of: strip, matching: find.text(label)), find.descendant(
of: strip,
matching: find.byKey(ValueKey('run-detail-tab-$name')),
),
findsNothing, findsNothing,
); );
} }
@@ -165,9 +165,12 @@ void main() {
} }
Future<void> tapTab(String label) async { Future<void> tapTab(String label) async {
await tester.ensureVisible(find.text(label)); final tab = find.byKey(
ValueKey('run-detail-tab-${label.toLowerCase()}'),
);
await tester.ensureVisible(tab);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.text(label)); await tester.tap(tab);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
+3 -3
View File
@@ -92,13 +92,13 @@ void main() {
testWidgets('the badge stays visible from every destination', (tester) async { testWidgets('the badge stays visible from every destination', (tester) async {
await pumpShell(tester, width: 1000, cupertino: false, count: 2); await pumpShell(tester, width: 1000, cupertino: false, count: 2);
for (final label in ['Runs', 'Chat', 'Settings']) { for (final name in ['runs', 'chat', 'search']) {
await tester.tap(find.text(label).last); await tester.tap(find.byKey(ValueKey('shell.destination.$name')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
find.descendant(of: find.byType(Badge), matching: find.text('2')), find.descendant(of: find.byType(Badge), matching: find.text('2')),
findsOneWidget, findsOneWidget,
reason: 'badge missing on $label', reason: 'badge missing on $name',
); );
} }
}); });
+16 -10
View File
@@ -14,11 +14,6 @@ void main() {
matching: find.byType(GlassPill), matching: find.byType(GlassPill),
); );
Finder barText(String label) => find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.text(label),
);
Future<void> setSize(WidgetTester tester, Size size) async { Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size; tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1; tester.view.devicePixelRatio = 1;
@@ -74,7 +69,14 @@ void main() {
expect(rect.right, 1200 - 16); expect(rect.right, 1200 - 16);
expect(rect.bottom, 800 - 16); expect(rect.bottom, 800 - 16);
expect(rect.width, lessThan(1200 * 0.6)); expect(rect.width, lessThan(1200 * 0.6));
expect(rect.width, greaterThan(5 * 72)); // Four icon-only tabs (Settings opens from the Pipelines bar).
expect(
rect.width,
4 *
(cupertino
? FloatingDestinationBar.cupertinoTabWidth
: FloatingDestinationBar.materialTabWidth),
);
// No rail or sidebar: the content starts at the left edge. // No rail or sidebar: the content starts at the left edge.
expect(find.byType(NavigationRail), findsNothing); expect(find.byType(NavigationRail), findsNothing);
expect(find.byType(CupertinoListTile), findsNothing); expect(find.byType(CupertinoListTile), findsNothing);
@@ -143,12 +145,16 @@ void main() {
await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pumpWidget(shell(cupertino: cupertino));
await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( final runs = tester.getSemantics(
tester.getSemantics(barText('Runs')), find.byKey(const ValueKey('shell.destination.runs')),
isSemantics(isSelected: true),
); );
expect(runs, isSemantics(isSelected: true));
// Icon-only, yet the tab keeps its name for assistive technology.
expect(runs.label, startsWith('Runs'));
expect( expect(
tester.getSemantics(barText('Chat')), tester.getSemantics(
find.byKey(const ValueKey('shell.destination.chat')),
),
isNot(isSemantics(isSelected: true)), isNot(isSemantics(isSelected: true)),
); );
semantics.dispose(); semantics.dispose();
+6 -3
View File
@@ -151,7 +151,7 @@ void main() {
}); });
testWidgets('$host 1200: the item\'s tabs float at the bottom of its ' testWidgets('$host 1200: the item\'s tabs float at the bottom of its '
'pane, beside the shell\'s tab bar', (tester) async { 'pane, above the shell\'s tab bar', (tester) async {
await setSize(tester, const Size(1200, 800)); await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump(); await tester.pump();
@@ -174,8 +174,11 @@ void main() {
final body = tester.getRect( final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')), find.byKey(const ValueKey('list-detail-body')),
); );
// Near the bottom of the detail pane, never on the shell's tabs. // The shell's tabs keep the bottom right; the item's float a gap
expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); // above them in the detail pane, never on them.
expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(shellTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(itemTabs.bottom, closeTo(shellTabs.top - kStackedBarGap, 0.5));
expect(itemTabs.left, greaterThanOrEqualTo(body.left)); expect(itemTabs.left, greaterThanOrEqualTo(body.left));
expect(itemTabs.overlaps(shellTabs), isFalse); expect(itemTabs.overlaps(shellTabs), isFalse);
// The item's list starts below its bar and clears its tabs at rest. // The item's list starts below its bar and clears its tabs at rest.
+18 -3
View File
@@ -52,13 +52,28 @@ void main() {
expect(find.byKey(const Key('run-more')), findsNothing); expect(find.byKey(const Key('run-more')), findsNothing);
}); });
testWidgets('$host: Search is the fifth tab', (tester) async { testWidgets('$host: Search is the fourth tab; Settings is not a tab', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844); tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1; tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset); addTearDown(tester.view.reset);
await tester.pumpWidget(_app(cupertino: cupertino, open: false)); await tester.pumpWidget(_app(cupertino: cupertino, open: false));
expect(AppDestination.values, hasLength(5)); expect(AppDestination.values, hasLength(5));
expect(find.text('Search'), findsOneWidget); expect(shellTabDestinations, [
AppDestination.pipelines,
AppDestination.runs,
AppDestination.chat,
AppDestination.search,
]);
expect(
find.byKey(const ValueKey('shell.destination.search')),
findsOneWidget,
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.search')), findsNothing); expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget); expect(find.byType(FloatingDestinationBar), findsOneWidget);
}); });
@@ -76,7 +91,7 @@ void main() {
matching: find.byType(GlassPill), matching: find.byType(GlassPill),
); );
expect(tester.getSize(destinationPill).width, 358); expect(tester.getSize(destinationPill).width, 358);
await tester.tap(find.text('Chat')); await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pump(); await tester.pump();
expect(find.text('Chat — Not implemented'), findsOneWidget); expect(find.text('Chat — Not implemented'), findsOneWidget);
}); });
+92 -20
View File
@@ -5,11 +5,13 @@ import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/list_detail.dart'; import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart'; import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
/// While a tab shows its list beside an open item, the shell's destination /// While a tab shows its list beside an open item, the shell's destination
/// bar floats over the list pane only: it never covers the item, and the /// bar keeps its place at the bottom right (near the thumb). The item's own
/// item's own bottom control (a composer) owns the pane's bottom edge. /// bottom control (its tabs, or a composer) floats above it with a gap, and
/// the item's content clears both.
void main() { void main() {
Future<void> setSize(WidgetTester tester, Size size) async { Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size; tester.view.physicalSize = size;
@@ -43,9 +45,36 @@ void main() {
), ),
); );
/// A detail with its own floating tabs over a list, like run detail.
Widget tabsDetail(bool cupertino) => FloatingBarOverlay(
bar: KeyedSubtree(
key: const Key('detail-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
currentIndex: 0,
onTap: (_) {},
items: const [
FloatingDestinationItem(icon: Icon(Icons.summarize), label: 'One'),
FloatingDestinationItem(icon: Icon(Icons.timeline), label: 'Two'),
FloatingDestinationItem(icon: Icon(Icons.inventory), label: 'Three'),
],
),
),
child: Builder(
builder: (context) => ListView(
key: const Key('detail-list'),
children: [
for (var index = 0; index < 40; index++)
SizedBox(height: 40, child: Text('item $index')),
],
),
),
);
Widget shell({ Widget shell({
required bool cupertino, required bool cupertino,
bool split = true, bool split = true,
bool tabs = false,
double textScale = 1, double textScale = 1,
}) { }) {
final app = AdaptiveShell( final app = AdaptiveShell(
@@ -53,7 +82,10 @@ void main() {
destination: AppDestination.chat, destination: AppDestination.chat,
destinationBodies: { destinationBodies: {
AppDestination.chat: (_) => split AppDestination.chat: (_) => split
? ListDetailPanes(list: listBody(), detail: composerDetail()) ? ListDetailPanes(
list: listBody(),
detail: tabs ? tabsDetail(cupertino) : composerDetail(),
)
: listBody(), : listBody(),
}, },
); );
@@ -78,8 +110,8 @@ void main() {
final host = cupertino ? 'Cupertino' : 'Material'; final host = cupertino ? 'Cupertino' : 'Material';
for (final width in [1200.0, 1600.0]) { for (final width in [1200.0, 1600.0]) {
testWidgets('$host $width split: the destination bar stays over the ' testWidgets('$host $width split: the destination bar stays bottom '
'list pane and the composer owns the detail bottom', (tester) async { 'right and the composer floats above it', (tester) async {
await setSize(tester, Size(width, 800)); await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump(); await tester.pump();
@@ -92,23 +124,59 @@ void main() {
find.byKey(const ValueKey('list-detail-body')), find.byKey(const ValueKey('list-detail-body')),
); );
final pill = destinationPill(tester); final pill = destinationPill(tester);
expect(pill.right, lessThanOrEqualTo(list.right)); // Compact at the window's right edge, over the detail pane only.
expect(pill.left, greaterThanOrEqualTo(list.left)); expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
expect(pill.overlaps(body), isFalse, reason: 'no overlap with detail');
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(pill.width, lessThan(body.width / 2));
expect(pill.overlaps(list), isFalse, reason: 'never over the list');
expect(pill.left, greaterThan(body.left));
// The detail keeps only the system inset (none here): its composer // The composer's box starts a gap above the shell's pill (the real
// reaches the bottom edge, below the level of the shell's pill. // composer pads its pill by another 12 inside that box).
final composer = tester.getRect(find.byKey(const Key('composer'))); final composer = tester.getRect(find.byKey(const Key('composer')));
expect(composer.bottom, 800);
expect(composer.left, body.left); expect(composer.left, body.left);
expect(composer.top, greaterThan(pill.top)); expect(composer.overlaps(pill), isFalse);
expect(pill.top - composer.bottom, closeTo(kStackedBarGap, 0.5));
// The list still clears the bar. // The list is not under the bar: it clears only the system inset.
final listContext = tester.element(find.byKey(const Key('list'))); final listContext = tester.element(find.byKey(const Key('list')));
expect(MediaQuery.paddingOf(listContext).bottom, 0);
});
testWidgets('$host $width split: the item tabs float above the '
'destination bar with a gap, and its content clears both', (
tester,
) async {
await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino, tabs: true));
await tester.pump();
await tester.pump();
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final pill = destinationPill(tester);
final tabs = tester.getRect(
find
.descendant(
of: find.byKey(const Key('detail-tabs')),
matching: find.byType(GlassPill),
)
.first,
);
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5));
expect(tabs.left, greaterThan(body.left));
expect(tabs.overlaps(pill), isFalse);
expect(pill.top - tabs.bottom, closeTo(kStackedBarGap, 0.5));
// The item's list pads its end clear of both pills.
final listContext = tester.element(
find.byKey(const Key('detail-list')),
);
expect( expect(
MediaQuery.paddingOf(listContext).bottom, MediaQuery.paddingOf(listContext).bottom,
greaterThanOrEqualTo(pill.height), closeTo(800 - tabs.top, 0.5),
); );
}); });
} }
@@ -134,17 +202,21 @@ void main() {
}); });
for (final width in [600.0, 840.0]) { for (final width in [600.0, 840.0]) {
testWidgets('$host $width split at 2x: the narrow list pane bar lays ' testWidgets('$host $width split at 2x: both bars lay out over the '
'out without overflow', (tester) async { 'detail pane without overflow', (tester) async {
await setSize(tester, Size(width, 800)); await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino, textScale: 2)); await tester.pumpWidget(
shell(cupertino: cupertino, tabs: true, textScale: 2),
);
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
final list = tester.getRect( final body = tester.getRect(
find.byKey(const ValueKey('list-detail-list')), find.byKey(const ValueKey('list-detail-body')),
); );
expect(destinationPill(tester).right, lessThanOrEqualTo(list.right)); final pill = destinationPill(tester);
expect(pill.left, greaterThanOrEqualTo(body.left));
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
}); });
} }
} }
+136
View File
@@ -0,0 +1,136 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/detail_page.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import '../features/runs/ui/run_detail_graph_support.dart';
import '../features/runs/ui/run_detail_visit_support.dart';
/// On a wide split window (unfolded foldable, desktop) the real run detail
/// and the stage page it opens keep the shell's tab bar at the bottom right
/// and float their own tabs above it with a gap; the stage page opens inside
/// the detail pane instead of covering the shell.
void main() {
Rect pillOf(WidgetTester tester, Finder owner) => tester.getRect(
find.descendant(of: owner, matching: find.byType(GlassPill)).first,
);
Rect shellPill(WidgetTester tester) => tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byType(GlassPill),
)
.first,
);
Future<void> pumpSplitRun(WidgetTester tester, bool cupertino) async {
tester.view.physicalSize = const Size(1200, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = RunDetailFakeGateway(visitRunFixture());
final controller = RunsController(RunsRepository(gateway));
addTearDown(controller.dispose);
await controller.select(77);
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.runs,
destinationBodies: {
AppDestination.runs: (_) => ListDetailPanes(
list: ListView(
children: [for (var i = 0; i < 30; i++) Text('run row $i')],
),
detail: DetailPane(
destination: AppDestination.runs,
implyBack: false,
builder: (_) => RunDetailView(
controller: controller,
gateway: gateway,
onBack: () {},
),
),
),
},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: shell)
: MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: shell,
),
);
await tester.pumpAndSettle();
}
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host 1200: run tabs float above the shell bar, and the '
'stage page opens in the pane with its tabs above it too', (
tester,
) async {
await pumpSplitRun(tester, cupertino);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
var main = shellPill(tester);
expect(main.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs')));
expect(runTabs.left, greaterThanOrEqualTo(body.left));
expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(runTabs.overlaps(main), isFalse);
expect(main.top - runTabs.bottom, closeTo(kStackedBarGap, 0.5));
// Open the stage page from the timeline.
await openRunDetailTab(tester, RunDetailTab.timeline);
final row = find.byKey(const ValueKey('run-timeline-visit-1'));
await tester.ensureVisible(row);
await tester.pumpAndSettle();
await tester.tap(row);
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
// The page covers only the detail pane: the root navigator has nothing
// pushed, and the list and the shell's tab bar stay in place.
expect(
tester.state<NavigatorState>(find.byType(Navigator).first).canPop(),
isFalse,
);
expect(find.text('run row 0'), findsOneWidget);
final back = tester.getRect(find.byKey(const Key('run-visit-back')));
expect(back.left, greaterThanOrEqualTo(body.left));
main = shellPill(tester);
expect(main.right, closeTo(1200 - kFloatingBarMargin, 0.5));
final visitTabs = pillOf(
tester,
find.byKey(const Key('run-visit-tabs')).last,
);
expect(visitTabs.left, greaterThanOrEqualTo(body.left));
expect(visitTabs.overlaps(main), isFalse);
expect(main.top - visitTabs.bottom, closeTo(kStackedBarGap, 0.5));
expect(tester.takeException(), isNull);
// The shell's tabs still work over the open stage page.
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
// Back closes the page inside the pane, back to the run.
await tester.tap(find.byKey(const Key('run-visit-back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-back')), findsNothing);
expect(find.byKey(const Key('run-detail-tabs')), findsOneWidget);
});
}
}
+18 -9
View File
@@ -15,15 +15,19 @@ import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
/// On a wide split window (an unfolded foldable) under a system status bar, /// On a wide split window (an unfolded foldable) under a system status bar,
/// every pane's bar sits below the status-bar inset while content still /// every pane's bar sits below the status-bar inset while content still
/// reaches the top edge; and the open item's tabs float at the bottom of the /// reaches the top edge; and the open item's tabs float at the bottom of the
/// detail pane, beside (never on) the shell's tab bar over the list. /// detail pane, above (never on) the shell's tab bar at the bottom right.
void main() { void main() {
const statusBar = 40.0; const statusBar = 40.0;
Future<void> setUp(WidgetTester tester, Size size) async { Future<void> setUp(
WidgetTester tester,
Size size, {
double bottom = 0,
}) async {
tester.view.physicalSize = size; tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1; tester.view.devicePixelRatio = 1;
tester.view.padding = const FakeViewPadding(top: statusBar); tester.view.padding = FakeViewPadding(top: statusBar, bottom: bottom);
tester.view.viewPadding = const FakeViewPadding(top: statusBar); tester.view.viewPadding = FakeViewPadding(top: statusBar, bottom: bottom);
addTearDown(tester.view.reset); addTearDown(tester.view.reset);
} }
@@ -156,9 +160,10 @@ void main() {
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0); expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
}); });
testWidgets('$host split: the item tabs float at the bottom of the ' testWidgets('$host split: the item tabs float above the shell tab bar '
'detail pane, beside the shell tab bar over the list', (tester) async { 'at the bottom right of the detail pane', (tester) async {
await setUp(tester, const Size(1200, 800)); // A gesture-navigation inset as on the unfolded foldable.
await setUp(tester, const Size(1200, 800), bottom: 24);
await tester.pumpWidget(shell(cupertino, tabbedItem)); await tester.pumpWidget(shell(cupertino, tabbedItem));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
@@ -167,7 +172,6 @@ void main() {
find.byKey(const ValueKey('list-detail-body')), find.byKey(const ValueKey('list-detail-body')),
); );
final tabs = pillsOf(tester, find.byKey(const Key('item-tabs'))).single; final tabs = pillsOf(tester, find.byKey(const Key('item-tabs'))).single;
expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(tabs.left, greaterThanOrEqualTo(body.left)); expect(tabs.left, greaterThanOrEqualTo(body.left));
expect(tabs.right, lessThanOrEqualTo(body.right)); expect(tabs.right, lessThanOrEqualTo(body.right));
final shellTabs = tester.getRect( final shellTabs = tester.getRect(
@@ -178,8 +182,13 @@ void main() {
) )
.first, .first,
); );
// The shell's bar keeps the bottom right, above the system inset; the
// item's tabs sit a gap above it, both at the trailing edge.
expect(shellTabs.bottom, closeTo(800 - 24, 0.5));
expect(shellTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(shellTabs.overlaps(tabs), isFalse); expect(shellTabs.overlaps(tabs), isFalse);
expect(shellTabs.right, lessThanOrEqualTo(body.left)); expect(shellTabs.top - tabs.bottom, closeTo(kStackedBarGap, 0.5));
// The item's list clears its tabs at rest. // The item's list clears its tabs at rest.
final list = tester.element(find.byKey(const Key('item-list'))); final list = tester.element(find.byKey(const Key('item-list')));
expect( expect(
@@ -0,0 +1,127 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
/// Every bottom tab bar shows icons only, yet each tab keeps its name for
/// assistive technology (and a Material tooltip), its selected state and its
/// test key; the icons within a bar, and against the shell's tabs a detail's
/// bar floats above, are distinct.
void main() {
Widget host(bool cupertino, Widget bar) {
final body = Align(alignment: Alignment.bottomCenter, child: bar);
return cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body));
}
final bars = <String, (Widget, List<(String, String)>)>{
'run detail': (
RunDetailTabStrip(selected: RunDetailTab.summary, onSelected: (_) {}),
[
for (final tab in renderedRunDetailTabs)
('run-detail-tab-${tab.name}', tab.label),
],
),
'stage page': (
RunVisitSectionStrip(
selected: RunVisitSection.summary,
onSelected: (_) {},
),
[
for (final section in shownVisitSections)
('run-visit-tab-${section.name}', section.label),
],
),
'pipeline detail': (
PipelineDetailTabs(
selected: PipelineDetailTab.summary,
onSelected: (_) {},
),
[
for (final tab in PipelineDetailTab.values)
('pipeline-detail-tab-${tab.name}', tab.label),
],
),
};
for (final cupertino in [false, true]) {
final name = cupertino ? 'Cupertino' : 'Material';
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
testWidgets('$name $label tabs are icons named for assistive '
'technology', (tester) async {
final semantics = tester.ensureSemantics();
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(host(cupertino, bar));
await tester.pumpAndSettle();
final floating = find.byType(FloatingDestinationBar);
if (cupertino) {
// No label is drawn at all.
expect(
find.descendant(of: floating, matching: find.byType(Text)),
findsNothing,
);
} else {
// NavigationBar keeps its label hidden (for semantics only).
expect(
NavigationBarTheme.of(
tester.element(find.byType(NavigationDestination).first),
).labelBehavior,
NavigationDestinationLabelBehavior.alwaysHide,
);
}
for (final (index, (key, tabLabel)) in tabs.indexed) {
final node = tester.getSemantics(find.byKey(ValueKey(key)));
expect(node.label, startsWith(tabLabel), reason: key);
expect(
node,
index == 0
? isSemantics(isSelected: true)
: isNot(isSemantics(isSelected: true)),
reason: key,
);
}
// Distinct glyphs within the bar.
final icons = tester
.widgetList<Icon>(
find.descendant(of: floating, matching: find.byType(Icon)),
)
.map((icon) => icon.icon)
.toSet();
expect(icons.length, greaterThanOrEqualTo(tabs.length));
semantics.dispose();
});
}
}
test('detail tab icons differ from the shell tabs they float above', () {
final shell = {
for (final destination in shellTabDestinations) ...[
destinationDetails(destination).icon,
destinationDetails(destination).cupertinoIcon,
],
};
final details = [
for (final tab in renderedRunDetailTabs) ...[tab.icon, tab.cupertinoIcon],
for (final section in shownVisitSections) ...[
section.icon,
section.cupertinoIcon,
],
for (final tab in PipelineDetailTab.values) ...[
tab.icon,
tab.cupertinoIcon,
],
];
for (final icon in details) {
expect(shell.contains(icon), isFalse, reason: '$icon');
}
});
}
+3 -3
View File
@@ -28,7 +28,7 @@ void main() {
expect(find.byType(NavigationBar), findsOneWidget); expect(find.byType(NavigationBar), findsOneWidget);
expect(find.byType(NavigationRail), findsNothing); expect(find.byType(NavigationRail), findsNothing);
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
await tester.tap(find.text('Runs').last); await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Runs — Not implemented'), findsOneWidget); expect(find.text('Runs — Not implemented'), findsOneWidget);
}, },
@@ -104,9 +104,9 @@ void main() {
); );
await tester.tap(find.text('Builds: 0')); await tester.tap(find.text('Builds: 0'));
await tester.pump(); await tester.pump();
await tester.tap(find.text('Runs').last); await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.text('Pipelines').last); await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Builds: 1'), findsOneWidget); expect(find.text('Builds: 1'), findsOneWidget);
}); });