Skip to content

Commit 2512f6a

Browse files
committed
[green] keep Files actions on one row
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent a61986b commit 2512f6a

16 files changed

Lines changed: 333 additions & 75 deletions

‎app/lib/files/files_view.dart‎

Lines changed: 157 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
/// Two ConnState-keyed treatments, read through the seam ([connStateProvider]):
88
/// * **Disconnected** — a quiet `folder_off` [EmptyState] with guidance and NO
99
/// destructive actions (nothing to act on).
10-
/// * **Connected** — a breadcrumb + action bar (Up / Refresh / New file / New
11-
/// folder / Upload / GitHub import) over the live listing. Tapping a folder
12-
/// descends; tapping
10+
/// * **Connected** — a breadcrumb + responsive, single-row action toolbar
11+
/// (Select / Refresh / New file / New folder / Upload / GitHub import) over
12+
/// the live listing. Lower-priority actions move into a labelled overflow
13+
/// only when all six targets do not fit. Tapping a folder descends; tapping
1314
/// a file opens it in the editor. Each row carries rename/delete affordances.
1415
/// A determinate transfer bar shows during a transfer; a typed failure is
1516
/// surfaced as an ARB-localized message (FR-FILES-3), never a raw code.
@@ -40,8 +41,19 @@ import 'package:pyble/theme/theme.dart';
4041
import 'file_explorer_controller.dart';
4142

4243
/// Stable interaction keys used by widget, golden, and hardware acceptance
43-
/// tests for the visible-file multi-delete workflow (ADR-0043).
44+
/// tests for the normal toolbar and visible-file multi-delete workflow
45+
/// (ADR-0043).
4446
const Key kFilesSelectActionKey = ValueKey<String>('filesSelectAction');
47+
const Key kFilesNormalActionsRowKey = ValueKey<String>('filesNormalActionsRow');
48+
const Key kFilesActionsOverflowButtonKey = ValueKey<String>(
49+
'filesActionsOverflowButton',
50+
);
51+
const Key kFilesOverflowRefreshKey = ValueKey<String>('filesOverflowRefresh');
52+
const Key kFilesOverflowNewFileKey = ValueKey<String>('filesOverflowNewFile');
53+
const Key kFilesOverflowNewFolderKey = ValueKey<String>(
54+
'filesOverflowNewFolder',
55+
);
56+
const Key kFilesOverflowUploadKey = ValueKey<String>('filesOverflowUpload');
4557
const Key kFilesSelectionBarKey = ValueKey<String>('filesSelectionBar');
4658
const Key kFilesSelectAllShownKey = ValueKey<String>('filesSelectAllShown');
4759
const Key kFilesBulkDeleteActionKey = ValueKey<String>('filesBulkDeleteAction');
@@ -552,8 +564,9 @@ class _ExplorerState extends ConsumerState<_Explorer> {
552564
}
553565
}
554566

555-
/// The breadcrumb + action bar. Actions live in a [Wrap] so they never overflow
556-
/// a narrow pane.
567+
enum _FilesOverflowAction { refresh, newFile, newFolder, upload }
568+
569+
/// The breadcrumb + responsive one-row action toolbar.
557570
class _ActionBar extends StatelessWidget {
558571
const _ActionBar({
559572
required this.state,
@@ -580,6 +593,21 @@ class _ActionBar extends StatelessWidget {
580593
@override
581594
Widget build(BuildContext context) {
582595
final ColorScheme scheme = Theme.of(context).colorScheme;
596+
final Widget selectAction = IconButton(
597+
key: kFilesSelectActionKey,
598+
focusNode: selectFocus,
599+
tooltip: l10n.filesActionSelect,
600+
onPressed: canSelect ? onSelect : null,
601+
icon: const Icon(Icons.checklist_outlined),
602+
);
603+
final Widget githubAction = IconButton(
604+
focusNode: githubImportFocus,
605+
tooltip: githubImportEnabled
606+
? l10n.githubImportAction
607+
: l10n.githubImportRequiresReady,
608+
icon: const Icon(Icons.cloud_download_outlined),
609+
onPressed: githubImportEnabled ? openGithubImport : null,
610+
);
583611
return Column(
584612
crossAxisAlignment: CrossAxisAlignment.stretch,
585613
children: <Widget>[
@@ -615,47 +643,113 @@ class _ActionBar extends StatelessWidget {
615643
alignment: Alignment.centerRight,
616644
child: Padding(
617645
padding: const EdgeInsets.symmetric(horizontal: SignalSpacing.xs),
618-
child: Wrap(
619-
spacing: SignalSpacing.xs,
620-
crossAxisAlignment: WrapCrossAlignment.center,
621-
children: <Widget>[
622-
TextButton.icon(
623-
key: kFilesSelectActionKey,
624-
focusNode: selectFocus,
625-
style: TextButton.styleFrom(minimumSize: const Size(48, 48)),
626-
onPressed: canSelect ? onSelect : null,
627-
icon: const Icon(Icons.checklist_outlined),
628-
label: Text(l10n.filesActionSelect),
629-
),
630-
IconButton(
631-
tooltip: l10n.filesActionRefresh,
632-
icon: const Icon(Icons.refresh),
633-
onPressed: () => ctrl.refresh(),
634-
),
635-
IconButton(
636-
tooltip: l10n.filesEmptyCta,
637-
icon: const Icon(Icons.note_add_outlined),
638-
onPressed: () => _promptNewFile(context, ctrl, l10n),
639-
),
640-
IconButton(
641-
tooltip: l10n.filesActionNewFolder,
642-
icon: const Icon(Icons.create_new_folder_outlined),
643-
onPressed: () => _promptNewFolder(context, ctrl, l10n),
644-
),
645-
IconButton(
646-
tooltip: l10n.filesActionUpload,
647-
icon: const Icon(Icons.upload_file_outlined),
648-
onPressed: () => ctrl.uploadCurrentBuffer(),
649-
),
650-
IconButton(
651-
focusNode: githubImportFocus,
652-
tooltip: githubImportEnabled
653-
? l10n.githubImportAction
654-
: l10n.githubImportRequiresReady,
655-
icon: const Icon(Icons.cloud_download_outlined),
656-
onPressed: githubImportEnabled ? openGithubImport : null,
657-
),
658-
],
646+
child: LayoutBuilder(
647+
builder: (BuildContext context, BoxConstraints constraints) {
648+
// Six direct Material targets need 288 dp. Below that exact
649+
// bound, keep the two priority actions visible and move the
650+
// remaining four into one labelled, accessible menu.
651+
final bool compact = constraints.maxWidth < 6 * 48;
652+
return SizedBox(
653+
key: kFilesNormalActionsRowKey,
654+
height: 48,
655+
child: Row(
656+
mainAxisAlignment: MainAxisAlignment.end,
657+
children: compact
658+
? <Widget>[
659+
selectAction,
660+
githubAction,
661+
PopupMenuButton<_FilesOverflowAction>(
662+
key: kFilesActionsOverflowButtonKey,
663+
tooltip: l10n.filesMoreActions,
664+
constraints: const BoxConstraints(
665+
minWidth: 220,
666+
maxWidth: 320,
667+
),
668+
icon: const Icon(Icons.more_vert),
669+
onSelected: (_FilesOverflowAction action) {
670+
switch (action) {
671+
case _FilesOverflowAction.refresh:
672+
ctrl.refresh();
673+
break;
674+
case _FilesOverflowAction.newFile:
675+
_promptNewFile(context, ctrl, l10n);
676+
break;
677+
case _FilesOverflowAction.newFolder:
678+
_promptNewFolder(context, ctrl, l10n);
679+
break;
680+
case _FilesOverflowAction.upload:
681+
ctrl.uploadCurrentBuffer();
682+
break;
683+
}
684+
},
685+
itemBuilder: (BuildContext context) =>
686+
<PopupMenuEntry<_FilesOverflowAction>>[
687+
PopupMenuItem<_FilesOverflowAction>(
688+
key: kFilesOverflowRefreshKey,
689+
value: _FilesOverflowAction.refresh,
690+
child: _FilesOverflowLabel(
691+
icon: Icons.refresh,
692+
label: l10n.filesActionRefresh,
693+
),
694+
),
695+
PopupMenuItem<_FilesOverflowAction>(
696+
key: kFilesOverflowNewFileKey,
697+
value: _FilesOverflowAction.newFile,
698+
child: _FilesOverflowLabel(
699+
icon: Icons.note_add_outlined,
700+
label: l10n.filesEmptyCta,
701+
),
702+
),
703+
PopupMenuItem<_FilesOverflowAction>(
704+
key: kFilesOverflowNewFolderKey,
705+
value: _FilesOverflowAction.newFolder,
706+
child: _FilesOverflowLabel(
707+
icon: Icons.create_new_folder_outlined,
708+
label: l10n.filesActionNewFolder,
709+
),
710+
),
711+
PopupMenuItem<_FilesOverflowAction>(
712+
key: kFilesOverflowUploadKey,
713+
value: _FilesOverflowAction.upload,
714+
child: _FilesOverflowLabel(
715+
icon: Icons.upload_file_outlined,
716+
label: l10n.filesActionUpload,
717+
),
718+
),
719+
],
720+
),
721+
]
722+
: <Widget>[
723+
selectAction,
724+
IconButton(
725+
tooltip: l10n.filesActionRefresh,
726+
icon: const Icon(Icons.refresh),
727+
onPressed: () => ctrl.refresh(),
728+
),
729+
IconButton(
730+
tooltip: l10n.filesEmptyCta,
731+
icon: const Icon(Icons.note_add_outlined),
732+
onPressed: () =>
733+
_promptNewFile(context, ctrl, l10n),
734+
),
735+
IconButton(
736+
tooltip: l10n.filesActionNewFolder,
737+
icon: const Icon(
738+
Icons.create_new_folder_outlined,
739+
),
740+
onPressed: () =>
741+
_promptNewFolder(context, ctrl, l10n),
742+
),
743+
IconButton(
744+
tooltip: l10n.filesActionUpload,
745+
icon: const Icon(Icons.upload_file_outlined),
746+
onPressed: () => ctrl.uploadCurrentBuffer(),
747+
),
748+
githubAction,
749+
],
750+
),
751+
);
752+
},
659753
),
660754
),
661755
),
@@ -664,6 +758,22 @@ class _ActionBar extends StatelessWidget {
664758
}
665759
}
666760

761+
class _FilesOverflowLabel extends StatelessWidget {
762+
const _FilesOverflowLabel({required this.icon, required this.label});
763+
764+
final IconData icon;
765+
final String label;
766+
767+
@override
768+
Widget build(BuildContext context) => Row(
769+
children: <Widget>[
770+
Icon(icon, size: 20),
771+
const SizedBox(width: SignalSpacing.md),
772+
Expanded(child: Text(label)),
773+
],
774+
);
775+
}
776+
667777
/// Session-scoped replacement for the ordinary Files actions. It stays compact
668778
/// on a wide tablet pane and deliberately reflows into two rows for a narrow
669779
/// phone/pane or large text, preserving every 48 dp action target.

‎app/test/golden/files_multi_delete_golden_test.dart‎

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// SPDX-License-Identifier: MIT
22
// Part of PyBLE (https://pyble.dev) — see /LICENSE.
33
//
4-
// A-30 / ADR-0043 [red] — adaptive visual coverage for Files regular-file
5-
// multi-selection and its exact, non-atomic delete confirmation. Every board
6-
// entry is an authored in-memory fixture and all filesystem access crosses the
7-
// neutral Connection seam.
4+
// A-30 / ADR-0043 [red] — adaptive visual coverage for the normal Files action
5+
// toolbar, regular-file multi-selection, and its exact non-atomic delete
6+
// confirmation. Every board entry is an authored in-memory fixture and all
7+
// filesystem access crosses the neutral Connection seam.
88

99
import 'dart:convert';
1010
import 'dart:typed_data';
@@ -144,7 +144,42 @@ Future<void> _expectGolden(WidgetTester tester, String name) => expectLater(
144144
);
145145

146146
void main() {
147-
group('A-30 Files visible-file multi-delete goldens', () {
147+
group('A-30 Files adaptive chrome and multi-delete goldens', () {
148+
testWidgets(
149+
'252 dp pane keeps priority actions on one row and opens labelled overflow',
150+
(WidgetTester tester) async {
151+
final RecordingConnection connection = await _fixtureConnection();
152+
addTearDown(connection.dispose);
153+
154+
await _pumpGoldenHost(
155+
tester,
156+
connection: connection,
157+
size: const Size(252, 568),
158+
);
159+
final AppLocalizations l10n = _l10n(tester);
160+
161+
expect(find.byKey(kFilesNormalActionsRowKey), findsOneWidget);
162+
expect(find.byTooltip(l10n.filesActionSelect), findsOneWidget);
163+
expect(find.byTooltip(l10n.githubImportAction), findsOneWidget);
164+
expect(find.byKey(kFilesActionsOverflowButtonKey), findsOneWidget);
165+
expect(find.byTooltip(l10n.filesActionRefresh), findsNothing);
166+
expect(find.byTooltip(l10n.filesEmptyCta), findsNothing);
167+
expect(find.byTooltip(l10n.filesActionNewFolder), findsNothing);
168+
expect(find.byTooltip(l10n.filesActionUpload), findsNothing);
169+
expect(tester.takeException(), isNull);
170+
171+
await tester.tap(find.byKey(kFilesActionsOverflowButtonKey));
172+
await tester.pumpAndSettle();
173+
expect(find.text(l10n.filesActionRefresh), findsOneWidget);
174+
expect(find.text(l10n.filesEmptyCta), findsOneWidget);
175+
expect(find.text(l10n.filesActionNewFolder), findsOneWidget);
176+
expect(find.text(l10n.filesActionUpload), findsOneWidget);
177+
178+
await _expectGolden(tester, 'files_toolbar_252_compact_overflow');
179+
},
180+
tags: const <String>['golden'],
181+
);
182+
148183
testWidgets(
149184
'320 dp pane reflows the contextual selection bar without selecting folders or locked files',
150185
(WidgetTester tester) async {
8.64 KB
Loading
-299 Bytes
Loading
-319 Bytes
Loading
-1 Bytes
Loading
-1 Bytes
Loading
1 Byte
Loading
0 Bytes
Loading
-3 Bytes
Loading

0 commit comments

Comments
 (0)