fix(app): runs attention action shares the filter toolbar row
This commit is contained in:
@@ -12,9 +12,10 @@ import 'runs_controller.dart';
|
|||||||
/// The buttons sit in a single horizontally scrollable row so a phone at a
|
/// The buttons sit in a single horizontally scrollable row so a phone at a
|
||||||
/// doubled text scale can still reach them without crushing the list.
|
/// doubled text scale can still reach them without crushing the list.
|
||||||
class RunsFilters extends StatelessWidget {
|
class RunsFilters extends StatelessWidget {
|
||||||
const RunsFilters({super.key, required this.controller});
|
const RunsFilters({super.key, required this.controller, this.action});
|
||||||
|
|
||||||
final RunsController controller;
|
final RunsController controller;
|
||||||
|
final Widget? action;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -37,6 +38,7 @@ class RunsFilters extends StatelessWidget {
|
|||||||
Widget _materialToolbar(int count) => Row(
|
Widget _materialToolbar(int count) => Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
if (action case final action?) ...[action, const SizedBox(width: 4)],
|
||||||
PopupMenuButton<_FilterChoice>(
|
PopupMenuButton<_FilterChoice>(
|
||||||
tooltip: count > 0
|
tooltip: count > 0
|
||||||
? '$count active ${count == 1 ? 'filter' : 'filters'}'
|
? '$count active ${count == 1 ? 'filter' : 'filters'}'
|
||||||
@@ -154,6 +156,7 @@ class RunsFilters extends StatelessWidget {
|
|||||||
Widget _cupertinoToolbar(BuildContext context, int count) => Row(
|
Widget _cupertinoToolbar(BuildContext context, int count) => Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
if (action case final action?) ...[action, const SizedBox(width: 4)],
|
||||||
CupertinoButton(
|
CupertinoButton(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||||
minimumSize: Size.zero,
|
minimumSize: Size.zero,
|
||||||
|
|||||||
@@ -75,7 +75,19 @@ class RunsList extends StatelessWidget {
|
|||||||
onChanged: controller.setQuery,
|
onChanged: controller.setQuery,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
RunsFilters(controller: controller),
|
RunsFilters(
|
||||||
|
controller: controller,
|
||||||
|
action: NeedsYouRunsHeading(
|
||||||
|
rows: controller.runs,
|
||||||
|
frames: controller.repository.gateway.frames,
|
||||||
|
onOpen: (entry) => onSelected(entry.runId),
|
||||||
|
syncToken: syncToken,
|
||||||
|
store: attentionStore,
|
||||||
|
now: attentionNow,
|
||||||
|
notifications: notifications,
|
||||||
|
attention: attention,
|
||||||
|
),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: controller.visibleRuns.isEmpty
|
child: controller.visibleRuns.isEmpty
|
||||||
? const Center(child: Text('No runs found.'))
|
? const Center(child: Text('No runs found.'))
|
||||||
@@ -85,33 +97,18 @@ class RunsList extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _heading(BuildContext context) => Padding(
|
Widget _heading(BuildContext context) {
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
final usage = controller.usage;
|
||||||
child: Row(
|
if (usage == null) return const SizedBox.shrink();
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
return Padding(
|
||||||
children: [
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||||
Expanded(
|
child: Text(
|
||||||
child: controller.usage == null
|
'Usage: $usage',
|
||||||
? const SizedBox.shrink()
|
maxLines: 1,
|
||||||
: Text(
|
overflow: TextOverflow.ellipsis,
|
||||||
'Usage: ${controller.usage}',
|
),
|
||||||
maxLines: 1,
|
);
|
||||||
overflow: TextOverflow.ellipsis,
|
}
|
||||||
),
|
|
||||||
),
|
|
||||||
NeedsYouRunsHeading(
|
|
||||||
rows: controller.runs,
|
|
||||||
frames: controller.repository.gateway.frames,
|
|
||||||
onOpen: (entry) => onSelected(entry.runId),
|
|
||||||
syncToken: syncToken,
|
|
||||||
store: attentionStore,
|
|
||||||
now: attentionNow,
|
|
||||||
notifications: notifications,
|
|
||||||
attention: attention,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _groupedRuns(BuildContext context) {
|
Widget _groupedRuns(BuildContext context) {
|
||||||
final groups = groupRunsByDay(controller.visibleRuns, DateTime.now());
|
final groups = groupRunsByDay(controller.visibleRuns, DateTime.now());
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
|
import 'package:pipelines_app/features/attention/ui/needs_you_runs_heading.dart';
|
||||||
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
||||||
|
import 'package:pipelines_app/features/runs/ui/runs_filters.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||||
|
|
||||||
class _Gateway implements ApiGateway {
|
class _Gateway implements ApiGateway {
|
||||||
@@ -188,4 +190,26 @@ void main() {
|
|||||||
},
|
},
|
||||||
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
|
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
testWidgets('the attention action shares the Filter toolbar row '
|
||||||
|
'(${cupertino ? 'Cupertino' : 'Material'})', (tester) async {
|
||||||
|
await mount(tester, cupertino: cupertino);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final bell = find.descendant(
|
||||||
|
of: find.byType(RunsFilters),
|
||||||
|
matching: find.byType(NeedsYouRunsHeading),
|
||||||
|
);
|
||||||
|
expect(bell, findsOneWidget);
|
||||||
|
final filter = find.descendant(
|
||||||
|
of: find.byType(RunsFilters),
|
||||||
|
matching: find.text('Filter'),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
(tester.getCenter(bell).dy - tester.getCenter(filter).dy).abs(),
|
||||||
|
lessThan(1),
|
||||||
|
);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user