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
|
||||
/// doubled text scale can still reach them without crushing the list.
|
||||
class RunsFilters extends StatelessWidget {
|
||||
const RunsFilters({super.key, required this.controller});
|
||||
const RunsFilters({super.key, required this.controller, this.action});
|
||||
|
||||
final RunsController controller;
|
||||
final Widget? action;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -37,6 +38,7 @@ class RunsFilters extends StatelessWidget {
|
||||
Widget _materialToolbar(int count) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (action case final action?) ...[action, const SizedBox(width: 4)],
|
||||
PopupMenuButton<_FilterChoice>(
|
||||
tooltip: count > 0
|
||||
? '$count active ${count == 1 ? 'filter' : 'filters'}'
|
||||
@@ -154,6 +156,7 @@ class RunsFilters extends StatelessWidget {
|
||||
Widget _cupertinoToolbar(BuildContext context, int count) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (action case final action?) ...[action, const SizedBox(width: 4)],
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
minimumSize: Size.zero,
|
||||
|
||||
@@ -75,7 +75,19 @@ class RunsList extends StatelessWidget {
|
||||
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(
|
||||
child: controller.visibleRuns.isEmpty
|
||||
? const Center(child: Text('No runs found.'))
|
||||
@@ -85,33 +97,18 @@ class RunsList extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _heading(BuildContext context) => Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: controller.usage == null
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
'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 _heading(BuildContext context) {
|
||||
final usage = controller.usage;
|
||||
if (usage == null) return const SizedBox.shrink();
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Text(
|
||||
'Usage: $usage',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _groupedRuns(BuildContext context) {
|
||||
final groups = groupRunsByDay(controller.visibleRuns, DateTime.now());
|
||||
|
||||
@@ -4,8 +4,10 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.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/ui/runs_controller.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_filters.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
@@ -188,4 +190,26 @@ void main() {
|
||||
},
|
||||
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