Anchor desktop Files and Runs menus

Use Material popup menus for file actions and anchor Runs sorting choices to the sort button while retaining the phone fallback. Update callers, tests, and implementation notes to match the desktop behavior.
This commit is contained in:
2026-11-10 22:14:29 +00:00
parent 31f495fc18
commit 42a2378ecb
10 changed files with 73 additions and 194 deletions
@@ -127,8 +127,6 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
Widget build(BuildContext context) {
return AppOverflowMenu<_RunMoreItem>(
key: widget.menuKey,
cupertino: widget.cupertino,
// The Cupertino action sheet names the run it acts on.
sheetTitle: runMoreMenuTitle(run),
actions: [
for (final (item, label) in _items)
+30 -72
View File
@@ -1,9 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/app_popups.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/adaptive/segmented_bar_overflow.dart';
import '../../../ui/layout/app_sheet_header.dart';
import '../../pipelines/pipeline_format.dart' show runStateLabel;
import 'runs_controller.dart';
import 'runs_filter_options.dart';
@@ -160,6 +160,7 @@ class RunsBarActions {
String label,
VoidCallback onPressed, {
bool active = false,
bool anchorPopup = false,
}) {
final Widget button;
if (cupertino) {
@@ -178,12 +179,16 @@ class RunsBarActions {
),
);
} else {
button = IconButton(
key: key,
tooltip: label,
isSelected: active,
onPressed: onPressed,
icon: Icon(material),
button = Builder(
builder: (buttonContext) => IconButton(
key: key,
tooltip: label,
isSelected: active,
onPressed: anchorPopup
? () => _chooseSort(buttonContext)
: onPressed,
icon: Icon(material),
),
);
}
// A narrow bar moves it into its More menu.
@@ -221,80 +226,33 @@ class RunsBarActions {
CupertinoIcons.arrow_up_arrow_down,
'Sort runs: ${runSortLabel(controller.sort)}',
() => _chooseSort(context),
anchorPopup: true,
),
];
}
Future<void> _chooseSort(BuildContext context) async {
final cupertino = usesCupertinoHost(context);
String? value;
if (cupertino) {
value = await showCupertinoModalPopup<String>(
context: context,
builder: (sheet) => CupertinoActionSheet(
title: const Text(runsSortTitle),
actions: [
final value = await showAppChoiceMenu<String>(
context,
semanticLabel: runsSortTitle,
builder: (menu) => SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
for (final option in runSorts)
CupertinoActionSheetAction(
// The current order is the sheet's default (bold) action.
isDefaultAction: controller.sort == option.$1,
onPressed: () => Navigator.pop(sheet, option.$1),
child: Semantics(
selected: controller.sort == option.$1,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(option.$2),
if (controller.sort == option.$1) ...[
const SizedBox(width: 8),
const Icon(CupertinoIcons.checkmark),
],
],
),
),
ListTile(
selected: controller.sort == option.$1,
title: Text(option.$2),
trailing: controller.sort == option.$1
? const Icon(Icons.check)
: null,
onTap: () => Navigator.of(menu).pop(option.$1),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(sheet),
child: const Text('Cancel'),
),
),
);
} else {
value = await showModalBottomSheet<String>(
context: context,
showDragHandle: true,
builder: (sheet) => SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const AppSheetHeader(
title: runsSortTitle,
cupertino: false,
doneKey: runsSortDoneKey,
),
Flexible(
child: ListView(
shrinkWrap: true,
children: [
for (final option in runSorts)
ListTile(
selected: controller.sort == option.$1,
title: Text(option.$2),
trailing: controller.sort == option.$1
? const Icon(Icons.check)
: null,
onTap: () => Navigator.pop(sheet, option.$1),
),
],
),
),
],
),
),
);
}
),
);
if (value != null && value != controller.sort) controller.setSort(value);
}
}