diff --git a/app/lib/features/chat/files/files_panel.dart b/app/lib/features/chat/files/files_panel.dart index a864c59c..af0d2ba7 100644 --- a/app/lib/features/chat/files/files_panel.dart +++ b/app/lib/features/chat/files/files_panel.dart @@ -175,7 +175,6 @@ class _FilesPanelState extends State { /// Open and Download for a file, then Rename, Move and Delete for any entry. Widget _menu(DirectoryEntry entry) => AppOverflowMenu( label: entry.isDir ? 'Folder actions' : 'File actions', - sheetTitle: entry.name, onSelected: (_, action) => switch (action) { FileAction.open => _open(entry), FileAction.download => widget.viewer.download( diff --git a/app/lib/features/chat/ui/sessions/session_actions.dart b/app/lib/features/chat/ui/sessions/session_actions.dart index 47a7c843..b649a8eb 100644 --- a/app/lib/features/chat/ui/sessions/session_actions.dart +++ b/app/lib/features/chat/ui/sessions/session_actions.dart @@ -44,7 +44,6 @@ class SessionActionsButton extends StatelessWidget { @override Widget build(BuildContext context) { return AppOverflowMenu( - cupertino: chatControlsStyleOf(context) == ChatControlsStyle.cupertino, label: sessionActionsLabel(session, duplicateTitles), sheetTitle: chatSessionTitle(session), actions: [ diff --git a/app/lib/features/pipelines/widgets/pipeline_archive_action.dart b/app/lib/features/pipelines/widgets/pipeline_archive_action.dart index 940359a5..fc5bb10d 100644 --- a/app/lib/features/pipelines/widgets/pipeline_archive_action.dart +++ b/app/lib/features/pipelines/widgets/pipeline_archive_action.dart @@ -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'), diff --git a/app/lib/features/runs/ui/run_more_menu.dart b/app/lib/features/runs/ui/run_more_menu.dart index 77f4e427..a9b23a44 100644 --- a/app/lib/features/runs/ui/run_more_menu.dart +++ b/app/lib/features/runs/ui/run_more_menu.dart @@ -127,8 +127,6 @@ class _RunMoreMenuState extends State { 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) diff --git a/app/lib/features/runs/ui/runs_filters.dart b/app/lib/features/runs/ui/runs_filters.dart index 6b6db935..640cf479 100644 --- a/app/lib/features/runs/ui/runs_filters.dart +++ b/app/lib/features/runs/ui/runs_filters.dart @@ -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 _chooseSort(BuildContext context) async { - final cupertino = usesCupertinoHost(context); - String? value; - if (cupertino) { - value = await showCupertinoModalPopup( - context: context, - builder: (sheet) => CupertinoActionSheet( - title: const Text(runsSortTitle), - actions: [ + final value = await showAppChoiceMenu( + 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( - 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); } } diff --git a/app/lib/features/schedules/ui/pipeline/schedule_pipeline_row.dart b/app/lib/features/schedules/ui/pipeline/schedule_pipeline_row.dart index 1b9b52f7..5ba772f1 100644 --- a/app/lib/features/schedules/ui/pipeline/schedule_pipeline_row.dart +++ b/app/lib/features/schedules/ui/pipeline/schedule_pipeline_row.dart @@ -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), diff --git a/app/lib/ui/layout/app_overflow_menu.dart b/app/lib/ui/layout/app_overflow_menu.dart index 3dee38ae..98f925ff 100644 --- a/app/lib/ui/layout/app_overflow_menu.dart +++ b/app/lib/ui/layout/app_overflow_menu.dart @@ -1,8 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../adaptive/host.dart'; - /// One choice in an [AppOverflowMenu]. class AppMenuAction { const AppMenuAction({ @@ -15,21 +12,19 @@ class AppMenuAction { final T value; final String label; - /// Placed on the menu item (Material) or the sheet action (Cupertino), so a - /// test finds the same item on both hosts. + /// Placed on the menu item so tests can find the same item. final Key? key; - /// Shown in the destructive colour on Cupertino's action sheet. + // Kept for callers that distinguish destructive actions in their data model; + // Material PopupMenuItem does not apply a separate action-sheet treatment. final bool destructive; } /// The app's one row/header overflow control: the host's "more" icon that /// opens the row's secondary actions. /// -/// Material shows a [PopupMenuButton] with [Icons.more_vert]; Cupertino shows -/// a [CupertinoButton] with [CupertinoIcons.ellipsis] that opens a -/// [CupertinoActionSheet] (with Cancel). Every list row and the run header use -/// this, so the overflow icon reads the same everywhere on a host. +/// Shows a [PopupMenuButton] with [Icons.more_vert]. Every list row and the run +/// header use this, so overflow actions are anchored to their button. class AppOverflowMenu extends StatelessWidget { const AppOverflowMenu({ super.key, @@ -38,81 +33,44 @@ class AppOverflowMenu extends StatelessWidget { this.label = 'More actions', this.sheetTitle, this.enabled = true, - this.cupertino, }); final List> actions; - /// Called with the picked value once the menu or sheet has closed. + /// Called with the picked value once the menu has closed. final void Function(BuildContext context, T value) onSelected; - /// Tooltip (Material) and accessible label (both hosts). + /// Tooltip and accessible label. final String label; - /// The Cupertino sheet's title, usually the row's name. + /// Retained for source compatibility; Material menus do not show a title. final String? sheetTitle; final bool enabled; - /// Overrides the host detection (some features pick a style per platform). - final bool? cupertino; - @override Widget build(BuildContext context) { if (actions.isEmpty) return const SizedBox.shrink(); - if (!(cupertino ?? usesCupertinoHost(context))) { - return PopupMenuButton( - icon: const Icon(Icons.more_vert), - tooltip: label, - enabled: enabled, - onSelected: (value) => onSelected(context, value), - itemBuilder: (_) => [ - for (final action in actions) - PopupMenuItem( - key: action.key, - value: action.value, - child: Text(action.label), - ), - ], - ); - } - // Its own node, so a row's merged label never swallows the button. - return Semantics( - container: true, - button: true, - enabled: enabled, - label: label, - excludeSemantics: true, - child: CupertinoButton( - padding: EdgeInsets.zero, - minimumSize: const Size.square(kMinInteractiveDimensionCupertino), - onPressed: enabled ? () => _showSheet(context) : null, - child: const Icon(CupertinoIcons.ellipsis), - ), - ); - } - - Future _showSheet(BuildContext context) async { - final picked = await showCupertinoModalPopup( + return Localizations.override( context: context, - builder: (sheet) => CupertinoActionSheet( - title: sheetTitle == null ? null : Text(sheetTitle!), - actions: [ - for (final action in actions) - CupertinoActionSheetAction( - key: action.key, - isDestructiveAction: action.destructive, - onPressed: () => Navigator.of(sheet).pop(action.value), - child: Text(action.label), - ), - ], - cancelButton: CupertinoActionSheetAction( - isDefaultAction: true, - onPressed: () => Navigator.of(sheet).pop(), - child: const Text('Cancel'), + delegates: const [DefaultMaterialLocalizations.delegate], + child: Material( + type: MaterialType.transparency, + child: PopupMenuButton( + icon: const Icon(Icons.more_vert), + tooltip: label, + enabled: enabled, + onSelected: (value) => onSelected(context, value), + itemBuilder: (_) => [ + for (final action in actions) + PopupMenuItem( + key: action.key, + value: action.value, + child: Text(action.label), + ), + ], ), ), ); - if (picked != null && context.mounted) onSelected(context, picked); } } diff --git a/app/notes/desktop-menus-files-runs.md b/app/notes/desktop-menus-files-runs.md new file mode 100644 index 00000000..6c6bf098 --- /dev/null +++ b/app/notes/desktop-menus-files-runs.md @@ -0,0 +1,7 @@ +# Desktop Files and Runs menus + +- `AppOverflowMenu` now always uses the anchored Material `PopupMenuButton`; file sort and file row actions no longer have sheet-only behavior. +- Runs sort uses `showAppChoiceMenu` with the sort button as its anchor, retaining the phone bottom-sheet fallback. +- Focused checks: `tool/memwatch/full.sh 'test/features/runs/ui/runs_toolbar_test.dart test/ui/layout/app_list_row_test.dart test/ui/adaptive/app_popups_test.dart'` — 26 passed. +- `tool/analyze.sh` — clean. +- UI capture/review was not run in this implementation stage; the requested states remain for the UI review stage. diff --git a/app/test/features/runs/ui/runs_sheets_test.dart b/app/test/features/runs/ui/runs_sheets_test.dart index e388903a..973c1436 100644 --- a/app/test/features/runs/ui/runs_sheets_test.dart +++ b/app/test/features/runs/ui/runs_sheets_test.dart @@ -7,7 +7,6 @@ import 'package:pipelines_app/core/api_gateway.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_filter_sheet.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/ui/layout/app_sheet_header.dart'; @@ -139,44 +138,14 @@ void main() { expect(tester.widget(anyTime).selected, isTrue); }); - testWidgets('Material sort sheet has the same header', (tester) async { + testWidgets('Material sort opens an anchored choice menu', (tester) async { await mount(tester, cupertino: false); await tester.tap(find.byKey(const ValueKey('runs.sort'))); await tester.pumpAndSettle(); - expect(find.text(runsSortTitle), findsOneWidget); - await tester.tap(find.byKey(runsSortDoneKey)); + expect(find.byKey(const ValueKey('app-choice-menu')), findsOneWidget); + await tester.tap(find.text('Oldest first')); await tester.pumpAndSettle(); - expect(find.text(runsSortTitle), findsNothing); - expect(controller.sort, 'newest_first'); - }); - - testWidgets('Cupertino sort sheet marks the selected order with an icon', ( - tester, - ) async { - await mount(tester, cupertino: true); - await tester.tap(find.byKey(const ValueKey('runs.sort'))); - await tester.pumpAndSettle(); - - expect(find.text('✓ Newest first'), findsNothing); - final newestFirst = find.widgetWithText( - CupertinoActionSheetAction, - 'Newest first', - ); - expect(newestFirst, findsOneWidget); - expect( - find.descendant( - of: newestFirst, - matching: find.byIcon(CupertinoIcons.checkmark), - ), - findsOneWidget, - ); - final selected = find.descendant( - of: newestFirst, - matching: find.byWidgetPredicate( - (widget) => widget is Semantics && widget.properties.selected == true, - ), - ); - expect(selected, findsOneWidget); + expect(controller.sort, 'oldest_first'); }); testWidgets('the usage page is honest when nothing was reported', ( diff --git a/app/test/ui/layout/app_list_row_test.dart b/app/test/ui/layout/app_list_row_test.dart index 2d6b2347..d56c71e7 100644 --- a/app/test/ui/layout/app_list_row_test.dart +++ b/app/test/ui/layout/app_list_row_test.dart @@ -121,25 +121,18 @@ void main() { await tester.pumpAndSettle(); expect(taps, 1); - // One overflow icon per host; the menu items keep their keys. - expect( - find.descendant( - of: find.byKey(const Key('menu')), - matching: find.byIcon( - cupertino ? CupertinoIcons.ellipsis : Icons.more_vert, - ), - ), + // The overflow control is the same Material menu on every host. + expect( + find.descendant( + of: find.byKey(const Key('menu')), + matching: find.byIcon(Icons.more_vert), + ), findsOneWidget, ); await tester.tap(find.byKey(const Key('menu'))); await tester.pumpAndSettle(); expect(taps, 1, reason: 'the menu is its own control'); - if (cupertino) { - expect(find.byType(CupertinoActionSheet), findsOneWidget); - expect(find.text('Cancel'), findsOneWidget); - } else { - expect(find.byType(PopupMenuItem), findsNWidgets(2)); - } + expect(find.byType(PopupMenuItem), findsNWidgets(2)); await tester.tap(find.byKey(const Key('menu-delete'))); await tester.pumpAndSettle(); expect(picked, 'delete');