diff --git a/app/lib/features/pipelines/screen.dart b/app/lib/features/pipelines/screen.dart index 1dfaa318..54c8f80b 100644 --- a/app/lib/features/pipelines/screen.dart +++ b/app/lib/features/pipelines/screen.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../core/api_gateway.dart'; +import '../../shell/shell_bar.dart'; import 'pipeline_models.dart'; import 'pipeline_repository.dart'; import 'pipelines_controller.dart'; @@ -224,9 +225,20 @@ class _PipelinesScreenState extends State { ); } - /// The shell owns the navigation bar here, so the content keeps a native - /// Refresh action without adding a second bar. + /// The shell owns the navigation bar here: the list puts filter, sort and + /// refresh in it; an open pipeline on a phone keeps refresh only. Widget _embeddedBody(BuildContext context, Widget body) { + if (ShellBar.available(context)) { + final wide = MediaQuery.sizeOf(context).width >= kPipelinesWideBreakpoint; + final listShown = wide || !_controller.hasSelection; + return ShellBar( + actions: [ + if (listShown) ...pipelineListActions(context, _controller), + _refreshButton(context), + ], + child: body, + ); + } return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -234,7 +246,13 @@ class _PipelinesScreenState extends State { alignment: AlignmentDirectional.centerEnd, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8), - child: _refreshButton(context), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + ...pipelineListActions(context, _controller), + _refreshButton(context), + ], + ), ), ), Expanded(child: body), @@ -275,7 +293,10 @@ class _PipelinesScreenState extends State { return Scaffold( appBar: AppBar( title: const Text('Pipelines'), - actions: [_refreshButton(context)], + actions: [ + ...pipelineListActions(context, _controller), + _refreshButton(context), + ], ), body: SafeArea(child: body), ); @@ -285,7 +306,13 @@ class _PipelinesScreenState extends State { return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( middle: const Text('Pipelines'), - trailing: _refreshButton(context), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + ...pipelineListActions(context, _controller), + _refreshButton(context), + ], + ), ), child: SafeArea(top: false, child: body), ); diff --git a/app/lib/features/pipelines/widgets/pipeline_controls.dart b/app/lib/features/pipelines/widgets/pipeline_controls.dart index 27648e55..fd1b0395 100644 --- a/app/lib/features/pipelines/widgets/pipeline_controls.dart +++ b/app/lib/features/pipelines/widgets/pipeline_controls.dart @@ -87,19 +87,32 @@ class PipelineSortButton extends StatelessWidget { super.key, required this.sort, required this.onSelected, + this.icon = false, }); final PipelineSort sort; final ValueChanged onSelected; + /// An app-bar icon instead of a labelled button. + final bool icon; + @override Widget build(BuildContext context) { final label = 'Sort: ${sort.label}'; if (useCupertinoControls(context)) { - return CupertinoButton( - padding: EdgeInsets.zero, - onPressed: () => _showCupertinoSheet(context), - child: Text(label), + return Semantics( + button: true, + label: icon ? 'Sort pipelines: ${sort.label}' : null, + excludeSemantics: icon, + child: CupertinoButton( + padding: icon + ? const EdgeInsets.symmetric(horizontal: 6) + : EdgeInsets.zero, + onPressed: () => _showCupertinoSheet(context), + child: icon + ? const Icon(CupertinoIcons.arrow_up_arrow_down) + : Text(label), + ), ); } return MenuAnchor( @@ -110,10 +123,16 @@ class PipelineSortButton extends StatelessWidget { child: Text(option.label), ), ], - builder: (context, menu, child) => TextButton( - onPressed: () => menu.isOpen ? menu.close() : menu.open(), - child: Text(label), - ), + builder: (context, menu, child) => icon + ? IconButton( + tooltip: 'Sort pipelines: ${sort.label}', + onPressed: () => menu.isOpen ? menu.close() : menu.open(), + icon: const Icon(Icons.sort), + ) + : TextButton( + onPressed: () => menu.isOpen ? menu.close() : menu.open(), + child: Text(label), + ), ); } diff --git a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart index 9e5423d1..e24c33fc 100644 --- a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart @@ -62,52 +62,28 @@ class PipelineListPanel extends StatelessWidget { /// The web's compact toolbar: filter (whose page carries the name search), /// sort and clear, on the list's 12px inset with a separator underneath. + /// Filter and sort are in the app bar; only an active filter keeps a + /// one-tap way back here. Widget _toolbar( BuildContext context, PipelineFilters filters, bool hasUnclassified, ) { - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: kPipelineListInset, - vertical: 2, - ), - child: Wrap( - key: const Key('pipeline-toolbar'), - spacing: 4, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - PipelineTextButton( - key: const Key('pipeline-filter'), - label: filters.count == 0 - ? 'Filter' - : 'Filter (${filters.count})', - onPressed: () => openPipelineFilters( - context, - initial: filters, - hasUnclassified: hasUnclassified, - onApply: controller.setFilters, - ), - ), - PipelineSortButton( - key: const Key('pipeline-sort'), - sort: controller.sort, - onSelected: controller.setSort, - ), - if (filters.active) - PipelineTextButton( - key: const Key('pipeline-clear-filters'), - label: 'Clear filters', - onPressed: controller.clearFilters, - ), - ], - ), + if (!filters.active) return const SizedBox.shrink(); + return Padding( + key: const Key('pipeline-toolbar'), + padding: const EdgeInsets.symmetric( + horizontal: kPipelineListInset, + vertical: 2, + ), + child: Align( + alignment: AlignmentDirectional.centerStart, + child: PipelineTextButton( + key: const Key('pipeline-clear-filters'), + label: 'Clear filters (${filters.count})', + onPressed: controller.clearFilters, ), - const Divider(height: 1), - ], + ), ); } @@ -489,3 +465,57 @@ class _MiniGraphPainter extends CustomPainter { !identical(oldDelegate.layout, layout) || !identical(oldDelegate.routes, routes); } + +/// The Pipelines list's app-bar actions: filter (with its count) and sort. +List pipelineListActions( + BuildContext context, + PipelinesController controller, +) { + final filters = controller.filters; + final hasUnclassified = controller.pipelines.any( + (pipeline) => pipeline.scheduleState == PipelineScheduleState.unclassified, + ); + void openFilters() => openPipelineFilters( + context, + initial: filters, + hasUnclassified: hasUnclassified, + onApply: controller.setFilters, + ); + final label = filters.count == 0 + ? 'Filter pipelines' + : '${filters.count} active ${filters.count == 1 ? 'filter' : 'filters'}'; + final filter = useCupertinoControls(context) + ? Semantics( + button: true, + label: label, + excludeSemantics: true, + child: CupertinoButton( + key: const Key('pipeline-filter'), + padding: const EdgeInsets.symmetric(horizontal: 6), + onPressed: openFilters, + child: Icon( + filters.count > 0 + ? CupertinoIcons.line_horizontal_3_decrease_circle_fill + : CupertinoIcons.line_horizontal_3_decrease_circle, + ), + ), + ) + : IconButton( + key: const Key('pipeline-filter'), + tooltip: label, + isSelected: filters.count > 0, + onPressed: openFilters, + icon: Icon( + filters.count > 0 ? Icons.filter_alt : Icons.filter_alt_outlined, + ), + ); + return [ + filter, + PipelineSortButton( + key: const Key('pipeline-sort'), + sort: controller.sort, + onSelected: controller.setSort, + icon: true, + ), + ]; +} diff --git a/app/test/features/pipelines/pipeline_list_composition_test.dart b/app/test/features/pipelines/pipeline_list_composition_test.dart index 87143fb8..63b082d1 100644 --- a/app/test/features/pipelines/pipeline_list_composition_test.dart +++ b/app/test/features/pipelines/pipeline_list_composition_test.dart @@ -14,20 +14,15 @@ import 'test_helpers.dart'; /// last run, separated from each other, and a one-line detail identity header /// whose recorded facts live at the top of Summary. void main() { - testWidgets('toolbar, rows and separators share the web list inset', ( - tester, - ) async { + testWidgets('rows and separators share the web list inset', (tester) async { final fixture = PipelineFixture(); await pumpWide(tester, gatewayFor(fixture)); final list = find.byKey(const Key('pipeline-list')); final listLeft = tester.getTopLeft(list).dx; - expect( - tester.getTopLeft(find.byKey(const Key('pipeline-toolbar'))).dx - - listLeft, - kPipelineListInset, - ); + // Filter and sort are app-bar actions; no toolbar row without a filter. + expect(find.byKey(const Key('pipeline-toolbar')), findsNothing); expect( tester.getTopLeft(find.text('Alpha review')).dx - listLeft, kPipelineListInset, diff --git a/app/test/features/pipelines/pipelines_screen_filter_test.dart b/app/test/features/pipelines/pipelines_screen_filter_test.dart index 392e467d..ad8a79c6 100644 --- a/app/test/features/pipelines/pipelines_screen_filter_test.dart +++ b/app/test/features/pipelines/pipelines_screen_filter_test.dart @@ -18,7 +18,7 @@ void main() { await tester.enterText(find.byType(TextField), 'beta'); await tester.tap(find.text('Done')); await tester.pumpAndSettle(); - expect(find.text('Filter (1)'), findsOneWidget); + expect(find.text('Clear filters (1)'), findsOneWidget); expect(find.text('Beta deploy'), findsOneWidget); expect(find.text('Alpha review'), findsNothing); @@ -62,7 +62,7 @@ void main() { await tester.tap(find.text('Name Z\u2013A')); await tester.pumpAndSettle(); - expect(find.text('Sort: Name Z\u2013A'), findsOneWidget); + expect(find.byTooltip('Sort pipelines: Name Z\u2013A'), findsOneWidget); final gamma = tester.getTopLeft(find.text('Gamma legacy')).dy; final beta = tester.getTopLeft(find.text('Beta deploy')).dy; final alpha = tester.getTopLeft(find.text('Alpha review')).dy;