feat(app): Pipelines filter, sort and refresh are app-bar icons
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../core/api_gateway.dart';
|
import '../../core/api_gateway.dart';
|
||||||
|
import '../../shell/shell_bar.dart';
|
||||||
import 'pipeline_models.dart';
|
import 'pipeline_models.dart';
|
||||||
import 'pipeline_repository.dart';
|
import 'pipeline_repository.dart';
|
||||||
import 'pipelines_controller.dart';
|
import 'pipelines_controller.dart';
|
||||||
@@ -224,9 +225,20 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The shell owns the navigation bar here, so the content keeps a native
|
/// The shell owns the navigation bar here: the list puts filter, sort and
|
||||||
/// Refresh action without adding a second bar.
|
/// refresh in it; an open pipeline on a phone keeps refresh only.
|
||||||
Widget _embeddedBody(BuildContext context, Widget body) {
|
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(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
@@ -234,7 +246,13 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
alignment: AlignmentDirectional.centerEnd,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
child: _refreshButton(context),
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
...pipelineListActions(context, _controller),
|
||||||
|
_refreshButton(context),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(child: body),
|
Expanded(child: body),
|
||||||
@@ -275,7 +293,10 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Pipelines'),
|
title: const Text('Pipelines'),
|
||||||
actions: [_refreshButton(context)],
|
actions: [
|
||||||
|
...pipelineListActions(context, _controller),
|
||||||
|
_refreshButton(context),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
body: SafeArea(child: body),
|
body: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
@@ -285,7 +306,13 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: CupertinoNavigationBar(
|
||||||
middle: const Text('Pipelines'),
|
middle: const Text('Pipelines'),
|
||||||
trailing: _refreshButton(context),
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
...pipelineListActions(context, _controller),
|
||||||
|
_refreshButton(context),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: SafeArea(top: false, child: body),
|
child: SafeArea(top: false, child: body),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -87,19 +87,32 @@ class PipelineSortButton extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.sort,
|
required this.sort,
|
||||||
required this.onSelected,
|
required this.onSelected,
|
||||||
|
this.icon = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final PipelineSort sort;
|
final PipelineSort sort;
|
||||||
final ValueChanged<PipelineSort> onSelected;
|
final ValueChanged<PipelineSort> onSelected;
|
||||||
|
|
||||||
|
/// An app-bar icon instead of a labelled button.
|
||||||
|
final bool icon;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final label = 'Sort: ${sort.label}';
|
final label = 'Sort: ${sort.label}';
|
||||||
if (useCupertinoControls(context)) {
|
if (useCupertinoControls(context)) {
|
||||||
return CupertinoButton(
|
return Semantics(
|
||||||
padding: EdgeInsets.zero,
|
button: true,
|
||||||
onPressed: () => _showCupertinoSheet(context),
|
label: icon ? 'Sort pipelines: ${sort.label}' : null,
|
||||||
child: Text(label),
|
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(
|
return MenuAnchor(
|
||||||
@@ -110,10 +123,16 @@ class PipelineSortButton extends StatelessWidget {
|
|||||||
child: Text(option.label),
|
child: Text(option.label),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
builder: (context, menu, child) => TextButton(
|
builder: (context, menu, child) => icon
|
||||||
onPressed: () => menu.isOpen ? menu.close() : menu.open(),
|
? IconButton(
|
||||||
child: Text(label),
|
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),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,52 +62,28 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
|
|
||||||
/// The web's compact toolbar: filter (whose page carries the name search),
|
/// 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.
|
/// 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(
|
Widget _toolbar(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
PipelineFilters filters,
|
PipelineFilters filters,
|
||||||
bool hasUnclassified,
|
bool hasUnclassified,
|
||||||
) {
|
) {
|
||||||
return Column(
|
if (!filters.active) return const SizedBox.shrink();
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
return Padding(
|
||||||
children: [
|
key: const Key('pipeline-toolbar'),
|
||||||
Padding(
|
padding: const EdgeInsets.symmetric(
|
||||||
padding: const EdgeInsets.symmetric(
|
horizontal: kPipelineListInset,
|
||||||
horizontal: kPipelineListInset,
|
vertical: 2,
|
||||||
vertical: 2,
|
),
|
||||||
),
|
child: Align(
|
||||||
child: Wrap(
|
alignment: AlignmentDirectional.centerStart,
|
||||||
key: const Key('pipeline-toolbar'),
|
child: PipelineTextButton(
|
||||||
spacing: 4,
|
key: const Key('pipeline-clear-filters'),
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
label: 'Clear filters (${filters.count})',
|
||||||
children: [
|
onPressed: controller.clearFilters,
|
||||||
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,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const Divider(height: 1),
|
),
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,3 +465,57 @@ class _MiniGraphPainter extends CustomPainter {
|
|||||||
!identical(oldDelegate.layout, layout) ||
|
!identical(oldDelegate.layout, layout) ||
|
||||||
!identical(oldDelegate.routes, routes);
|
!identical(oldDelegate.routes, routes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The Pipelines list's app-bar actions: filter (with its count) and sort.
|
||||||
|
List<Widget> 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,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,20 +14,15 @@ import 'test_helpers.dart';
|
|||||||
/// last run, separated from each other, and a one-line detail identity header
|
/// last run, separated from each other, and a one-line detail identity header
|
||||||
/// whose recorded facts live at the top of Summary.
|
/// whose recorded facts live at the top of Summary.
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('toolbar, rows and separators share the web list inset', (
|
testWidgets('rows and separators share the web list inset', (tester) async {
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final fixture = PipelineFixture();
|
final fixture = PipelineFixture();
|
||||||
await pumpWide(tester, gatewayFor(fixture));
|
await pumpWide(tester, gatewayFor(fixture));
|
||||||
|
|
||||||
final list = find.byKey(const Key('pipeline-list'));
|
final list = find.byKey(const Key('pipeline-list'));
|
||||||
final listLeft = tester.getTopLeft(list).dx;
|
final listLeft = tester.getTopLeft(list).dx;
|
||||||
|
|
||||||
expect(
|
// Filter and sort are app-bar actions; no toolbar row without a filter.
|
||||||
tester.getTopLeft(find.byKey(const Key('pipeline-toolbar'))).dx -
|
expect(find.byKey(const Key('pipeline-toolbar')), findsNothing);
|
||||||
listLeft,
|
|
||||||
kPipelineListInset,
|
|
||||||
);
|
|
||||||
expect(
|
expect(
|
||||||
tester.getTopLeft(find.text('Alpha review')).dx - listLeft,
|
tester.getTopLeft(find.text('Alpha review')).dx - listLeft,
|
||||||
kPipelineListInset,
|
kPipelineListInset,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ void main() {
|
|||||||
await tester.enterText(find.byType(TextField), 'beta');
|
await tester.enterText(find.byType(TextField), 'beta');
|
||||||
await tester.tap(find.text('Done'));
|
await tester.tap(find.text('Done'));
|
||||||
await tester.pumpAndSettle();
|
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('Beta deploy'), findsOneWidget);
|
||||||
expect(find.text('Alpha review'), findsNothing);
|
expect(find.text('Alpha review'), findsNothing);
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ void main() {
|
|||||||
await tester.tap(find.text('Name Z\u2013A'));
|
await tester.tap(find.text('Name Z\u2013A'));
|
||||||
await tester.pumpAndSettle();
|
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 gamma = tester.getTopLeft(find.text('Gamma legacy')).dy;
|
||||||
final beta = tester.getTopLeft(find.text('Beta deploy')).dy;
|
final beta = tester.getTopLeft(find.text('Beta deploy')).dy;
|
||||||
final alpha = tester.getTopLeft(find.text('Alpha review')).dy;
|
final alpha = tester.getTopLeft(find.text('Alpha review')).dy;
|
||||||
|
|||||||
Reference in New Issue
Block a user