Merge 2b.5: files and runs sort menus on desktop

This commit is contained in:
2026-11-10 22:56:39 +00:00
10 changed files with 73 additions and 194 deletions
@@ -175,7 +175,6 @@ class _FilesPanelState extends State<FilesPanel> {
/// Open and Download for a file, then Rename, Move and Delete for any entry.
Widget _menu(DirectoryEntry entry) => AppOverflowMenu<FileAction>(
label: entry.isDir ? 'Folder actions' : 'File actions',
sheetTitle: entry.name,
onSelected: (_, action) => switch (action) {
FileAction.open => _open(entry),
FileAction.download => widget.viewer.download(
@@ -44,7 +44,6 @@ class SessionActionsButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AppOverflowMenu<SessionAction>(
cupertino: chatControlsStyleOf(context) == ChatControlsStyle.cupertino,
label: sessionActionsLabel(session, duplicateTitles),
sheetTitle: chatSessionTitle(session),
actions: [
@@ -37,7 +37,6 @@ Widget pipelineActionsMenu(
key: const Key('pipeline-actions-menu'),
label: 'Pipeline actions',
sheetTitle: detail.displayName,
cupertino: useCupertinoControls(context),
actions: [
AppMenuAction(
key: Key(archived ? 'pipeline-unarchive' : 'pipeline-archive'),
@@ -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);
}
}
@@ -54,7 +54,6 @@ class SchedulePipelineRow extends StatelessWidget {
// A narrow Summary still needs a way to pause or delete.
menu: AppOverflowMenu<_ScheduleAction>(
key: scheduleRowMenuKey(id),
cupertino: cupertino,
enabled: !busy,
label: 'Schedule actions for ${scheduleDisplayName(schedule)}',
sheetTitle: scheduleDisplayName(schedule),