Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][locker] Add redesigned upload screen for internal users (#13620)

aman-pilote9f01a8df663
diff --git a/mobile/apps/locker/changes/upload-screen-redesign.md b/mobile/apps/locker/changes/upload-screen-redesign.md
new file mode 100644
index 0000000000..5ddb1d3b98
--- /dev/null
+++ b/mobile/apps/locker/changes/upload-screen-redesign.md
@@ -0,0 +1 @@
+- Redesigned the upload screen for internal users.
diff --git a/mobile/apps/locker/lib/ui/components/collection_selection_widget_v2.dart b/mobile/apps/locker/lib/ui/components/collection_selection_widget_v2.dart
new file mode 100644
index 0000000000..bee9d5df54
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/components/collection_selection_widget_v2.dart
@@ -0,0 +1,196 @@
+import 'package:ente_components/ente_components.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+import 'package:hugeicons/hugeicons.dart';
+import 'package:locker/extensions/collection_extension.dart';
+import 'package:locker/services/collections/collections_service.dart';
+import 'package:locker/services/collections/models/collection.dart';
+import 'package:locker/utils/collection_actions.dart';
+import 'package:locker/utils/collection_list_util.dart';
+import 'package:locker/utils/file_icon_utils.dart';
+
+class CollectionSelectionWidgetV2 extends StatefulWidget {
+ final List<Collection> collections;
+ final Set<int> selectedCollectionIds;
+ final void Function(int) onToggleCollection;
+ final void Function(List<Collection>) onCollectionsUpdated;
+
+ const CollectionSelectionWidgetV2({
+ super.key,
+ required this.collections,
+ required this.selectedCollectionIds,
+ required this.onToggleCollection,
+ required this.onCollectionsUpdated,
+ });
+
+ @override
+ State<CollectionSelectionWidgetV2> createState() =>
+ _CollectionSelectionWidgetV2State();
+}
+
+class _CollectionSelectionWidgetV2State
+ extends State<CollectionSelectionWidgetV2> {
+ final Map<int, Future<int>> _fileCounts = {};
+ final List<Collection> _created = [];
+
+ Future<void> _createCollection() async {
+ final created = await CollectionActions.createCollection(context);
+ if (created == null || !mounted) return;
+ _created.insert(0, created);
+ widget.onCollectionsUpdated([...widget.collections, created]);
+ widget.onToggleCollection(created.id);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ final l10n = context.strings;
+ final collections = uniqueCollectionsById([
+ ..._created,
+ ...widget.collections,
+ ]);
+ return ScrollCard(
+ showScrollbar: true,
+ itemCount: collections.length + 1,
+ itemBuilder: (context, index) {
+ if (index == 0) {
+ return MenuComponent(
+ title: l10n.newCollection,
+ titleColor: colors.primary,
+ iconColor: colors.primary,
+ leading: const HugeIcon(icon: HugeIcons.strokeRoundedAdd01),
+ onTap: _createCollection,
+ );
+ }
+ final collection = collections[index - 1];
+ return FutureBuilder<int>(
+ key: ValueKey(collection.id),
+ future: _fileCounts.putIfAbsent(
+ collection.id,
+ () => CollectionService.instance.getFileCount(collection),
+ ),
+ builder: (context, count) => MenuComponent(
+ title: collection.type == CollectionType.uncategorized
+ ? l10n.uncategorized
+ : collection.displayName ?? l10n.unnamedCollection,
+ titleMaxLines: 1,
+ subtitle: l10n.itemCount(count: count.data ?? 0),
+ leading: HugeIcon(
+ icon: collection.type == CollectionType.favorites
+ ? HugeIcons.strokeRoundedStar
+ : HugeIcons.strokeRoundedFolder01,
+ ),
+ trailing: widget.selectedCollectionIds.contains(collection.id)
+ ? const SelectionCheckBadge()
+ : null,
+ onTap: () => widget.onToggleCollection(collection.id),
+ ),
+ );
+ },
+ );
+ }
+}
+
+class ScrollCard extends StatefulWidget {
+ final int itemCount;
+ final IndexedWidgetBuilder itemBuilder;
+ final bool showScrollbar;
+
+ const ScrollCard({
+ super.key,
+ required this.itemCount,
+ required this.itemBuilder,
+ this.showScrollbar = false,
+ });
+
+ @override
+ State<ScrollCard> createState() => _ScrollCardState();
+}
+
+class _ScrollCardState extends State<ScrollCard> {
+ final _controller = ScrollController();
+ bool _hasMore = false;
+
+ @override
+ void dispose() {
+ _controller.dispose();
+ super.dispose();
+ }
+
+ bool _onScroll(Notification notification) {
+ if (notification
+ case ScrollMetricsNotification(:final metrics) ||
+ ScrollUpdateNotification(:final metrics)) {
+ final hasMore = metrics.extentAfter > 0;
+ if (hasMore != _hasMore) setState(() => _hasMore = hasMore);
+ }
+ return false;
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ return DecoratedBox(
+ position: DecorationPosition.foreground,
+ decoration: BoxDecoration(
+ border: Border.all(color: colors.strokeFaint),
+ borderRadius: Radii.buttonBorder,
+ ),
+ child: ClipRRect(
+ borderRadius: Radii.buttonBorder,
+ child: NotificationListener<Notification>(
+ onNotification: _onScroll,
+ child: Stack(
+ children: [
+ Scrollbar(
+ controller: _controller,
+ thumbVisibility: widget.showScrollbar,
+ child: ListView.separated(
+ controller: _controller,
+ shrinkWrap: true,
+ padding: EdgeInsets.zero,
+ itemCount: widget.itemCount,
+ separatorBuilder: (_, _) => ColoredBox(
+ color: colors.fillLight,
+ child: const DividerComponent(),
+ ),
+ itemBuilder: (context, index) => MenuGroupComponent(
+ borderRadius: MenuGroupComponent.itemBorderRadius(
+ index: index,
+ itemCount: widget.itemCount,
+ ),
+ items: [widget.itemBuilder(context, index)],
+ ),
+ ),
+ ),
+ Positioned(
+ left: 0,
+ right: 0,
+ bottom: 0,
+ height: Spacing.xxl,
+ child: IgnorePointer(
+ child: AnimatedOpacity(
+ opacity: _hasMore ? 1 : 0,
+ duration: Motion.quick,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ colors.fillLight.withValues(alpha: 0),
+ colors.fillLight,
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/apps/locker/lib/ui/pages/file_upload_screen_v2.dart b/mobile/apps/locker/lib/ui/pages/file_upload_screen_v2.dart
new file mode 100644
index 0000000000..96935dfd23
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/pages/file_upload_screen_v2.dart
@@ -0,0 +1,429 @@
+import 'dart:convert';
+import 'dart:io';
+
+import 'package:ente_components/ente_components.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:file_picker/file_picker.dart';
+import 'package:flutter/material.dart';
+import 'package:hugeicons/hugeicons.dart';
+import 'package:locker/services/collections/models/collection.dart';
+import 'package:locker/services/configuration.dart';
+import 'package:locker/ui/components/collection_selection_widget_v2.dart';
+import 'package:locker/ui/components/text_input_sheet.dart';
+import 'package:locker/ui/pages/file_upload_screen.dart';
+import 'package:locker/utils/bottom_sheet_illustration.dart';
+import 'package:locker/utils/file_icon_utils.dart';
+import 'package:path/path.dart' as path;
+
+const _maxShare = 0.35;
+
+enum _FileAction { rename, remove }
+
+class FileUploadScreenV2 extends StatefulWidget {
+ final List<File> files;
+ final List<Collection> collections;
+ final Collection? selectedCollection;
+
+ const FileUploadScreenV2({
+ super.key,
+ required this.files,
+ required this.collections,
+ this.selectedCollection,
+ });
+
+ @override
+ State<FileUploadScreenV2> createState() => _FileUploadScreenV2State();
+}
+
+class _FileUploadScreenV2State extends State<FileUploadScreenV2> {
+ late final List<File> _files = List.of(widget.files);
+ late List<Collection> _collections = List.of(widget.collections);
+ final Map<String, String> _fileNames = {};
+ final Set<int> _selectedIds = {};
+
+ @override
+ void initState() {
+ super.initState();
+ final selected = widget.selectedCollection;
+ if (selected != null &&
+ (selected.type != CollectionType.uncategorized ||
+ !selected.isOwner(Configuration.instance.getUserID()!))) {
+ _selectedIds.add(selected.id);
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ final l10n = context.strings;
+ final hasFiles = _files.isNotEmpty;
+ final selectedCount = _collections
+ .where((c) => _selectedIds.contains(c.id))
+ .length;
+
+ return PopScope(
+ canPop: !hasFiles,
+ onPopInvokedWithResult: (didPop, _) async {
+ if (didPop || !await _confirmDiscard() || !context.mounted) return;
+ Navigator.of(context).pop();
+ },
+ child: MediaQuery.withNoTextScaling(
+ child: Scaffold(
+ backgroundColor: colors.backgroundBase,
+ body: SafeArea(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: Spacing.sm),
+ child: Row(
+ children: [
+ IconButtonComponent(
+ variant: IconButtonComponentVariant.unfilled,
+ shouldSurfaceExecutionStates: false,
+ iconSize: IconSizes.medium,
+ icon: const Icon(Icons.arrow_back),
+ onTap: () => Navigator.maybePop(context),
+ ),
+ const SizedBox(width: Spacing.sm),
+ Expanded(
+ child: Text(
+ l10n.uploadFiles,
+ style: TextStyles.display3.copyWith(
+ color: colors.textBase,
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ ),
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.all(Spacing.lg),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final collections = IgnorePointer(
+ ignoring: !hasFiles,
+ child: AnimatedOpacity(
+ duration: Motion.standard,
+ opacity: hasFiles ? 1 : 0.5,
+ child: CollectionSelectionWidgetV2(
+ collections: _collections,
+ selectedCollectionIds: _selectedIds,
+ onToggleCollection: (id) => setState(() {
+ if (!_selectedIds.remove(id)) {
+ _selectedIds.add(id);
+ }
+ }),
+ onCollectionsUpdated: (collections) =>
+ setState(() => _collections = collections),
+ ),
+ ),
+ );
+ final files = AnimatedSwitcher(
+ duration: Motion.standard,
+ child: hasFiles
+ ? ScrollCard(
+ itemCount: _files.length,
+ itemBuilder: (context, index) {
+ final file = _files[index];
+ return MenuComponent(
+ key: ValueKey(file.path),
+ title: _nameOf(file),
+ titleMaxLines: 1,
+ leading: FileIconUtils.getFileIcon(
+ context,
+ _nameOf(file),
+ backgroundColor: Colors.transparent,
+ size: IconSizes.small,
+ ),
+ trailing: Builder(
+ builder: (anchor) =>
+ IconButtonComponent(
+ variant:
+ IconButtonComponentVariant
+ .unfilled,
+ shouldSurfaceExecutionStates:
+ false,
+ icon: const HugeIcon(
+ icon: HugeIcons
+ .strokeRoundedMoreVertical,
+ ),
+ onTap: () =>
+ _showFileMenu(anchor, file),
+ ),
+ ),
+ );
+ },
+ )
+ : _EmptyItems(onAdd: _addFiles),
+ );
+ final maxListHeight = BoxConstraints(
+ maxHeight: constraints.maxHeight * _maxShare,
+ );
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ _SectionLabel(
+ title: l10n.itemsLabel,
+ meta: l10n.itemCount(count: _files.length),
+ ),
+ const SizedBox(height: Spacing.sm),
+ Flexible(
+ child: ConstrainedBox(
+ constraints: maxListHeight,
+ child: files,
+ ),
+ ),
+ const SizedBox(height: Spacing.xl),
+ _SectionLabel(
+ title: l10n.addToCollections,
+ meta: selectedCount == 0
+ ? null
+ : l10n.selectedCount(
+ count: selectedCount,
+ ),
+ ),
+ const SizedBox(height: Spacing.xs),
+ Text(
+ l10n.uncategorizedUploadHint,
+ style: TextStyles.mini.copyWith(
+ color: colors.textLight,
+ ),
+ ),
+ const SizedBox(height: Spacing.sm),
+ Flexible(
+ child: ConstrainedBox(
+ constraints: maxListHeight,
+ child: collections,
+ ),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: Spacing.md),
+ ButtonComponent(
+ label: l10n.save,
+ isDisabled: !hasFiles,
+ onTap: _save,
+ ),
+ ],
+ );
+ },
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ String _nameOf(File file) =>
+ _fileNames[file.path] ?? path.basename(file.path);
+
+ void _save() {
+ Navigator.of(context).pop(
+ FileUploadScreenResult(
+ files: List.of(_files),
+ fileNames: {for (final file in _files) file.path: _nameOf(file)},
+ note: '',
+ selectedCollections: _collections
+ .where((c) => _selectedIds.contains(c.id))
+ .toList(),
+ ),
+ );
+ }
+
+ Future<void> _showFileMenu(BuildContext anchor, File file) async {
+ final l10n = context.strings;
+ final warning = context.componentColors.warning;
+ final action = await showEntePopupMenu<_FileAction>(
+ context: anchor,
+ options: [
+ EntePopupMenuOption(
+ value: _FileAction.rename,
+ label: l10n.rename,
+ leadingWidget: const HugeIcon(
+ icon: HugeIcons.strokeRoundedEdit02,
+ size: IconSizes.small,
+ ),
+ ),
+ EntePopupMenuOption(
+ value: _FileAction.remove,
+ label: l10n.remove,
+ labelColor: warning,
+ leadingWidget: HugeIcon(
+ icon: HugeIcons.strokeRoundedCancel01,
+ color: warning,
+ size: IconSizes.small,
+ ),
+ ),
+ ],
+ );
+ if (!mounted) return;
+ switch (action) {
+ case _FileAction.rename:
+ await _renameFile(file);
+ case _FileAction.remove:
+ setState(() {
+ _files.remove(file);
+ _fileNames.remove(file.path);
+ });
+ case null:
+ }
+ }
+
+ Future<void> _addFiles() async {
+ final result = await FilePicker.pickFiles(
+ type: FileType.any,
+ allowMultiple: true,
+ );
+ if (result == null || !mounted) return;
+ setState(() {
+ _files.addAll([
+ for (final file in result.files)
+ if (file.path != null) File(file.path!),
+ ]);
+ });
+ }
+
+ Future<bool> _confirmDiscard() async {
+ final l10n = context.strings;
+ final discard = await showBottomSheetComponent<bool>(
+ context: context,
+ builder: (sheetContext) => BottomSheetComponent(
+ title: l10n.discardUploadTitle,
+ message: l10n.discardUploadMessage,
+ illustration: LockerBottomSheetIllustration.warningGrey,
+ actions: [
+ ButtonComponent(
+ label: l10n.discardChanges,
+ variant: ButtonComponentVariant.critical,
+ onTap: () => Navigator.of(sheetContext).pop(true),
+ ),
+ ],
+ ),
+ );
+ return discard ?? false;
+ }
+
+ Future<void> _renameFile(File file) async {
+ final l10n = context.strings;
+ final currentName = _nameOf(file);
+ final extension = path.extension(file.path);
+ final baseName = currentName.substring(
+ 0,
+ currentName.length - extension.length,
+ );
+
+ String? nameForUpload(String name) {
+ if (name == baseName) return currentName;
+ var cleaned = name.replaceAll(RegExp(r'[/\\\x00-\x1f]'), '').trim();
+ if (extension.isNotEmpty &&
+ cleaned.toLowerCase().endsWith(extension.toLowerCase())) {
+ cleaned = cleaned
+ .substring(0, cleaned.length - extension.length)
+ .trim();
+ }
+ if (cleaned.isEmpty || cleaned == '.' || cleaned == '..') return null;
+ return '$cleaned$extension';
+ }
+
+ await showTextInputSheet(
+ context,
+ title: l10n.renameFile,
+ initialValue: baseName,
+ hintText: l10n.enterFileName,
+ submitButtonLabel: l10n.save,
+ validator: (name) {
+ final fileName = nameForUpload(name);
+ if (fileName == null) return l10n.enterFileName;
+ if (utf8.encode(fileName).length > 255) return l10n.fileNameTooLong;
+ return null;
+ },
+ onSubmit: (name) async {
+ final fileName = nameForUpload(name);
+ if (fileName == null || !mounted) return;
+ setState(() => _fileNames[file.path] = fileName);
+ },
+ );
+ }
+}
+
+class _SectionLabel extends StatelessWidget {
+ const _SectionLabel({required this.title, this.meta});
+
+ final String title;
+ final String? meta;
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ return Row(
+ children: [
+ Expanded(
+ child: Text(
+ title,
+ style: TextStyles.large.copyWith(color: colors.textBase),
+ ),
+ ),
+ if (meta != null)
+ Text(meta!, style: TextStyles.mini.copyWith(color: colors.textLight)),
+ ],
+ );
+ }
+}
+
+class _EmptyItems extends StatelessWidget {
+ const _EmptyItems({required this.onAdd});
+
+ final VoidCallback onAdd;
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ final l10n = context.strings;
+ return SingleChildScrollView(
+ child: Container(
+ padding: const EdgeInsets.all(Spacing.xxl),
+ decoration: BoxDecoration(
+ color: colors.fillLight,
+ borderRadius: Radii.buttonBorder,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ HugeIcon(
+ icon: HugeIcons.strokeRoundedFile02,
+ color: colors.textLighter,
+ size: IconSizes.large,
+ ),
+ const SizedBox(height: Spacing.md),
+ Text(
+ l10n.uploadItemsRemoved,
+ textAlign: TextAlign.center,
+ style: TextStyles.body.copyWith(color: colors.textLight),
+ ),
+ const SizedBox(height: Spacing.lg),
+ ButtonComponent(
+ label: l10n.addItems,
+ variant: ButtonComponentVariant.secondary,
+ leading: const HugeIcon(icon: HugeIcons.strokeRoundedAdd01),
+ shouldSurfaceExecutionStates: false,
+ onTap: onAdd,
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/apps/locker/lib/ui/pages/uploader_page.dart b/mobile/apps/locker/lib/ui/pages/uploader_page.dart
index 49dfb33d25..fbabaa963d 100644
--- a/mobile/apps/locker/lib/ui/pages/uploader_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/uploader_page.dart
@@ -13,9 +13,11 @@ import 'package:locker/core/errors.dart';
import 'package:locker/events/user_details_refresh_event.dart';
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/collections/models/collection.dart';
+import 'package:locker/services/feature_flag_service.dart';
import 'package:locker/services/files/sync/metadata_updater_service.dart';
import 'package:locker/services/files/upload/file_upload_service.dart';
import 'package:locker/ui/pages/file_upload_screen.dart';
+import 'package:locker/ui/pages/file_upload_screen_v2.dart';
import "package:locker/utils/bottom_sheet_illustration.dart";
import "package:locker/utils/error_sheet.dart";
import 'package:logging/logging.dart';
@@ -83,11 +85,17 @@ abstract class UploaderPageState<T extends UploaderPage> extends State<T> {
final uploadResult = await Navigator.of(context)
.push<FileUploadScreenResult>(
MaterialPageRoute(
- builder: (context) => FileUploadScreen(
- files: files,
- collections: regularCollections,
- selectedCollection: selectedCollection,
- ),
+ builder: (context) => FeatureFlagService.instance.internalUser
+ ? FileUploadScreenV2(
+ files: files,
+ collections: regularCollections,
+ selectedCollection: selectedCollection,
+ )
+ : FileUploadScreen(
+ files: files,
+ collections: regularCollections,
+ selectedCollection: selectedCollection,
+ ),
),
);
diff --git a/mobile/apps/locker/test/ui/pages/file_upload_screen_v2_test.dart b/mobile/apps/locker/test/ui/pages/file_upload_screen_v2_test.dart
new file mode 100644
index 0000000000..7a59d66019
--- /dev/null
+++ b/mobile/apps/locker/test/ui/pages/file_upload_screen_v2_test.dart
@@ -0,0 +1,261 @@
+import 'dart:io';
+
+import 'package:ente_components/ente_components.dart';
+import 'package:ente_sharing/models/user.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:hugeicons/hugeicons.dart';
+import 'package:locker/services/collections/models/collection.dart';
+import 'package:locker/ui/components/collection_selection_widget_v2.dart';
+import 'package:locker/ui/pages/file_upload_screen_v2.dart';
+
+void main() {
+ final files = [
+ File('/upload/Passport_scan.pdf'),
+ File('/upload/IMG_4821.png'),
+ ];
+
+ Future<void> showScreen(WidgetTester tester) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ localizationsDelegates: StringsLocalizations.localizationsDelegates,
+ supportedLocales: const [Locale('en')],
+ home: Builder(
+ builder: (context) => TextButton(
+ onPressed: () => Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (_) =>
+ FileUploadScreenV2(files: files, collections: const []),
+ ),
+ ),
+ child: const Text('open'),
+ ),
+ ),
+ ),
+ );
+ await tester.tap(find.text('open'));
+ await tester.pumpAndSettle();
+ }
+
+ Future<void> openRowMenu(WidgetTester tester) async {
+ await tester.tap(
+ find
+ .byWidgetPredicate(
+ (w) =>
+ w is HugeIcon && w.icon == HugeIcons.strokeRoundedMoreVertical,
+ )
+ .first,
+ );
+ await tester.pumpAndSettle();
+ }
+
+ testWidgets('removing every file shows the empty state instead of popping', (
+ tester,
+ ) async {
+ await showScreen(tester);
+
+ for (var i = 0; i < files.length; i++) {
+ await openRowMenu(tester);
+ await tester.tap(find.text('Remove'));
+ await tester.pumpAndSettle();
+ }
+
+ expect(find.byType(FileUploadScreenV2), findsOneWidget);
+ expect(find.text('No items left to upload'), findsOneWidget);
+ expect(find.text('Add items'), findsOneWidget);
+ final save = tester.widget<ButtonComponent>(
+ find.widgetWithText(ButtonComponent, 'Save'),
+ );
+ expect(save.isDisabled, isTrue);
+ });
+
+ testWidgets('rename from the row menu keeps the extension', (tester) async {
+ await showScreen(tester);
+
+ await openRowMenu(tester);
+ await tester.tap(find.text('Rename'));
+ await tester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), 'Passport 2026');
+ await tester.tap(
+ find.descendant(
+ of: find.byType(BottomSheetComponent),
+ matching: find.text('Save'),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ expect(find.text('Passport 2026.pdf'), findsOneWidget);
+ expect(find.text('Passport_scan.pdf'), findsNothing);
+ });
+
+ testWidgets('back with items asks before discarding them', (tester) async {
+ await showScreen(tester);
+
+ await tester.tap(find.byIcon(Icons.arrow_back));
+ await tester.pumpAndSettle();
+ expect(find.text('Discard upload?'), findsOneWidget);
+ expect(find.byType(FileUploadScreenV2), findsOneWidget);
+
+ await tester.tap(find.text('Discard'));
+ await tester.pumpAndSettle();
+ expect(find.byType(FileUploadScreenV2), findsNothing);
+ });
+
+ testWidgets('a removed file comes back with its original name', (
+ tester,
+ ) async {
+ tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
+ const MethodChannel('miguelruivo.flutter.plugins.filepicker'),
+ (call) async => [
+ {
+ 'name': 'Passport_scan.pdf',
+ 'path': '/upload/Passport_scan.pdf',
+ 'size': 1,
+ },
+ ],
+ );
+ addTearDown(
+ () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
+ const MethodChannel('miguelruivo.flutter.plugins.filepicker'),
+ null,
+ ),
+ );
+ await showScreen(tester);
+
+ await openRowMenu(tester);
+ await tester.tap(find.text('Rename'));
+ await tester.pumpAndSettle();
+ await tester.enterText(find.byType(TextField), 'Passport 2026');
+ await tester.tap(
+ find.descendant(
+ of: find.byType(BottomSheetComponent),
+ matching: find.text('Save'),
+ ),
+ );
+ await tester.pumpAndSettle();
+ for (var i = 0; i < files.length; i++) {
+ await openRowMenu(tester);
+ await tester.tap(find.text('Remove'));
+ await tester.pumpAndSettle();
+ }
+
+ await tester.tap(find.text('Add items'));
+ await tester.pumpAndSettle();
+
+ expect(find.text('Passport_scan.pdf'), findsOneWidget);
+ expect(find.text('Passport 2026.pdf'), findsNothing);
+ });
+
+ Future<List<double>> cardHeights(
+ WidgetTester tester, {
+ required int files,
+ required int collections,
+ }) async {
+ tester.view.physicalSize = const Size(390, 844);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(
+ MaterialApp(
+ localizationsDelegates: StringsLocalizations.localizationsDelegates,
+ supportedLocales: const [Locale('en')],
+ home: FileUploadScreenV2(
+ key: ValueKey((files, collections)),
+ files: [for (var i = 0; i < files; i++) File('/upload/f$i.pdf')],
+ collections: [
+ for (var i = 0; i < collections; i++)
+ Collection(
+ i,
+ User(id: 1, email: '[email protected]'),
+ '',
+ null,
+ 'Collection $i',
+ null,
+ null,
+ CollectionType.folder,
+ CollectionAttributes(),
+ const [],
+ const [],
+ 0,
+ ),
+ ],
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ return [
+ for (final card in tester.widgetList(find.byType(ScrollCard)))
+ tester.getSize(find.byWidget(card)).height,
+ ];
+ }
+
+ testWidgets('long lists each stop at the same share of the screen', (
+ tester,
+ ) async {
+ final heights = await cardHeights(tester, files: 10, collections: 10);
+ expect(heights[0], moreOrLessEquals(heights[1]));
+ expect(heights[0], lessThan(844 * 0.35));
+ });
+
+ testWidgets('a large batch only builds the visible file rows', (
+ tester,
+ ) async {
+ await cardHeights(tester, files: 1000, collections: 0);
+ expect(
+ find.byType(MenuComponent, skipOffstage: false).evaluate().length,
+ lessThan(50),
+ );
+ });
+
+ testWidgets('large system text keeps Save on screen', (tester) async {
+ tester.view.physicalSize = const Size(320, 568);
+ tester.view.devicePixelRatio = 1;
+ tester.platformDispatcher.textScaleFactorTestValue = 3;
+ addTearDown(tester.view.reset);
+ addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
+ await tester.pumpWidget(
+ MaterialApp(
+ localizationsDelegates: StringsLocalizations.localizationsDelegates,
+ supportedLocales: const [Locale('en')],
+ home: FileUploadScreenV2(
+ files: [for (var i = 0; i < 10; i++) File('/upload/f$i.pdf')],
+ collections: const [],
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ expect(tester.takeException(), isNull);
+ expect(find.text('Save').hitTestable(), findsOneWidget);
+ });
+
+ testWidgets('a short file list leaves the rest to collections', (
+ tester,
+ ) async {
+ final heights = await cardHeights(tester, files: 1, collections: 10);
+ expect(heights[1], greaterThan(heights[0] * 3));
+ });
+
+ testWidgets('a short portrait phone keeps collections reachable', (
+ tester,
+ ) async {
+ tester.view.physicalSize = const Size(320, 520);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(
+ MaterialApp(
+ localizationsDelegates: StringsLocalizations.localizationsDelegates,
+ supportedLocales: const [Locale('en')],
+ home: FileUploadScreenV2(
+ files: [for (var i = 0; i < 10; i++) File('/upload/f$i.pdf')],
+ collections: const [],
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ expect(tester.takeException(), isNull);
+ expect(find.text('New collection').hitTestable(), findsOneWidget);
+ });
+}
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index 34af554e10..165f2576b8 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -133,6 +133,7 @@
"count": {}
}
},
+ "addItems": "Add items",
"addLocation": "Add location",
"addLocationButton": "Add",
"addMember": "Add member",
@@ -168,6 +169,7 @@
"addTo": "Add to",
"addToAlbum": "Add to album",
"addToCollection": "Add to collection",
+ "addToCollections": "Add to collections",
"addToEnte": "Add to Ente",
"addToHiddenAlbum": "Add to hidden album",
"addToPerson": "Add to person",
@@ -1084,6 +1086,8 @@
"disablingTwofactorAuthentication": "Disabling two-factor authentication...",
"discardChanges": "Discard",
"discardEditsQuestion": "Discard edits?",
+ "discardUploadMessage": "The items you picked won't be saved.",
+ "discardUploadTitle": "Discard upload?",
"discover": "Discover",
"@discover": {
"description": "The text to display for the discover section under which we show receipts, screenshots, sunsets, greenery, etc."
@@ -2117,6 +2121,7 @@
}
}
},
+ "itemsLabel": "Items",
"itemsShowTheNumberOfDaysRemainingBeforePermanentDeletion": "Items show the number of days remaining before permanent deletion",
"itemsStored": "Items stored",
"itemsWillBeDeletedFromAllCollections": "{count, plural, one{This item will be deleted from all collections. You can recover it from Trash.} other{These items will be deleted from all collections. You can recover them from Trash.}}",
@@ -4586,6 +4591,7 @@
"unavailableReferralCode": "This code is already taken",
"uncategorized": "Uncategorized",
"uncategorizedItemsWillShowUpHere": "Uncategorized items will show up here",
+ "uncategorizedUploadHint": "If you skip this, items go to Uncategorized",
"undo": "Undo",
"unhide": "Unhide",
"unhideToAlbum": "Unhide to album",
@@ -4684,6 +4690,7 @@
}
},
"uploadingSingleMemory": "Preserving 1 memory...",
+ "uploadItemsRemoved": "No items left to upload",
"uploadIsIgnoredDueToIgnorereason": "Upload is ignored due to {ignoreReason}",
"@uploadIsIgnoredDueToIgnorereason": {
"placeholders": {