Use proper sort icon in file explorer
Give the FilesHeader sort control a recognizable Material sort glyph while preserving the default overflow icon for other menus. Add focused widget coverage for sort key and direction behavior.
This commit is contained in:
@@ -82,6 +82,7 @@ class FilesHeader extends StatelessWidget {
|
||||
),
|
||||
AppOverflowMenu<FilesSortKey>(
|
||||
label: 'Sort',
|
||||
icon: const Icon(Icons.sort),
|
||||
onSelected: (_, key) =>
|
||||
controller.setSort(controller.sort.reverseOr(key)),
|
||||
actions: [
|
||||
|
||||
@@ -33,6 +33,7 @@ class AppOverflowMenu<T> extends StatelessWidget {
|
||||
this.label = 'More actions',
|
||||
this.sheetTitle,
|
||||
this.enabled = true,
|
||||
this.icon = const Icon(Icons.more_vert),
|
||||
});
|
||||
|
||||
final List<AppMenuAction<T>> actions;
|
||||
@@ -48,6 +49,10 @@ class AppOverflowMenu<T> extends StatelessWidget {
|
||||
|
||||
final bool enabled;
|
||||
|
||||
/// The button glyph. Most callers use the default overflow icon; controls
|
||||
/// whose action has a distinct meaning can provide a matching Material icon.
|
||||
final Widget icon;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (actions.isEmpty) return const SizedBox.shrink();
|
||||
@@ -57,7 +62,7 @@ class AppOverflowMenu<T> extends StatelessWidget {
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: PopupMenuButton<T>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
icon: icon,
|
||||
tooltip: label,
|
||||
enabled: enabled,
|
||||
onSelected: (value) => onSelected(context, value),
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# File explorer sort icon
|
||||
|
||||
- Changed `FilesHeader` to use the Material `Icons.sort` glyph for the Sort
|
||||
control instead of the generic overflow glyph.
|
||||
- Extended `AppOverflowMenu` with an optional icon while preserving the default
|
||||
`Icons.more_vert` for existing callers.
|
||||
- Added widget coverage for the recognizable sort icon and key/direction
|
||||
selection behavior.
|
||||
- Focused verification: `files_panel_test.dart` and `files_models_test.dart`
|
||||
through `tool/memwatch/full.sh`, followed by `tool/analyze.sh` (recorded in
|
||||
the stage handoff).
|
||||
@@ -93,6 +93,31 @@ void main() {
|
||||
expect(find.widgetWithText(TextButton, 'demo'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('file sorting uses a sort icon and preserves direction', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = await pump(tester);
|
||||
|
||||
expect(find.byTooltip('Sort'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.sort), findsOneWidget);
|
||||
expect(controller.sort.key, FilesSortKey.name);
|
||||
expect(controller.sort.ascending, isTrue);
|
||||
|
||||
await tester.tap(find.byTooltip('Sort'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('size'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sort.key, FilesSortKey.size);
|
||||
expect(controller.sort.ascending, isTrue);
|
||||
|
||||
await tester.tap(find.byTooltip('Sort'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('size ↑'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sort.key, FilesSortKey.size);
|
||||
expect(controller.sort.ascending, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('text tap opens shared viewer and fetches inline URL', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user