π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update file upload screen UI to match Figma design
AmanRajSinghMourya71026379a526
diff --git a/mobile/apps/locker/lib/ui/components/collection_list_widget.dart b/mobile/apps/locker/lib/ui/components/collection_list_widget.dartnew file mode 100644index 0000000000..ab59eb27c4--- /dev/null+++ b/mobile/apps/locker/lib/ui/components/collection_list_widget.dart@@ -0,0 +1,280 @@+import "package:ente_events/event_bus.dart";+import "package:ente_ui/components/buttons/icon_button_widget.dart";+import "package:ente_ui/theme/ente_theme.dart";+import "package:flutter/material.dart";+import "package:hugeicons/hugeicons.dart";+import "package:locker/events/collections_updated_event.dart";+import "package:locker/l10n/l10n.dart";+import "package:locker/models/selected_collections.dart";+import "package:locker/services/collections/collections_service.dart";+import "package:locker/services/collections/models/collection.dart";+import "package:locker/services/collections/models/collection_view_type.dart";+import "package:locker/services/configuration.dart";+import "package:locker/ui/components/item_list_view.dart";+import "package:locker/ui/pages/collection_page.dart";+import "package:locker/utils/collection_actions.dart";++class CollectionListWidget extends StatelessWidget {+ final Collection collection;+ final List<OverflowMenuAction>? overflowActions;+ final bool isLastItem;+ final SelectedCollections? selectedCollections;+ final void Function(Collection)? onTapCallback;+ final void Function(Collection)? onLongPressCallback;++ const CollectionListWidget({+ super.key,+ required this.collection,+ this.overflowActions,+ this.isLastItem = false,+ this.selectedCollections,+ this.onTapCallback,+ this.onLongPressCallback,+ });++ @override+ Widget build(BuildContext context) {+ final textTheme = getEnteTextTheme(context);+ final colorScheme = getEnteColorScheme(context);++ final collectionRowWidget = Flexible(+ flex: 6,+ child: Row(+ children: [+ SizedBox(+ height: 60,+ width: 60,+ child: Padding(+ padding: const EdgeInsets.all(10.0),+ child: Container(+ decoration: BoxDecoration(+ color: colorScheme.backgroundBase,+ borderRadius: BorderRadius.circular(12),+ ),+ child: Padding(+ padding: const EdgeInsets.all(8.0),+ child: collection.type == CollectionType.favorites+ ? HugeIcon(+ icon: HugeIcons.strokeRoundedStar,+ color: getEnteColorScheme(context).primary700,+ )+ : HugeIcon(+ icon: HugeIcons.strokeRoundedWallet05,+ color: getEnteColorScheme(context).iconColor,+ ),+ ),+ ),+ ),+ ),+ const SizedBox(width: 12),+ Flexible(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ Text(+ collection.name ?? 'Unnamed Collection',+ overflow: TextOverflow.ellipsis,+ maxLines: 1,+ ),+ FutureBuilder<int>(+ future: CollectionService.instance.getFileCount(collection),+ builder: (context, snapshot) {+ final fileCount = snapshot.data ?? 0;+ return Text(+ context.l10n.items(fileCount),+ style: textTheme.small.copyWith(+ color: colorScheme.textMuted,+ ),+ );+ },+ ),+ ],+ ),+ ),+ ],+ ),+ );++ return GestureDetector(+ onTap: () {+ if (onTapCallback != null) {+ onTapCallback!(collection);+ } else {+ _openCollection(context);+ }+ },+ onLongPress: () {+ if (onLongPressCallback != null) {+ onLongPressCallback!(collection);+ }+ },+ behavior: HitTestBehavior.opaque,+ child: ListenableBuilder(+ listenable: selectedCollections ?? ValueNotifier(false),+ builder: (context, _) {+ final bool isSelected =+ selectedCollections?.isCollectionSelected(collection) ?? false;+ return AnimatedContainer(+ duration: const Duration(milliseconds: 200),+ curve: Curves.easeOut,+ decoration: BoxDecoration(+ border: Border.all(+ color: isSelected+ ? colorScheme.primary700+ : colorScheme.backdropBase,+ width: 1.5,+ ),+ color: colorScheme.backdropBase,+ borderRadius: const BorderRadius.all(Radius.circular(20)),+ ),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ collectionRowWidget,+ Flexible(+ flex: 1,+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 200),+ switchInCurve: Curves.easeOut,+ switchOutCurve: Curves.easeIn,+ child: isSelected+ ? IconButtonWidget(+ key: const ValueKey("selected"),+ icon: Icons.check_circle_rounded,+ iconButtonType: IconButtonType.secondary,+ iconColor: colorScheme.primary700,+ )+ : PopupMenuButton<String>(+ onSelected: (value) =>+ _handleMenuAction(context, value),+ child: Padding(+ padding: const EdgeInsets.all(12.0),+ child: HugeIcon(+ icon: HugeIcons.strokeRoundedMoreVertical,+ color: getEnteColorScheme(context).iconColor,+ ),+ ),+ itemBuilder: (BuildContext context) {+ return _buildPopupMenuItems(context);+ },+ ),+ ),+ ),+ ],+ ),+ );+ },+ ),+ );+ }++ List<PopupMenuItem<String>> _buildPopupMenuItems(BuildContext context) {+ final collectionViewType =+ getCollectionViewType(collection, Configuration.instance.getUserID()!);+ if (overflowActions != null && overflowActions!.isNotEmpty) {+ return overflowActions!+ .map(+ (action) => PopupMenuItem<String>(+ value: action.id,+ child: Row(+ children: [+ Icon(action.icon, size: 16),+ const SizedBox(width: 8),+ Text(action.label),+ ],+ ),+ ),+ )+ .toList();+ } else {+ return [+ if (collectionViewType == CollectionViewType.ownedCollection ||+ collectionViewType == CollectionViewType.hiddenOwnedCollection ||+ collectionViewType == CollectionViewType.quickLink)+ PopupMenuItem<String>(+ value: 'edit',+ child: Row(+ children: [+ const Icon(Icons.edit, size: 16),+ const SizedBox(width: 8),+ Text(context.l10n.edit),+ ],+ ),+ ),+ if (collectionViewType == CollectionViewType.ownedCollection ||+ collectionViewType == CollectionViewType.hiddenOwnedCollection ||+ collectionViewType == CollectionViewType.quickLink)+ PopupMenuItem<String>(+ value: 'delete',+ child: Row(+ children: [+ const Icon(Icons.delete, size: 16),+ const SizedBox(width: 8),+ Text(context.l10n.delete),+ ],+ ),+ ),+ if (collectionViewType == CollectionViewType.sharedCollection)+ PopupMenuItem<String>(+ value: 'leave_collection',+ child: Row(+ children: [+ const Icon(Icons.logout),+ const SizedBox(width: 12),+ Text(context.l10n.leaveCollection),+ ],+ ),+ ),+ ];+ }+ }++ void _handleMenuAction(BuildContext context, String action) {+ if (overflowActions != null && overflowActions!.isNotEmpty) {+ final customAction = overflowActions!.firstWhere(+ (a) => a.id == action,+ orElse: () => throw StateError('Action not found'),+ );+ customAction.onTap(context, null, collection);+ } else {+ switch (action) {+ case 'edit':+ _editCollection(context);+ break;+ case 'delete':+ _deleteCollection(context);+ break;+ case 'leave_collection':+ _leaveCollection(context);+ break;+ }+ }+ }++ void _editCollection(BuildContext context) {+ CollectionActions.editCollection(context, collection);+ }++ void _deleteCollection(BuildContext context) {+ CollectionActions.deleteCollection(context, collection);+ }++ void _openCollection(BuildContext context) {+ Navigator.of(context).push(+ MaterialPageRoute(+ builder: (context) => CollectionPage(collection: collection),+ ),+ );+ }++ Future<void> _leaveCollection(BuildContext context) async {+ await CollectionActions.leaveCollection(+ context,+ collection,+ onSuccess: () {+ Bus.instance.fire(CollectionsUpdatedEvent());+ },+ );+ }+}diff --git a/mobile/apps/locker/lib/ui/components/collection_row_widget.dart b/mobile/apps/locker/lib/ui/components/collection_row_widget.dartindex b611976505..d01bde33f5 100644--- a/mobile/apps/locker/lib/ui/components/collection_row_widget.dart+++ b/mobile/apps/locker/lib/ui/components/collection_row_widget.dart@@ -1,18 +1,11 @@-import "package:ente_events/event_bus.dart";-import "package:ente_ui/components/buttons/icon_button_widget.dart";import "package:ente_ui/theme/ente_theme.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";-import "package:locker/events/collections_updated_event.dart";import "package:locker/l10n/l10n.dart";import "package:locker/models/selected_collections.dart";import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";-import "package:locker/services/collections/models/collection_view_type.dart";-import "package:locker/services/configuration.dart";import "package:locker/ui/components/item_list_view.dart";-import "package:locker/ui/pages/collection_page.dart";-import "package:locker/utils/collection_actions.dart";class CollectionRowWidget extends StatelessWidget {final Collection collection;@@ -34,74 +27,14 @@ class CollectionRowWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);final colorScheme = getEnteColorScheme(context);-- final collectionRowWidget = Flexible(- flex: 6,- child: Row(- children: [- SizedBox(- height: 60,- width: 60,- child: Padding(- padding: const EdgeInsets.all(10.0),- child: Container(- decoration: BoxDecoration(- color: colorScheme.backgroundBase,- borderRadius: BorderRadius.circular(12),- ),- child: Padding(- padding: const EdgeInsets.all(8.0),- child: collection.type == CollectionType.favorites- ? HugeIcon(- icon: HugeIcons.strokeRoundedStar,- color: getEnteColorScheme(context).primary700,- )- : HugeIcon(- icon: HugeIcons.strokeRoundedWallet05,- color: getEnteColorScheme(context).iconColor,- ),- ),- ),- ),- ),- const SizedBox(width: 12),- Flexible(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisAlignment: MainAxisAlignment.center,- children: [- Text(- collection.name ?? 'Unnamed Collection',- overflow: TextOverflow.ellipsis,- maxLines: 1,- ),- FutureBuilder<int>(- future: CollectionService.instance.getFileCount(collection),- builder: (context, snapshot) {- final fileCount = snapshot.data ?? 0;- return Text(- context.l10n.items(fileCount),- style: textTheme.small.copyWith(- color: colorScheme.textMuted,- ),- );- },- ),- ],- ),- ),- ],- ),- );+ final textTheme = getEnteTextTheme(context);+ final collectionName = collection.name ?? context.l10n.unnamedCollection;return GestureDetector(onTap: () {if (onTapCallback != null) {onTapCallback!(collection);- } else {- _openCollection(context);}},onLongPress: () {@@ -109,7 +42,6 @@ class CollectionRowWidget extends StatelessWidget {onLongPressCallback!(collection);}},- behavior: HitTestBehavior.opaque,child: ListenableBuilder(listenable: selectedCollections ?? ValueNotifier(false),builder: (context, _) {@@ -125,41 +57,53 @@ class CollectionRowWidget extends StatelessWidget {: colorScheme.backdropBase,width: 1.5,),+ borderRadius: BorderRadius.circular(20),color: colorScheme.backdropBase,- borderRadius: const BorderRadius.all(Radius.circular(20)),),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,+ padding: const EdgeInsets.all(12),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisAlignment: MainAxisAlignment.center,children: [- collectionRowWidget,- Flexible(- flex: 1,- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 200),- switchInCurve: Curves.easeOut,- switchOutCurve: Curves.easeIn,- child: isSelected- ? IconButtonWidget(- key: const ValueKey("selected"),- icon: Icons.check_circle_rounded,- iconButtonType: IconButtonType.secondary,- iconColor: colorScheme.primary700,- )- : PopupMenuButton<String>(- onSelected: (value) =>- _handleMenuAction(context, value),- child: Padding(- padding: const EdgeInsets.all(12.0),- child: HugeIcon(- icon: HugeIcons.strokeRoundedMoreVertical,- color: getEnteColorScheme(context).iconColor,- ),- ),- itemBuilder: (BuildContext context) {- return _buildPopupMenuItems(context);- },- ),+ Container(+ height: 40,+ width: 40,+ decoration: BoxDecoration(+ color: colorScheme.backgroundBase,+ borderRadius: BorderRadius.circular(12),),+ padding: const EdgeInsets.all(8.0),+ child: collection.type == CollectionType.favorites+ ? HugeIcon(+ icon: HugeIcons.strokeRoundedStar,+ color: colorScheme.primary700,+ )+ : HugeIcon(+ icon: HugeIcons.strokeRoundedWallet05,+ color: colorScheme.iconColor,+ ),+ ),+ const SizedBox(height: 12),+ Text(+ collectionName,+ style: textTheme.bodyBold,+ textAlign: TextAlign.left,+ overflow: TextOverflow.ellipsis,+ maxLines: 1,+ ),+ const SizedBox(height: 4),+ FutureBuilder<int>(+ future: CollectionService.instance.getFileCount(collection),+ builder: (context, snapshot) {+ final fileCount = snapshot.data ?? 0;+ return Text(+ context.l10n.items(fileCount),+ style: textTheme.small.copyWith(+ color: colorScheme.textMuted,+ ),+ textAlign: TextAlign.left,+ );+ },),],),@@ -168,113 +112,4 @@ class CollectionRowWidget extends StatelessWidget {),);}-- List<PopupMenuItem<String>> _buildPopupMenuItems(BuildContext context) {- final collectionViewType =- getCollectionViewType(collection, Configuration.instance.getUserID()!);- if (overflowActions != null && overflowActions!.isNotEmpty) {- return overflowActions!- .map(- (action) => PopupMenuItem<String>(- value: action.id,- child: Row(- children: [- Icon(action.icon, size: 16),- const SizedBox(width: 8),- Text(action.label),- ],- ),- ),- )- .toList();- } else {- return [- if (collectionViewType == CollectionViewType.ownedCollection ||- collectionViewType == CollectionViewType.hiddenOwnedCollection ||- collectionViewType == CollectionViewType.quickLink)- PopupMenuItem<String>(- value: 'edit',- child: Row(- children: [- const Icon(Icons.edit, size: 16),- const SizedBox(width: 8),- Text(context.l10n.edit),- ],- ),- ),- if (collectionViewType == CollectionViewType.ownedCollection ||- collectionViewType == CollectionViewType.hiddenOwnedCollection ||- collectionViewType == CollectionViewType.quickLink)- PopupMenuItem<String>(- value: 'delete',- child: Row(- children: [- const Icon(Icons.delete, size: 16),- const SizedBox(width: 8),- Text(context.l10n.delete),- ],- ),- ),- if (collectionViewType == CollectionViewType.sharedCollection)- PopupMenuItem<String>(- value: 'leave_collection',- child: Row(- children: [- const Icon(Icons.logout),- const SizedBox(width: 12),- Text(context.l10n.leaveCollection),- ],- ),- ),- ];- }- }-- void _handleMenuAction(BuildContext context, String action) {- if (overflowActions != null && overflowActions!.isNotEmpty) {- final customAction = overflowActions!.firstWhere(- (a) => a.id == action,- orElse: () => throw StateError('Action not found'),- );- customAction.onTap(context, null, collection);- } else {- switch (action) {- case 'edit':- _editCollection(context);- break;- case 'delete':- _deleteCollection(context);- break;- case 'leave_collection':- _leaveCollection(context);- break;- }- }- }-- void _editCollection(BuildContext context) {- CollectionActions.editCollection(context, collection);- }-- void _deleteCollection(BuildContext context) {- CollectionActions.deleteCollection(context, collection);- }-- void _openCollection(BuildContext context) {- Navigator.of(context).push(- MaterialPageRoute(- builder: (context) => CollectionPage(collection: collection),- ),- );- }-- Future<void> _leaveCollection(BuildContext context) async {- await CollectionActions.leaveCollection(- context,- collection,- onSuccess: () {- Bus.instance.fire(CollectionsUpdatedEvent());- },- );- }}diff --git a/mobile/apps/locker/lib/ui/components/file_list_widget.dart b/mobile/apps/locker/lib/ui/components/file_list_widget.dartnew file mode 100644index 0000000000..5cc260dc08--- /dev/null+++ b/mobile/apps/locker/lib/ui/components/file_list_widget.dart@@ -0,0 +1,577 @@+import "dart:io";++import "package:ente_ui/components/buttons/button_widget.dart";+import "package:ente_ui/components/buttons/icon_button_widget.dart";+import "package:ente_ui/components/buttons/models/button_type.dart";+import "package:ente_ui/theme/ente_theme.dart";+import "package:ente_ui/utils/dialog_util.dart";+import "package:flutter/material.dart";+import "package:hugeicons/hugeicons.dart";+import "package:locker/l10n/l10n.dart";+import "package:locker/models/info/info_item.dart";+import "package:locker/models/selected_files.dart";+import "package:locker/services/collections/collections_service.dart";+import "package:locker/services/collections/models/collection.dart";+import "package:locker/services/configuration.dart";+import "package:locker/services/files/download/file_downloader.dart";+import "package:locker/services/files/links/links_service.dart";+import "package:locker/services/files/sync/metadata_updater_service.dart";+import "package:locker/services/files/sync/models/file.dart";+import "package:locker/services/info_file_service.dart";+import "package:locker/ui/components/file_edit_dialog.dart";+import "package:locker/ui/components/item_list_view.dart";+import "package:locker/ui/components/share_link_dialog.dart";+import "package:locker/ui/pages/account_credentials_page.dart";+import "package:locker/ui/pages/base_info_page.dart";+import "package:locker/ui/pages/emergency_contact_page.dart";+import "package:locker/ui/pages/personal_note_page.dart";+import "package:locker/ui/pages/physical_records_page.dart";+import "package:locker/utils/file_icon_utils.dart";+import "package:locker/utils/info_item_utils.dart";+import "package:locker/utils/snack_bar_utils.dart";+import "package:open_file/open_file.dart";++class FileListWidget extends StatelessWidget {+ final EnteFile file;+ final List<Collection> collections;+ final List<OverflowMenuAction>? overflowActions;+ final bool isLastItem;+ final SelectedFiles? selectedFiles;+ final void Function(EnteFile)? onTapCallback;+ final void Function(EnteFile)? onLongPressCallback;++ const FileListWidget({+ super.key,+ required this.file,+ required this.collections,+ this.overflowActions,+ this.isLastItem = false,+ this.selectedFiles,+ this.onTapCallback,+ this.onLongPressCallback,+ });++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);++ final fileRowWidget = Flexible(+ flex: 6,+ child: Row(+ children: [+ SizedBox(+ height: 60,+ width: 60,+ child: _buildFileIcon(),+ ),+ const SizedBox(width: 12),+ Flexible(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ Text(+ file.displayName,+ overflow: TextOverflow.ellipsis,+ maxLines: 1,+ ),+ ],+ ),+ ),+ ],+ ),+ );++ return GestureDetector(+ onTap: () {+ if (onTapCallback != null) {+ onTapCallback!(file);+ } else {+ _openFile(context);+ }+ },+ onLongPress: () {+ if (onLongPressCallback != null) {+ onLongPressCallback!(file);+ } else {+ _openFile(context);+ }+ },+ behavior: HitTestBehavior.opaque,+ child: ListenableBuilder(+ listenable: selectedFiles ?? ValueNotifier(false),+ builder: (context, _) {+ final bool isSelected = selectedFiles?.isFileSelected(file) ?? false;+ return AnimatedContainer(+ duration: const Duration(milliseconds: 200),+ curve: Curves.easeOut,+ decoration: BoxDecoration(+ border: Border.all(+ color: isSelected+ ? colorScheme.primary700+ : colorScheme.backdropBase,+ width: 1.5,+ ),+ color: colorScheme.backdropBase,+ borderRadius: const BorderRadius.all(Radius.circular(20)),+ ),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ fileRowWidget,+ Flexible(+ flex: 1,+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 200),+ switchInCurve: Curves.easeOut,+ switchOutCurve: Curves.easeIn,+ child: isSelected+ ? IconButtonWidget(+ key: const ValueKey("selected"),+ icon: Icons.check_circle_rounded,+ iconButtonType: IconButtonType.secondary,+ iconColor: colorScheme.primary700,+ )+ : PopupMenuButton<String>(+ onSelected: (value) =>+ _handleMenuAction(context, value),+ child: Padding(+ padding: const EdgeInsets.all(12.0),+ child: HugeIcon(+ icon: HugeIcons.strokeRoundedMoreVertical,+ color: getEnteColorScheme(context).iconColor,+ ),+ ),+ itemBuilder: (BuildContext context) {+ return _buildPopupMenuItems(context);+ },+ ),+ ),+ ),+ ],+ ),+ );+ },+ ),+ );+ }++ List<PopupMenuItem<String>> _buildPopupMenuItems(BuildContext context) {+ if (overflowActions != null && overflowActions!.isNotEmpty) {+ return overflowActions!+ .map(+ (action) => PopupMenuItem<String>(+ value: action.id,+ child: Row(+ children: [+ const HugeIcon(+ icon: HugeIcons.strokeRoundedFile02,+ size: 16,+ ),+ const SizedBox(width: 8),+ Text(action.label),+ ],+ ),+ ),+ )+ .toList();+ } else {+ return [+ PopupMenuItem<String>(+ value: 'edit',+ child: Row(+ children: [+ const HugeIcon(+ icon: HugeIcons.strokeRoundedEdit02,+ size: 16,+ ),+ const SizedBox(width: 8),+ Text(context.l10n.edit),+ ],+ ),+ ),+ PopupMenuItem<String>(+ value: 'share_link',+ child: Row(+ children: [+ const HugeIcon(+ icon: HugeIcons.strokeRoundedShare03,+ size: 16,+ ),+ const SizedBox(width: 8),+ Text(context.l10n.share),+ ],+ ),+ ),+ PopupMenuItem<String>(+ value: 'delete',+ child: Row(+ children: [+ const HugeIcon(+ icon: HugeIcons.strokeRoundedDelete01,+ size: 16,+ ),+ const SizedBox(width: 8),+ Text(context.l10n.delete),+ ],+ ),+ ),+ ];+ }+ }++ void _handleMenuAction(BuildContext context, String action) {+ if (overflowActions != null && overflowActions!.isNotEmpty) {+ final customAction = overflowActions!.firstWhere(+ (a) => a.id == action,+ orElse: () => throw StateError('Action not found'),+ );+ customAction.onTap(context, file, null);+ } else {+ switch (action) {+ case 'edit':+ _showEditDialog(context);+ break;+ case 'share_link':+ _shareLink(context);+ break;+ case 'delete':+ _showDeleteConfirmationDialog(context);+ break;+ }+ }+ }++ Future<void> _shareLink(BuildContext context) async {+ final dialog = createProgressDialog(+ context,+ context.l10n.creatingShareLink,+ isDismissible: false,+ );++ try {+ await dialog.show();++ // Get or create the share link+ final shareableLink = await LinksService.instance.getOrCreateLink(file);++ await dialog.hide();++ // Show the link dialog with copy and delete options+ if (context.mounted) {+ await showShareLinkDialog(+ context,+ shareableLink.fullURL!,+ shareableLink.linkID,+ file,+ );+ }+ } catch (e) {+ await dialog.hide();++ if (context.mounted) {+ SnackBarUtils.showWarningSnackBar(+ context,+ '${context.l10n.failedToCreateShareLink}: ${e.toString()}',+ );+ }+ }+ }++ Future<void> _showDeleteConfirmationDialog(BuildContext context) async {+ final result = await showChoiceDialog(+ context,+ title: context.l10n.deleteFile,+ body: context.l10n.deleteFileConfirmation(file.displayName),+ firstButtonLabel: context.l10n.delete,+ secondButtonLabel: context.l10n.cancel,+ firstButtonType: ButtonType.critical,+ isCritical: true,+ );++ if (result?.action == ButtonAction.first && context.mounted) {+ await _deleteFile(context);+ }+ }++ Future<void> _deleteFile(BuildContext context) async {+ final dialog = createProgressDialog(+ context,+ context.l10n.deletingFile,+ isDismissible: false,+ );++ try {+ await dialog.show();++ final collections =+ await CollectionService.instance.getCollectionsForFile(file);+ if (collections.isNotEmpty) {+ await CollectionService.instance.trashFile(file, collections.first);+ }++ await dialog.hide();+ if (context.mounted) {+ SnackBarUtils.showInfoSnackBar(+ context,+ context.l10n.fileDeletedSuccessfully,+ );+ }+ } catch (e) {+ await dialog.hide();++ if (context.mounted) {+ SnackBarUtils.showWarningSnackBar(+ context,+ context.l10n.failedToDeleteFile(e.toString()),+ );+ }+ }+ }++ Future<void> _showEditDialog(BuildContext context) async {+ final allCollections = await CollectionService.instance.getCollections();+ allCollections.removeWhere(+ (c) => c.type == CollectionType.uncategorized,+ );++ final result = await showFileEditDialog(+ context,+ file: file,+ collections: allCollections,+ );++ if (result != null && context.mounted) {+ List<Collection> currentCollections;+ try {+ currentCollections =+ await CollectionService.instance.getCollectionsForFile(file);+ } catch (e) {+ currentCollections = <Collection>[];+ }++ final currentCollectionsSet = currentCollections.toSet();++ final newCollectionsSet = result.selectedCollections.toSet();++ final collectionsToAdd =+ newCollectionsSet.difference(currentCollectionsSet).toList();++ final collectionsToRemove =+ currentCollectionsSet.difference(newCollectionsSet).toList();++ final currentTitle = file.displayName;+ final currentCaption = file.caption ?? '';+ final hasMetadataChanged =+ result.title != currentTitle || result.caption != currentCaption;++ if (hasMetadataChanged || currentCollectionsSet != newCollectionsSet) {+ final dialog = createProgressDialog(+ context,+ context.l10n.pleaseWait,+ isDismissible: false,+ );+ await dialog.show();++ try {+ final List<Future<void>> apiCalls = [];+ for (final collection in collectionsToAdd) {+ apiCalls.add(+ CollectionService.instance.addToCollection(collection, file),+ );+ }+ await Future.wait(apiCalls);+ apiCalls.clear();++ for (final collection in collectionsToRemove) {+ apiCalls.add(+ CollectionService.instance+ .move(file, collection, newCollectionsSet.first),+ );+ }+ if (hasMetadataChanged) {+ apiCalls.add(+ MetadataUpdaterService.instance+ .editFileNameAndCaption(file, result.title, result.caption),+ );+ }+ await Future.wait(apiCalls);++ await dialog.hide();++ SnackBarUtils.showInfoSnackBar(+ context,+ context.l10n.fileUpdatedSuccessfully,+ );+ } catch (e) {+ await dialog.hide();++ SnackBarUtils.showWarningSnackBar(+ context,+ context.l10n.failedToUpdateFile(e.toString()),+ );+ }+ } else {+ SnackBarUtils.showWarningSnackBar(+ context,+ context.l10n.noChangesWereMade,+ );+ }+ }+ }++ Widget _buildFileIcon() {+ // Check if this is an info file+ if (InfoFileService.instance.isInfoFile(file)) {+ try {+ final infoItem = InfoFileService.instance.extractInfoFromFile(file);+ if (infoItem != null) {+ return InfoItemUtils.getInfoIcon(infoItem.type);+ }+ } catch (e) {+ // Fallback to default icon if extraction fails+ }+ }++ // For non-info files or if extraction fails, use the original logic+ return FileIconUtils.getFileIcon(file.displayName, showBackground: true);+ }++ Future<void> _openFile(BuildContext context) async {+ // Check if this is an info file+ if (InfoFileService.instance.isInfoFile(file)) {+ return _openInfoFile(context);+ }++ if (file.localPath != null) {+ final localFile = File(file.localPath!);+ if (await localFile.exists()) {+ await _launchFile(context, localFile, file.displayName);+ return;+ }+ }++ final String cachedFilePath =+ "${Configuration.instance.getCacheDirectory()}${file.displayName}";+ final File cachedFile = File(cachedFilePath);+ if (await cachedFile.exists()) {+ await _launchFile(context, cachedFile, file.displayName);+ return;+ }++ final dialog = createProgressDialog(+ context,+ context.l10n.downloading,+ isDismissible: false,+ );++ try {+ await dialog.show();+ final fileKey = await CollectionService.instance.getFileKey(file);+ final decryptedFile = await downloadAndDecrypt(+ file,+ fileKey,+ progressCallback: (downloaded, total) {+ if (total > 0 && downloaded >= 0) {+ final percentage =+ ((downloaded / total) * 100).clamp(0, 100).round();+ dialog.update(+ message: context.l10n.downloadingProgress(percentage),+ );+ } else {+ dialog.update(message: context.l10n.downloading);+ }+ },+ shouldUseCache: true,+ );++ await dialog.hide();++ if (decryptedFile != null) {+ await _launchFile(context, decryptedFile, file.displayName);+ } else {+ await showErrorDialog(+ context,+ context.l10n.downloadFailed,+ context.l10n.failedToDownloadOrDecrypt,+ );+ }+ } catch (e) {+ await dialog.hide();+ await showErrorDialog(+ context,+ context.l10n.errorOpeningFile,+ context.l10n.errorOpeningFileMessage(e.toString()),+ );+ }+ }++ Future<void> _openInfoFile(BuildContext context) async {+ try {+ final infoItem = InfoFileService.instance.extractInfoFromFile(file);+ if (infoItem == null) {+ await showErrorDialog(+ context,+ context.l10n.errorOpeningFile,+ 'Unable to extract information from this file',+ );+ return;+ }++ // Navigate to the appropriate page based on info type in view mode+ Widget page;+ switch (infoItem.type) {+ case InfoType.note:+ page = PersonalNotePage(+ mode: InfoPageMode.view,+ existingFile: file,+ );+ break;+ case InfoType.accountCredential:+ page = AccountCredentialsPage(+ mode: InfoPageMode.view,+ existingFile: file,+ );+ break;+ case InfoType.physicalRecord:+ page = PhysicalRecordsPage(+ mode: InfoPageMode.view,+ existingFile: file,+ );+ break;+ case InfoType.emergencyContact:+ page = EmergencyContactPage(+ mode: InfoPageMode.view,+ existingFile: file,+ );+ break;+ }++ await Navigator.of(context).push(+ MaterialPageRoute(builder: (context) => page),+ );+ } catch (e) {+ await showErrorDialog(+ context,+ context.l10n.errorOpeningFile,+ 'Failed to open info file: ${e.toString()}',+ );+ }+ }++ Future<void> _launchFile(+ BuildContext context,+ File file,+ String fileName,+ ) async {+ try {+ await OpenFile.open(file.path);+ } catch (e) {+ await showErrorDialog(+ context,+ context.l10n.errorOpeningFile,+ context.l10n.couldNotOpenFile(e.toString()),+ );+ }+ }+}diff --git a/mobile/apps/locker/lib/ui/components/file_row_widget.dart b/mobile/apps/locker/lib/ui/components/file_row_widget.dartindex c837816eef..214d75fb1d 100644--- a/mobile/apps/locker/lib/ui/components/file_row_widget.dart+++ b/mobile/apps/locker/lib/ui/components/file_row_widget.dart@@ -1,39 +1,14 @@-import "dart:io";--import "package:ente_ui/components/buttons/button_widget.dart";-import "package:ente_ui/components/buttons/icon_button_widget.dart";-import "package:ente_ui/components/buttons/models/button_type.dart";import "package:ente_ui/theme/ente_theme.dart";-import "package:ente_ui/utils/dialog_util.dart";import "package:flutter/material.dart";-import "package:hugeicons/hugeicons.dart";-import "package:locker/l10n/l10n.dart";-import "package:locker/models/info/info_item.dart";import "package:locker/models/selected_files.dart";-import "package:locker/services/collections/collections_service.dart";-import "package:locker/services/collections/models/collection.dart";-import "package:locker/services/configuration.dart";-import "package:locker/services/files/download/file_downloader.dart";-import "package:locker/services/files/links/links_service.dart";-import "package:locker/services/files/sync/metadata_updater_service.dart";import "package:locker/services/files/sync/models/file.dart";import "package:locker/services/info_file_service.dart";-import "package:locker/ui/components/file_edit_dialog.dart";import "package:locker/ui/components/item_list_view.dart";-import "package:locker/ui/components/share_link_dialog.dart";-import "package:locker/ui/pages/account_credentials_page.dart";-import "package:locker/ui/pages/base_info_page.dart";-import "package:locker/ui/pages/emergency_contact_page.dart";-import "package:locker/ui/pages/personal_note_page.dart";-import "package:locker/ui/pages/physical_records_page.dart";import "package:locker/utils/file_icon_utils.dart";import "package:locker/utils/info_item_utils.dart";-import "package:locker/utils/snack_bar_utils.dart";-import "package:open_file/open_file.dart";class FileRowWidget extends StatelessWidget {final EnteFile file;- final List<Collection> collections;final List<OverflowMenuAction>? overflowActions;final bool isLastItem;final SelectedFiles? selectedFiles;@@ -43,7 +18,6 @@ class FileRowWidget extends StatelessWidget {const FileRowWidget({super.key,required this.file,- required this.collections,this.overflowActions,this.isLastItem = false,this.selectedFiles,@@ -54,50 +28,19 @@ class FileRowWidget extends StatelessWidget {@overrideWidget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);-- final fileRowWidget = Flexible(- flex: 6,- child: Row(- children: [- SizedBox(- height: 60,- width: 60,- child: _buildFileIcon(),- ),- const SizedBox(width: 12),- Flexible(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisAlignment: MainAxisAlignment.center,- children: [- Text(- file.displayName,- overflow: TextOverflow.ellipsis,- maxLines: 1,- ),- ],- ),- ),- ],- ),- );+ final textTheme = getEnteTextTheme(context);return GestureDetector(onTap: () {if (onTapCallback != null) {onTapCallback!(file);- } else {- _openFile(context);}},onLongPress: () {if (onLongPressCallback != null) {onLongPressCallback!(file);- } else {- _openFile(context);}},- behavior: HitTestBehavior.opaque,child: ListenableBuilder(listenable: selectedFiles ?? ValueNotifier(false),builder: (context, _) {@@ -112,41 +55,26 @@ class FileRowWidget extends StatelessWidget {: colorScheme.backdropBase,width: 1.5,),+ borderRadius: BorderRadius.circular(20),color: colorScheme.backdropBase,- borderRadius: const BorderRadius.all(Radius.circular(20)),),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,+ padding: const EdgeInsets.all(12),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisAlignment: MainAxisAlignment.center,children: [- fileRowWidget,- Flexible(- flex: 1,- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 200),- switchInCurve: Curves.easeOut,- switchOutCurve: Curves.easeIn,- child: isSelected- ? IconButtonWidget(- key: const ValueKey("selected"),- icon: Icons.check_circle_rounded,- iconButtonType: IconButtonType.secondary,- iconColor: colorScheme.primary700,- )- : PopupMenuButton<String>(- onSelected: (value) =>- _handleMenuAction(context, value),- child: Padding(- padding: const EdgeInsets.all(12.0),- child: HugeIcon(- icon: HugeIcons.strokeRoundedMoreVertical,- color: getEnteColorScheme(context).iconColor,- ),- ),- itemBuilder: (BuildContext context) {- return _buildPopupMenuItems(context);- },- ),- ),+ SizedBox(+ height: 40,+ width: 40,+ child: _buildFileIcon(),+ ),+ const SizedBox(height: 12),+ Text(+ file.displayName,+ style: textTheme.bodyBold,+ textAlign: TextAlign.left,+ overflow: TextOverflow.ellipsis,+ maxLines: 2,),],),@@ -156,270 +84,6 @@ class FileRowWidget extends StatelessWidget {);}- List<PopupMenuItem<String>> _buildPopupMenuItems(BuildContext context) {- if (overflowActions != null && overflowActions!.isNotEmpty) {- return overflowActions!- .map(- (action) => PopupMenuItem<String>(- value: action.id,- child: Row(- children: [- const HugeIcon(- icon: HugeIcons.strokeRoundedFile02,- size: 16,- ),- const SizedBox(width: 8),- Text(action.label),- ],- ),- ),- )- .toList();- } else {- return [- PopupMenuItem<String>(- value: 'edit',- child: Row(- children: [- const HugeIcon(- icon: HugeIcons.strokeRoundedEdit02,- size: 16,- ),- const SizedBox(width: 8),- Text(context.l10n.edit),- ],- ),- ),- PopupMenuItem<String>(- value: 'share_link',- child: Row(- children: [- const HugeIcon(- icon: HugeIcons.strokeRoundedShare03,- size: 16,- ),- const SizedBox(width: 8),- Text(context.l10n.share),- ],- ),- ),- PopupMenuItem<String>(- value: 'delete',- child: Row(- children: [- const HugeIcon(- icon: HugeIcons.strokeRoundedDelete01,- size: 16,- ),- const SizedBox(width: 8),- Text(context.l10n.delete),- ],- ),- ),- ];- }- }-- void _handleMenuAction(BuildContext context, String action) {- if (overflowActions != null && overflowActions!.isNotEmpty) {- final customAction = overflowActions!.firstWhere(- (a) => a.id == action,- orElse: () => throw StateError('Action not found'),- );- customAction.onTap(context, file, null);- } else {- switch (action) {- case 'edit':- _showEditDialog(context);- break;- case 'share_link':- _shareLink(context);- break;- case 'delete':- _showDeleteConfirmationDialog(context);- break;- }- }- }-- Future<void> _shareLink(BuildContext context) async {- final dialog = createProgressDialog(- context,- context.l10n.creatingShareLink,- isDismissible: false,- );-- try {- await dialog.show();-- // Get or create the share link- final shareableLink = await LinksService.instance.getOrCreateLink(file);-- await dialog.hide();-- // Show the link dialog with copy and delete options- if (context.mounted) {- await showShareLinkDialog(- context,- shareableLink.fullURL!,- shareableLink.linkID,- file,- );- }- } catch (e) {- await dialog.hide();-- if (context.mounted) {- SnackBarUtils.showWarningSnackBar(- context,- '${context.l10n.failedToCreateShareLink}: ${e.toString()}',- );- }- }- }-- Future<void> _showDeleteConfirmationDialog(BuildContext context) async {- final result = await showChoiceDialog(- context,- title: context.l10n.deleteFile,- body: context.l10n.deleteFileConfirmation(file.displayName),- firstButtonLabel: context.l10n.delete,- secondButtonLabel: context.l10n.cancel,- firstButtonType: ButtonType.critical,- isCritical: true,- );-- if (result?.action == ButtonAction.first && context.mounted) {- await _deleteFile(context);- }- }-- Future<void> _deleteFile(BuildContext context) async {- final dialog = createProgressDialog(- context,- context.l10n.deletingFile,- isDismissible: false,- );-- try {- await dialog.show();-- final collections =- await CollectionService.instance.getCollectionsForFile(file);- if (collections.isNotEmpty) {- await CollectionService.instance.trashFile(file, collections.first);- }-- await dialog.hide();- if (context.mounted) {- SnackBarUtils.showInfoSnackBar(- context,- context.l10n.fileDeletedSuccessfully,- );- }- } catch (e) {- await dialog.hide();-- if (context.mounted) {- SnackBarUtils.showWarningSnackBar(- context,- context.l10n.failedToDeleteFile(e.toString()),- );- }- }- }-- Future<void> _showEditDialog(BuildContext context) async {- final allCollections = await CollectionService.instance.getCollections();- allCollections.removeWhere(- (c) => c.type == CollectionType.uncategorized,- );-- final result = await showFileEditDialog(- context,- file: file,- collections: allCollections,- );-- if (result != null && context.mounted) {- List<Collection> currentCollections;- try {- currentCollections =- await CollectionService.instance.getCollectionsForFile(file);- } catch (e) {- currentCollections = <Collection>[];- }-- final currentCollectionsSet = currentCollections.toSet();-- final newCollectionsSet = result.selectedCollections.toSet();-- final collectionsToAdd =- newCollectionsSet.difference(currentCollectionsSet).toList();-- final collectionsToRemove =- currentCollectionsSet.difference(newCollectionsSet).toList();-- final currentTitle = file.displayName;- final currentCaption = file.caption ?? '';- final hasMetadataChanged =- result.title != currentTitle || result.caption != currentCaption;-- if (hasMetadataChanged || currentCollectionsSet != newCollectionsSet) {- final dialog = createProgressDialog(- context,- context.l10n.pleaseWait,- isDismissible: false,- );- await dialog.show();-- try {- final List<Future<void>> apiCalls = [];- for (final collection in collectionsToAdd) {- apiCalls.add(- CollectionService.instance.addToCollection(collection, file),- );- }- await Future.wait(apiCalls);- apiCalls.clear();-- for (final collection in collectionsToRemove) {- apiCalls.add(- CollectionService.instance- .move(file, collection, newCollectionsSet.first),- );- }- if (hasMetadataChanged) {- apiCalls.add(- MetadataUpdaterService.instance- .editFileNameAndCaption(file, result.title, result.caption),- );- }- await Future.wait(apiCalls);-- await dialog.hide();-- SnackBarUtils.showInfoSnackBar(- context,- context.l10n.fileUpdatedSuccessfully,- );- } catch (e) {- await dialog.hide();-- SnackBarUtils.showWarningSnackBar(- context,- context.l10n.failedToUpdateFile(e.toString()),- );- }- } else {- SnackBarUtils.showWarningSnackBar(- context,- context.l10n.noChangesWereMade,- );- }- }- }-Widget _buildFileIcon() {// Check if this is an info fileif (InfoFileService.instance.isInfoFile(file)) {@@ -436,142 +100,4 @@ class FileRowWidget extends StatelessWidget {// For non-info files or if extraction fails, use the original logicreturn FileIconUtils.getFileIcon(file.displayName, showBackground: true);}-- Future<void> _openFile(BuildContext context) async {- // Check if this is an info file- if (InfoFileService.instance.isInfoFile(file)) {- return _openInfoFile(context);- }-- if (file.localPath != null) {- final localFile = File(file.localPath!);- if (await localFile.exists()) {- await _launchFile(context, localFile, file.displayName);- return;- }- }-- final String cachedFilePath =- "${Configuration.instance.getCacheDirectory()}${file.displayName}";- final File cachedFile = File(cachedFilePath);- if (await cachedFile.exists()) {- await _launchFile(context, cachedFile, file.displayName);- return;- }-- final dialog = createProgressDialog(- context,- context.l10n.downloading,- isDismissible: false,- );-- try {- await dialog.show();- final fileKey = await CollectionService.instance.getFileKey(file);- final decryptedFile = await downloadAndDecrypt(- file,- fileKey,- progressCallback: (downloaded, total) {- if (total > 0 && downloaded >= 0) {- final percentage =- ((downloaded / total) * 100).clamp(0, 100).round();- dialog.update(- message: context.l10n.downloadingProgress(percentage),- );- } else {- dialog.update(message: context.l10n.downloading);- }- },- shouldUseCache: true,- );-- await dialog.hide();-- if (decryptedFile != null) {- await _launchFile(context, decryptedFile, file.displayName);- } else {- await showErrorDialog(- context,- context.l10n.downloadFailed,- context.l10n.failedToDownloadOrDecrypt,- );- }- } catch (e) {- await dialog.hide();- await showErrorDialog(- context,- context.l10n.errorOpeningFile,- context.l10n.errorOpeningFileMessage(e.toString()),- );- }- }-- Future<void> _openInfoFile(BuildContext context) async {- try {- final infoItem = InfoFileService.instance.extractInfoFromFile(file);- if (infoItem == null) {- await showErrorDialog(- context,- context.l10n.errorOpeningFile,- 'Unable to extract information from this file',- );- return;- }-- // Navigate to the appropriate page based on info type in view mode- Widget page;- switch (infoItem.type) {- case InfoType.note:- page = PersonalNotePage(- mode: InfoPageMode.view,- existingFile: file,- );- break;- case InfoType.accountCredential:- page = AccountCredentialsPage(- mode: InfoPageMode.view,- existingFile: file,- );- break;- case InfoType.physicalRecord:- page = PhysicalRecordsPage(- mode: InfoPageMode.view,- existingFile: file,- );- break;- case InfoType.emergencyContact:- page = EmergencyContactPage(- mode: InfoPageMode.view,- existingFile: file,- );- break;- }-- await Navigator.of(context).push(- MaterialPageRoute(builder: (context) => page),- );- } catch (e) {- await showErrorDialog(- context,- context.l10n.errorOpeningFile,- 'Failed to open info file: ${e.toString()}',- );- }- }-- Future<void> _launchFile(- BuildContext context,- File file,- String fileName,- ) async {- try {- await OpenFile.open(file.path);- } catch (e) {- await showErrorDialog(- context,- context.l10n.errorOpeningFile,- context.l10n.couldNotOpenFile(e.toString()),- );- }- }}diff --git a/mobile/apps/locker/lib/ui/components/item_list_view.dart b/mobile/apps/locker/lib/ui/components/item_list_view.dartindex 1120730eb3..883441cbd4 100644--- a/mobile/apps/locker/lib/ui/components/item_list_view.dart+++ b/mobile/apps/locker/lib/ui/components/item_list_view.dart@@ -9,7 +9,9 @@ import 'package:locker/models/selected_files.dart';import 'package:locker/services/collections/models/collection.dart';import 'package:locker/services/files/sync/models/file.dart';import 'package:locker/services/info_file_service.dart';+import "package:locker/ui/components/collection_list_widget.dart";import "package:locker/ui/components/collection_row_widget.dart";+import "package:locker/ui/components/file_list_widget.dart";import "package:locker/ui/components/file_row_widget.dart";import 'package:locker/ui/pages/collection_page.dart';import 'package:locker/utils/collection_sort_util.dart';@@ -32,6 +34,11 @@ class OverflowMenuAction {});}+enum ItemViewType {+ listView,+ gridView,+}+class ItemListView extends StatefulWidget {final List<EnteFile> files;final List<Collection> collections;@@ -40,6 +47,7 @@ class ItemListView extends StatefulWidget {final List<OverflowMenuAction>? collectionOverflowActions;final SelectedCollections? selectedCollections;final SelectedFiles? selectedFiles;+ final ItemViewType viewType;const ItemListView({super.key,@@ -50,6 +58,7 @@ class ItemListView extends StatefulWidget {this.collectionOverflowActions,this.selectedCollections,this.selectedFiles,+ this.viewType = ItemViewType.listView,});@override@@ -108,6 +117,14 @@ class _ItemListViewState extends State<ItemListView> {return _buildDefaultEmptyState(context);}+ if (widget.viewType == ItemViewType.gridView) {+ return _buildGridView(context);+ }++ return _buildListView(context);+ }++ Widget _buildListView(BuildContext context) {return Column(mainAxisSize: MainAxisSize.min,children: [@@ -140,6 +157,7 @@ class _ItemListViewState extends State<ItemListView> {isLastItem: isLastItem,selectedCollections: widget.selectedCollections,selectedFiles: widget.selectedFiles,+ viewType: widget.viewType,onCollectionTap: (c) {isAnyCollectionSelected? _toggleCollectionSelection(c)@@ -167,6 +185,7 @@ class _ItemListViewState extends State<ItemListView> {isLastItem: isLastItem,selectedCollections: widget.selectedCollections,selectedFiles: widget.selectedFiles,+ viewType: widget.viewType,onFileTap: isAnyFileSelected? (file) {_toggleFileSelection(file);@@ -189,6 +208,7 @@ class _ItemListViewState extends State<ItemListView> {isLastItem: isLastItem,selectedCollections: widget.selectedCollections,selectedFiles: widget.selectedFiles,+ viewType: widget.viewType,);}},@@ -197,6 +217,97 @@ class _ItemListViewState extends State<ItemListView> {);}+ Widget _buildGridView(BuildContext context) {+ return GridView.builder(+ shrinkWrap: true,+ physics: const NeverScrollableScrollPhysics(),+ gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(+ crossAxisCount: 2,+ crossAxisSpacing: 12,+ mainAxisSpacing: 12,+ childAspectRatio: 1.3,+ ),+ itemCount: _sortedItems.length,+ itemBuilder: (context, index) {+ final item = _sortedItems[index];+ final isLastItem = index == _sortedItems.length - 1;++ final hasCollectionSelection = widget.selectedCollections != null;+ final hasFileSelection = widget.selectedFiles != null;++ if (hasCollectionSelection && item.isCollection) {+ return ListenableBuilder(+ listenable: widget.selectedCollections!,+ builder: (context, child) {+ final isAnyCollectionSelected =+ widget.selectedCollections?.hasSelections ?? false;++ return ListItemWidget(+ item: item,+ collections: widget.collections,+ fileOverflowActions: widget.fileOverflowActions,+ collectionOverflowActions: widget.collectionOverflowActions,+ isLastItem: isLastItem,+ selectedCollections: widget.selectedCollections,+ selectedFiles: widget.selectedFiles,+ viewType: widget.viewType,+ onCollectionTap: (c) {+ isAnyCollectionSelected+ ? _toggleCollectionSelection(c)+ : _navigateToCollectionPage(c);+ },+ onCollectionLongPress: (c) {+ isAnyCollectionSelected+ ? _navigateToCollectionPage(c)+ : _toggleCollectionSelection(c);+ },+ );+ },+ );+ } else if (hasFileSelection && !item.isCollection) {+ return ListenableBuilder(+ listenable: widget.selectedFiles!,+ builder: (context, child) {+ final isAnyFileSelected =+ widget.selectedFiles?.hasSelections ?? false;+ return ListItemWidget(+ item: item,+ collections: widget.collections,+ fileOverflowActions: widget.fileOverflowActions,+ collectionOverflowActions: widget.collectionOverflowActions,+ isLastItem: isLastItem,+ selectedCollections: widget.selectedCollections,+ selectedFiles: widget.selectedFiles,+ viewType: widget.viewType,+ onFileTap: isAnyFileSelected+ ? (file) {+ _toggleFileSelection(file);+ }+ : null,+ onFileLongPress: isAnyFileSelected+ ? null+ : (file) {+ _toggleFileSelection(file);+ },+ );+ },+ );+ } else {+ return ListItemWidget(+ item: item,+ collections: widget.collections,+ fileOverflowActions: widget.fileOverflowActions,+ collectionOverflowActions: widget.collectionOverflowActions,+ isLastItem: isLastItem,+ selectedCollections: widget.selectedCollections,+ selectedFiles: widget.selectedFiles,+ viewType: widget.viewType,+ );+ }+ },+ );+ }+Widget _buildDefaultEmptyState(BuildContext context) {return Center(child: Padding(@@ -305,6 +416,7 @@ class ListItemWidget extends StatelessWidget {final Function(Collection)? onCollectionLongPress;final Function(EnteFile)? onFileTap;final Function(EnteFile)? onFileLongPress;+ final ItemViewType viewType;const ListItemWidget({super.key,@@ -320,30 +432,53 @@ class ListItemWidget extends StatelessWidget {this.onCollectionLongPress,this.onFileTap,this.onFileLongPress,+ this.viewType = ItemViewType.listView,});@overrideWidget build(BuildContext context) {if (item.isCollection && item.collection != null) {final collection = item.collection!;- return CollectionRowWidget(- collection: collection,- overflowActions: collectionOverflowActions,- isLastItem: isLastItem,- selectedCollections: selectedCollections,- onTapCallback: onCollectionTap,- onLongPressCallback: onCollectionLongPress,- );+ if (viewType == ItemViewType.gridView) {+ return CollectionRowWidget(+ collection: collection,+ overflowActions: collectionOverflowActions,+ isLastItem: isLastItem,+ selectedCollections: selectedCollections,+ onTapCallback: onCollectionTap,+ onLongPressCallback: onCollectionLongPress,+ );+ } else {+ return CollectionListWidget(+ collection: collection,+ overflowActions: collectionOverflowActions,+ isLastItem: isLastItem,+ selectedCollections: selectedCollections,+ onTapCallback: onCollectionTap,+ onLongPressCallback: onCollectionLongPress,+ );+ }} else if (!item.isCollection && item.file != null) {- return FileRowWidget(- file: item.file!,- collections: collections,- overflowActions: fileOverflowActions,- isLastItem: isLastItem,- selectedFiles: selectedFiles,- onTapCallback: onFileTap,- onLongPressCallback: onFileLongPress,- );+ if (viewType == ItemViewType.gridView) {+ return FileRowWidget(+ file: item.file!,+ overflowActions: fileOverflowActions,+ isLastItem: isLastItem,+ selectedFiles: selectedFiles,+ onTapCallback: onFileTap,+ onLongPressCallback: onFileLongPress,+ );+ } else {+ return FileListWidget(+ file: item.file!,+ collections: collections,+ overflowActions: fileOverflowActions,+ isLastItem: isLastItem,+ selectedFiles: selectedFiles,+ onTapCallback: onFileTap,+ onLongPressCallback: onFileLongPress,+ );+ }} else {return Container(padding: const EdgeInsets.all(16),diff --git a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart b/mobile/apps/locker/lib/ui/components/recents_section_widget.dartindex 5bf9392367..c09d30c1e9 100644--- a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart+++ b/mobile/apps/locker/lib/ui/components/recents_section_widget.dart@@ -40,6 +40,7 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {final Map<int, List<Collection>> _fileCollectionsCache = {};final Map<int, Future<List<Collection>>> _fileCollectionsRequests = {};final Map<int, InfoType?> _fileInfoTypeCache = {};+ ItemViewType _viewType = ItemViewType.listView;@overridevoid initState() {@@ -90,21 +91,34 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {}Widget _buildRecentsHeader() {+ final colorScheme = getEnteColorScheme(context);return SectionOptions(onTap: () {},body: context.l10n.items(_displayedFiles.length),SectionTitle(title: context.l10n.recents),- trailingWidget: Container(- height: 48,- width: 48,- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(12),- color: getEnteColorScheme(context).backdropBase,- ),- padding: const EdgeInsets.all(12),- child: HugeIcon(- icon: HugeIcons.strokeRoundedGridView,- color: getEnteColorScheme(context).iconColor,+ trailingWidget: GestureDetector(+ onTap: () {+ HapticFeedback.lightImpact();+ setState(() {+ _viewType = _viewType == ItemViewType.listView+ ? ItemViewType.gridView+ : ItemViewType.listView;+ });+ },+ child: Container(+ height: 48,+ width: 48,+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(12),+ color: colorScheme.backdropBase,+ ),+ padding: const EdgeInsets.all(12),+ child: HugeIcon(+ icon: _viewType == ItemViewType.listView+ ? HugeIcons.strokeRoundedGridView+ : HugeIcons.strokeRoundedMenu01,+ color: colorScheme.iconColor,+ ),),),);@@ -168,6 +182,7 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {return ItemListView(files: _displayedFiles,+ viewType: _viewType,);}