π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][locker] Remove the legacy upload screen (#13924)
aman-pilot70d582f09909
diff --git a/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart b/mobile/apps/locker/lib/ui/pages/file_upload_screen.dartindex 1951559616..350f9c208b 100644--- a/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart+++ b/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart@@ -1,15 +1,17 @@import 'dart:convert';import 'dart:io';-import "package:ente_components/ente_components.dart";+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: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.dart';import 'package:locker/ui/components/text_input_sheet.dart';-import "package:locker/utils/file_icon_utils.dart";+import 'package:locker/utils/bottom_sheet_illustration.dart';+import 'package:locker/utils/file_icon_utils.dart';import 'package:path/path.dart' as path;class FileUploadScreenResult {@@ -26,6 +28,10 @@ class FileUploadScreenResult {});}+const _maxShare = 0.35;++enum _FileAction { rename, remove }+class FileUploadScreen extends StatefulWidget {final List<File> files;final List<Collection> collections;@@ -43,54 +49,301 @@ class FileUploadScreen extends StatefulWidget {}class _FileUploadScreenState extends State<FileUploadScreen> {- List<File> _files = [];+ late final List<File> _files = List.of(widget.files);+ late List<Collection> _collections = List.of(widget.collections);final Map<String, String> _fileNames = {};- List<Collection> _availableCollections = [];- final Set<int> _selectedCollectionIds = {};+ final Set<int> _selectedIds = {};@overridevoid initState() {super.initState();- _files = List.from(widget.files);- _availableCollections = List.from(widget.collections);-- final selectedCollection = widget.selectedCollection;- if (selectedCollection != null &&- (selectedCollection.type != CollectionType.uncategorized ||- !selectedCollection.isOwner(Configuration.instance.getUserID()!))) {- _selectedCollectionIds.add(selectedCollection.id);+ final selected = widget.selectedCollection;+ if (selected != null &&+ (selected.type != CollectionType.uncategorized ||+ !selected.isOwner(Configuration.instance.getUserID()!))) {+ _selectedIds.add(selected.id);}}@override- void dispose() {- super.dispose();+ 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: LayoutBuilder(+ builder: (context, constraints) =>+ CollectionSelectionWidget(+ title: '',+ maxHeight: constraints.maxHeight,+ 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,+ ),+ ],+ );+ },+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ ),+ );}- void _toggleCollection(int collectionId) {- setState(() {- if (_selectedCollectionIds.contains(collectionId)) {- _selectedCollectionIds.remove(collectionId);- } else {- _selectedCollectionIds.add(collectionId);- }- });+ 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:+ }}- void _onCollectionsUpdated(List<Collection> updatedCollections) {+ Future<void> _addFiles() async {+ final result = await FilePicker.pickFiles(+ type: FileType.any,+ allowMultiple: true,+ );+ if (result == null || !mounted) return;setState(() {- _availableCollections = updatedCollections;+ _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 currentName = _fileNames[file.path] ?? path.basename(file.path);+ final l10n = context.strings;+ final currentName = _nameOf(file);final extension = path.extension(file.path);final baseName = currentName.substring(0,currentName.length - extension.length,);- final l10n = context.strings;String? nameForUpload(String name) {if (name == baseName) return currentName;@@ -114,237 +367,181 @@ class _FileUploadScreenState extends State<FileUploadScreen> {validator: (name) {final fileName = nameForUpload(name);if (fileName == null) return l10n.enterFileName;- // The title is also used as a filesystem name when opening the upload.if (utf8.encode(fileName).length > 255) return l10n.fileNameTooLong;return null;},onSubmit: (name) async {- if (!mounted) return;final fileName = nameForUpload(name);- if (fileName == null) return;+ 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;@overrideWidget 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,+ ),+ ],+ ),+ ),+ );+ }+}++class _ScrollCard extends StatefulWidget {+ final int itemCount;+ final IndexedWidgetBuilder itemBuilder;++ const _ScrollCard({required this.itemCount, required this.itemBuilder});++ @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;+ }- return Scaffold(- appBar: AppBar(- backgroundColor: colors.backgroundBase,- surfaceTintColor: Colors.transparent,- automaticallyImplyLeading: false,- toolbarHeight: 0,- elevation: 0,+ @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,),- backgroundColor: colors.backgroundBase,- body: SafeArea(- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,+ child: ClipRRect(+ borderRadius: Radii.buttonBorder,+ child: NotificationListener<Notification>(+ onNotification: _onScroll,+ child: Stack(children: [- const SizedBox(height: 16),- Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- context.strings.uploadFiles,- style: TextStyles.display2.copyWith(- color: colors.textBase,- ),- overflow: TextOverflow.ellipsis,- maxLines: 1,- ),- Text(- context.strings.filesSelected(count: _files.length),- style: TextStyles.body.copyWith(- color: colors.textLight,- ),- ),- ],+ Scrollbar(+ controller: _controller,+ child: ListView.separated(+ controller: _controller,+ physics: const ClampingScrollPhysics(),+ shrinkWrap: true,+ padding: EdgeInsets.zero,+ itemCount: widget.itemCount,+ separatorBuilder: (_, _) => ColoredBox(+ color: colors.fillLight,+ child: const DividerComponent(),),- GestureDetector(- onTap: () {- Navigator.pop(context);- },- child: Container(- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(50),- color: colors.strokeDark,- ),- padding: const EdgeInsets.all(8),- child: Icon(- Icons.close,- size: 24,- color: colors.textBase,- ),+ itemBuilder: (context, index) => MenuGroupComponent(+ borderRadius: MenuGroupComponent.itemBorderRadius(+ index: index,+ itemCount: widget.itemCount,),+ items: [widget.itemBuilder(context, index)],),- ],+ ),),- const SizedBox(height: 16),- Expanded(- child: SingleChildScrollView(- controller: ScrollController(),- physics: const BouncingScrollPhysics(),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- if (_files.isNotEmpty) ...[- Container(- decoration: BoxDecoration(- color: colors.fillDark,- borderRadius: BorderRadius.circular(24),- ),- padding: const EdgeInsets.all(12),- child: ClipRRect(- borderRadius: BorderRadius.circular(16),- child: ConstrainedBox(- constraints: BoxConstraints(- maxHeight: _files.length > 5- ? 360- : _files.length * 72.0,- ),- child: ListView.separated(- shrinkWrap: true,- padding: EdgeInsets.zero,- physics: _files.length > 5- ? const BouncingScrollPhysics()- : const NeverScrollableScrollPhysics(),- itemCount: _files.length,- separatorBuilder: (context, index) =>- const SizedBox(height: 8),- itemBuilder: (context, index) {- return _buildFileItem(_files[index], colors);- },- ),- ),- ),- ),- const SizedBox(height: 24),- ],- Text(- context.strings.collectionLabel,- style: TextStyles.display2.copyWith(- color: colors.textBase,+ 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,+ ],),- overflow: TextOverflow.ellipsis,- maxLines: 1,),- const SizedBox(height: 16),- CollectionSelectionWidget(- collections: _availableCollections,- selectedCollectionIds: _selectedCollectionIds,- onToggleCollection: _toggleCollection,- onCollectionsUpdated: _onCollectionsUpdated,- title: "",- ),- ],+ ),),),),- const SizedBox(height: 12),- SafeArea(- minimum: const EdgeInsets.only(bottom: 8),- child: ButtonComponent(- label: context.strings.save,- onTap: () async {- final selectedCollections = _availableCollections- .where((c) => _selectedCollectionIds.contains(c.id))- .toList();- final result = FileUploadScreenResult(- files: List<File>.of(_files),- fileNames: {- for (final file in _files)- file.path:- _fileNames[file.path] ?? path.basename(file.path),- },- note: '',- selectedCollections: selectedCollections,- );- Navigator.of(context).pop(result);- },- ),- ),],),),),);}-- Widget _buildFileItem(File file, ColorTokens colors) {- final fileName = _fileNames[file.path] ?? path.basename(file.path);-- return Container(- padding: const EdgeInsets.all(12),- decoration: BoxDecoration(- color: colors.fillLight,- borderRadius: const BorderRadius.all(Radius.circular(20)),- ),- child: Row(- children: [- SizedBox(height: 40, width: 40, child: _buildFileIcon(fileName)),- const SizedBox(width: 12),- Expanded(- child: Text(- fileName,- overflow: TextOverflow.ellipsis,- maxLines: 1,- style: TextStyles.body,- ),- ),- const SizedBox(width: 12),- IconButtonComponent(- tooltip: context.strings.renameFile,- shouldSurfaceExecutionStates: false,- onTap: () => _renameFile(file),- icon: HugeIcon(- icon: HugeIcons.strokeRoundedEdit02,- color: colors.textBase,- size: 20,- ),- ),- const SizedBox(width: 8),- GestureDetector(- onTap: () {- setState(() {- _files.remove(file);- if (_files.isEmpty) {- Navigator.of(context).pop();- }- });- },- child: Container(- decoration: BoxDecoration(- shape: BoxShape.circle,- color: colors.strokeDark,- ),- padding: const EdgeInsets.all(6),- child: HugeIcon(- icon: HugeIcons.strokeRoundedCancel01,- color: colors.textBase,- size: 16,- ),- ),- ),- ],- ),- );- }-- Widget _buildFileIcon(String fileName) {- return FileIconUtils.getFileIcon(- context,- fileName,- backgroundColor: context.componentColors.backgroundBase,- );- }}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.dartdeleted file mode 100644index c6ca89c882..0000000000--- a/mobile/apps/locker/lib/ui/pages/file_upload_screen_v2.dart+++ /dev/null@@ -1,534 +0,0 @@-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.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: LayoutBuilder(- builder: (context, constraints) =>- CollectionSelectionWidget(- title: '',- maxHeight: constraints.maxHeight,- 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,- ),- ],- ),- ),- );- }-}--class _ScrollCard extends StatefulWidget {- final int itemCount;- final IndexedWidgetBuilder itemBuilder;-- const _ScrollCard({required this.itemCount, required this.itemBuilder});-- @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,- child: ListView.separated(- controller: _controller,- physics: const ClampingScrollPhysics(),- 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/uploader_page.dart b/mobile/apps/locker/lib/ui/pages/uploader_page.dartindex 56b9c0c395..226d8d1094 100644--- a/mobile/apps/locker/lib/ui/pages/uploader_page.dart+++ b/mobile/apps/locker/lib/ui/pages/uploader_page.dart@@ -15,7 +15,6 @@ import 'package:locker/services/files/sync/metadata_updater_service.dart';import 'package:locker/services/files/upload/file_upload_service.dart';import 'package:locker/ui/components/locker_progress_dialog.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,7 +82,7 @@ abstract class UploaderPageState<T extends UploaderPage> extends State<T> {final uploadResult = await Navigator.of(context).push<FileUploadScreenResult>(MaterialPageRoute(- builder: (context) => FileUploadScreenV2(+ builder: (context) => 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_test.dartsimilarity index 95%rename from mobile/apps/locker/test/ui/pages/file_upload_screen_v2_test.dartrename to mobile/apps/locker/test/ui/pages/file_upload_screen_test.dartindex 5f2243567c..08672908a9 100644--- a/mobile/apps/locker/test/ui/pages/file_upload_screen_v2_test.dart+++ b/mobile/apps/locker/test/ui/pages/file_upload_screen_test.dart@@ -10,7 +10,6 @@ import 'package:locker/services/collections/models/collection.dart';import 'package:locker/services/configuration.dart';import 'package:locker/ui/components/collection_selection_widget.dart';import 'package:locker/ui/pages/file_upload_screen.dart';-import 'package:locker/ui/pages/file_upload_screen_v2.dart';import '../../test_utils/configuration_test_util.dart';@@ -18,7 +17,7 @@ void main() {late Directory testRoot;setUp(() async {- testRoot = await setupLockerConfigurationForTest('upload_v2');+ testRoot = await setupLockerConfigurationForTest('upload');await Configuration.instance.setUserID(1);});@@ -63,7 +62,7 @@ void main() {final result = await Navigator.of(context).push<FileUploadScreenResult>(MaterialPageRoute(- builder: (_) => FileUploadScreenV2(+ builder: (_) => FileUploadScreen(files: uploadFiles ?? files,collections: collections,selectedCollection: selectedCollection,@@ -149,7 +148,7 @@ void main() {await tester.pumpAndSettle();}- expect(find.byType(FileUploadScreenV2), findsOneWidget);+ expect(find.byType(FileUploadScreen), findsOneWidget);expect(find.text('No items left to upload'), findsOneWidget);expect(find.text('Add items'), findsOneWidget);final save = tester.widget<ButtonComponent>(@@ -183,11 +182,11 @@ void main() {await tester.tap(find.byIcon(Icons.arrow_back));await tester.pumpAndSettle();expect(find.text('Discard upload?'), findsOneWidget);- expect(find.byType(FileUploadScreenV2), findsOneWidget);+ expect(find.byType(FileUploadScreen), findsOneWidget);await tester.tap(find.text('Discard'));await tester.pumpAndSettle();- expect(find.byType(FileUploadScreenV2), findsNothing);+ expect(find.byType(FileUploadScreen), findsNothing);});Future<void> showLongLists(WidgetTester tester) async {