9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
171 lines
5.1 KiB
Dart
171 lines
5.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
|
import '../../../ui/layout/section_heading.dart';
|
|
import '../actions/delete_runs_action.dart';
|
|
import '../domain/run_deletion.dart';
|
|
import 'runs_controller.dart';
|
|
|
|
const runsSelectKey = ValueKey<String>('runs.select');
|
|
const runsSelectDoneKey = ValueKey<String>('runs.select.done');
|
|
const runsDeleteSelectedKey = ValueKey<String>('runs.select.delete');
|
|
const runsSelectionCountKey = ValueKey<String>('runs.select.count');
|
|
const runsDeleteReportKey = ValueKey<String>('runs.delete.report');
|
|
const runsDeleteReportDismissKey = ValueKey<String>(
|
|
'runs.delete.report.dismiss',
|
|
);
|
|
|
|
/// The day heading's Select all / Deselect all toggle key.
|
|
ValueKey<String> runsDaySelectKey(String day) =>
|
|
ValueKey('runs.select.day.$day');
|
|
|
|
/// The Runs bar's `Select` action, entering multi-select.
|
|
Widget runsSelectAction(BuildContext context, RunsController controller) {
|
|
void enter() => controller.selection.enter();
|
|
// A narrow bar moves it into its More menu.
|
|
return SegmentedOverflowAction(
|
|
overflowEntry: SegmentedOverflowEntry(
|
|
label: 'Select',
|
|
icon: Icons.checklist,
|
|
onPressed: enter,
|
|
),
|
|
child: IconButton(
|
|
key: runsSelectKey,
|
|
tooltip: 'Select',
|
|
onPressed: enter,
|
|
icon: const Icon(Icons.checklist),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// What the bar shows in select mode: `N selected` over the selection's size,
|
|
/// then Delete and Done.
|
|
({String title, String? subtitle, List<Widget> actions}) runsSelectionBar(
|
|
BuildContext context,
|
|
RunsController controller,
|
|
) {
|
|
final selection = controller.selection;
|
|
final selected = [
|
|
for (final run in controller.runs)
|
|
if (selection.contains(run['id'])) run,
|
|
];
|
|
final count = selected.length;
|
|
final size = count == 0 ? null : runsSizeLabel(selected);
|
|
final delete = count == 0
|
|
? null
|
|
: () => confirmDeleteRuns(
|
|
context,
|
|
runs: selected,
|
|
gateway: controller.repository.gateway,
|
|
onDeleted: controller.applyDeletion,
|
|
);
|
|
final deleteLabel = count == 0
|
|
? 'Delete selected runs'
|
|
: 'Delete $count selected ${count == 1 ? 'run' : 'runs'}';
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final actions = <Widget>[
|
|
Semantics(
|
|
label: deleteLabel,
|
|
excludeSemantics: true,
|
|
onTap: delete,
|
|
button: true,
|
|
enabled: delete != null,
|
|
child: TextButton(
|
|
key: runsDeleteSelectedKey,
|
|
style: TextButton.styleFrom(foregroundColor: scheme.error),
|
|
onPressed: delete,
|
|
child: const Text('Delete'),
|
|
),
|
|
),
|
|
TextButton(
|
|
key: runsSelectDoneKey,
|
|
onPressed: selection.exit,
|
|
child: const Text('Done'),
|
|
),
|
|
];
|
|
return (title: '$count selected', subtitle: size, actions: actions);
|
|
}
|
|
|
|
/// A day's heading; in select mode it carries that day's Select all /
|
|
/// Deselect all toggle, covering only the day's finished runs.
|
|
class RunsDayHeading extends StatelessWidget {
|
|
const RunsDayHeading({
|
|
super.key,
|
|
required this.label,
|
|
required this.runs,
|
|
required this.controller,
|
|
});
|
|
|
|
final String label;
|
|
final List<JsonMap> runs;
|
|
final RunsController controller;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final selection = controller.selection;
|
|
final trailing = <Widget>[];
|
|
if (selection.active) {
|
|
final any = deletableRunIds(runs).isNotEmpty;
|
|
final all = selection.allSelected(runs);
|
|
final text = all ? 'Deselect all' : 'Select all';
|
|
final toggle = any ? () => selection.toggleAll(runs) : null;
|
|
final key = runsDaySelectKey(label);
|
|
trailing.add(
|
|
Semantics(
|
|
button: true,
|
|
enabled: any,
|
|
label: any
|
|
? '$text $label'
|
|
: '$text $label. No finished runs to select.',
|
|
excludeSemantics: true,
|
|
onTap: toggle,
|
|
child: TextButton(key: key, onPressed: toggle, child: Text(text)),
|
|
),
|
|
);
|
|
}
|
|
return Padding(
|
|
padding: const EdgeInsets.only(top: 8),
|
|
child: SectionHeading(
|
|
title: label,
|
|
minHeight: 32,
|
|
header: true,
|
|
trailing: trailing,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The last deletion's outcome above the list, until dismissed.
|
|
class RunsDeleteReport extends StatelessWidget {
|
|
const RunsDeleteReport({super.key, required this.controller});
|
|
|
|
final RunsController controller;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final report = controller.selection.report;
|
|
if (report == null) return const SizedBox.shrink();
|
|
final dismiss = controller.selection.dismissReport;
|
|
return Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 8, 4),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Semantics(
|
|
liveRegion: true,
|
|
child: Text(report, key: runsDeleteReportKey),
|
|
),
|
|
),
|
|
TextButton(
|
|
key: runsDeleteReportDismissKey,
|
|
onPressed: dismiss,
|
|
child: const Text('Dismiss'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|