Skip to content

armgit / ente

Public Imported from GitHub
0

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

UI fixes

AmanRajSinghMourya40f24f93bc43
diff --git a/mobile/apps/locker/lib/models/ui_section_type.dart b/mobile/apps/locker/lib/models/ui_section_type.dart
new file mode 100644
index 0000000000..81b4b27ec1
--- /dev/null
+++ b/mobile/apps/locker/lib/models/ui_section_type.dart
@@ -0,0 +1,5 @@
+enum UISectionType {
+ incomingCollections,
+ outgoingCollections,
+ homeCollections,
+}
diff --git a/mobile/apps/locker/lib/services/files/download/service_locator.dart b/mobile/apps/locker/lib/services/files/download/service_locator.dart
index 5de5f31b4e..dc994b29a6 100644
--- a/mobile/apps/locker/lib/services/files/download/service_locator.dart
+++ b/mobile/apps/locker/lib/services/files/download/service_locator.dart
@@ -1,5 +1,6 @@
import 'package:dio/dio.dart';
import 'package:locker/services/files/download/manager.dart';
+import "package:locker/utils/local_settings.dart";
import 'package:package_info_plus/package_info_plus.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -34,3 +35,9 @@ DownloadManager get downloadManager {
);
return _downloadManager!;
}
+
+LocalSettings? _localSettings;
+LocalSettings get localSettings {
+ _localSettings ??= LocalSettings(ServiceLocator.instance.prefs);
+ return _localSettings!;
+}
diff --git a/mobile/apps/locker/lib/services/trash/trash_service.dart b/mobile/apps/locker/lib/services/trash/trash_service.dart
index a6ef50f6b9..372e020b50 100644
--- a/mobile/apps/locker/lib/services/trash/trash_service.dart
+++ b/mobile/apps/locker/lib/services/trash/trash_service.dart
@@ -7,6 +7,7 @@ import 'package:ente_crypto_dart/ente_crypto_dart.dart';
import "package:ente_events/event_bus.dart";
import "package:ente_events/models/signed_in_event.dart";
import 'package:ente_network/network.dart';
+import "package:locker/events/collections_updated_event.dart";
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/collections/models/collection.dart';
import 'package:locker/services/collections/models/collection_file_item.dart';
@@ -255,6 +256,7 @@ class TrashService {
data: params,
);
await _trashDB.delete(files.map((e) => e.uploadedFileID!).toList());
+ Bus.instance.fire(CollectionsUpdatedEvent("file_restore"));
// Force reload home gallery to pull in the restored files
} catch (e, s) {
_logger.severe("failed to restore files", e, s);
diff --git a/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart
index 22dcddaeaa..0055b7fdc3 100644
--- a/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart
@@ -63,14 +63,11 @@ class CollectionPopupMenuWidget extends StatelessWidget {
padding: EdgeInsets.zero,
height: 0,
child: MenuItemWidget(
- icon: Icon(
- action.icon,
- color: colorScheme.textBase,
- size: 20,
- ),
+ icon: action.icon,
label: action.label,
isFirst: i == 0,
isLast: i == overflowActions!.length - 1,
+ isWarning: action.isWarning,
),
),
);
@@ -120,7 +117,7 @@ class CollectionPopupMenuWidget extends StatelessWidget {
label: context.l10n.delete,
isFirst: false,
isLast: true,
- isDelete: true,
+ isWarning: true,
),
),
);
@@ -141,7 +138,7 @@ class CollectionPopupMenuWidget extends StatelessWidget {
label: context.l10n.leaveCollection,
isFirst: true,
isLast: true,
- isDelete: true,
+ isWarning: true,
),
),
);
diff --git a/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart b/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart
index b12396b042..ea18243eaf 100644
--- a/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart
+++ b/mobile/apps/locker/lib/ui/components/delete_confirmation_dialog.dart
@@ -10,6 +10,7 @@ Future<ButtonResult?> showDeleteConfirmationDialog(
required String body,
required String deleteButtonLabel,
required String assetPath,
+ Widget? icon,
}) {
return showModalBottomSheet<ButtonResult>(
context: context,
@@ -21,6 +22,7 @@ Future<ButtonResult?> showDeleteConfirmationDialog(
body: body,
deleteButtonLabel: deleteButtonLabel,
assetPath: assetPath,
+ icon: icon,
);
},
);
@@ -31,12 +33,14 @@ class _DeleteConfirmationBottomSheet extends StatelessWidget {
final String body;
final String deleteButtonLabel;
final String assetPath;
+ final Widget? icon;
const _DeleteConfirmationBottomSheet({
required this.title,
required this.body,
required this.deleteButtonLabel,
required this.assetPath,
+ this.icon,
});
@override
@@ -113,12 +117,13 @@ class _DeleteConfirmationBottomSheet extends StatelessWidget {
),
elevation: 0,
),
- icon: const HugeIcon(
- icon: HugeIcons.strokeRoundedFileUpload,
- color: Colors.white,
- size: 20,
- strokeWidth: 1.9,
- ),
+ icon: icon ??
+ const HugeIcon(
+ icon: HugeIcons.strokeRoundedFileUpload,
+ color: Colors.white,
+ size: 20,
+ strokeWidth: 1.9,
+ ),
label: Text(
deleteButtonLabel,
style: textTheme.bodyBold.copyWith(
diff --git a/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart b/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart
index e36c69ca12..91df9e2704 100644
--- a/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart
@@ -69,14 +69,11 @@ class FilePopupMenuWidget extends StatelessWidget {
padding: EdgeInsets.zero,
height: 0,
child: MenuItemWidget(
- icon: Icon(
- action.icon,
- color: colorScheme.textBase,
- size: 20,
- ),
+ icon: action.icon,
label: action.label,
isFirst: i == 0,
isLast: i == overflowActions!.length - 1,
+ isWarning: action.isWarning,
),
),
);
@@ -128,7 +125,7 @@ class FilePopupMenuWidget extends StatelessWidget {
label: context.l10n.delete,
isFirst: false,
isLast: true,
- isDelete: true,
+ isWarning: true,
),
),
];
diff --git a/mobile/apps/locker/lib/ui/components/file_restore_dialog.dart b/mobile/apps/locker/lib/ui/components/file_restore_dialog.dart
new file mode 100644
index 0000000000..068c5cfe55
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/components/file_restore_dialog.dart
@@ -0,0 +1,188 @@
+import "package:ente_ui/components/buttons/gradient_button.dart";
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:flutter/material.dart';
+import 'package:locker/l10n/l10n.dart';
+import 'package:locker/services/collections/models/collection.dart';
+import 'package:locker/services/files/sync/models/file.dart';
+import 'package:locker/ui/components/collection_selection_widget.dart';
+import 'package:locker/utils/snack_bar_utils.dart';
+
+class FileRestoreDialogResult {
+ final List<Collection> selectedCollections;
+
+ const FileRestoreDialogResult({
+ required this.selectedCollections,
+ });
+}
+
+class FileRestoreDialog extends StatefulWidget {
+ final EnteFile file;
+ final List<Collection> collections;
+
+ const FileRestoreDialog({
+ super.key,
+ required this.file,
+ required this.collections,
+ });
+
+ @override
+ State<FileRestoreDialog> createState() => _FileRestoreDialogState();
+}
+
+class _FileRestoreDialogState extends State<FileRestoreDialog> {
+ final Set<int> _selectedCollectionIds = <int>{};
+ late List<Collection> _availableCollections;
+
+ @override
+ void initState() {
+ super.initState();
+ _availableCollections = List.from(widget.collections);
+ if (_availableCollections.isNotEmpty) {
+ _selectedCollectionIds.add(_availableCollections.first.id);
+ }
+ }
+
+ void _toggleCollection(int collectionId) {
+ setState(() {
+ if (_selectedCollectionIds.contains(collectionId)) {
+ _selectedCollectionIds.remove(collectionId);
+ } else {
+ _selectedCollectionIds.add(collectionId);
+ }
+ });
+ }
+
+ void _onCollectionsUpdated(List<Collection> updatedCollections) {
+ setState(() {
+ _availableCollections = updatedCollections;
+ });
+ }
+
+ Future<void> _onCancel() async {
+ Navigator.of(context).pop();
+ }
+
+ Future<void> _onRestore() async {
+ final selectedCollections = _availableCollections
+ .where((c) => _selectedCollectionIds.contains(c.id))
+ .toList();
+
+ if (selectedCollections.isEmpty) {
+ SnackBarUtils.showWarningSnackBar(
+ context,
+ context.l10n.pleaseSelectAtLeastOneCollection,
+ );
+ return;
+ }
+
+ Navigator.of(context).pop(
+ FileRestoreDialogResult(selectedCollections: selectedCollections),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
+ return Dialog(
+ backgroundColor: colorScheme.backgroundBase,
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 360),
+ child: Container(
+ decoration: BoxDecoration(
+ color: colorScheme.backdropBase,
+ borderRadius: BorderRadius.circular(28),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withOpacity(0.08),
+ blurRadius: 24,
+ offset: const Offset(0, 12),
+ ),
+ ],
+ ),
+ padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ "Restore",
+ style: textTheme.largeBold,
+ ),
+ const SizedBox(height: 4),
+ Text(
+ widget.file.displayName,
+ style: textTheme.small.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
+ ),
+ ),
+ GestureDetector(
+ onTap: _onCancel,
+ child: Container(
+ height: 36,
+ width: 36,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: colorScheme.backgroundElevated,
+ ),
+ child: const Icon(
+ Icons.close_rounded,
+ size: 20,
+ ),
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 24),
+ CollectionSelectionWidget(
+ collections: _availableCollections,
+ selectedCollectionIds: _selectedCollectionIds,
+ onToggleCollection: _toggleCollection,
+ onCollectionsUpdated: _onCollectionsUpdated,
+ titleWidget: Text(
+ "Move to collection",
+ style: textTheme.largeBold,
+ ),
+ ),
+ const SizedBox(height: 28),
+ SizedBox(
+ width: double.infinity,
+ child: GradientButton(
+ onTap: _onRestore,
+ text: context.l10n.restore,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+Future<FileRestoreDialogResult?> showFileRestoreDialog(
+ BuildContext context, {
+ required EnteFile file,
+ required List<Collection> collections,
+}) {
+ return showDialog<FileRestoreDialogResult>(
+ context: context,
+ builder: (context) => FileRestoreDialog(
+ file: file,
+ collections: collections,
+ ),
+ );
+}
diff --git a/mobile/apps/locker/lib/ui/components/item_list_view.dart b/mobile/apps/locker/lib/ui/components/item_list_view.dart
index 4da5b3f9ce..fabe80a787 100644
--- a/mobile/apps/locker/lib/ui/components/item_list_view.dart
+++ b/mobile/apps/locker/lib/ui/components/item_list_view.dart
@@ -20,7 +20,8 @@ import 'package:locker/utils/collection_sort_util.dart';
class OverflowMenuAction {
final String id;
final String label;
- final IconData icon;
+ final Widget icon;
+ final bool isWarning;
final void Function(
BuildContext context,
EnteFile? file,
@@ -32,6 +33,7 @@ class OverflowMenuAction {
required this.label,
required this.icon,
required this.onTap,
+ this.isWarning = false,
});
}
diff --git a/mobile/apps/locker/lib/ui/components/menu_item_widget.dart b/mobile/apps/locker/lib/ui/components/menu_item_widget.dart
index f0a141ae32..d0dcf6f302 100644
--- a/mobile/apps/locker/lib/ui/components/menu_item_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/menu_item_widget.dart
@@ -6,7 +6,6 @@ class MenuItemWidget extends StatelessWidget {
final String label;
final bool isFirst;
final bool isLast;
- final bool isDelete;
final bool isWarning;
final VoidCallback? onTap;
@@ -16,7 +15,6 @@ class MenuItemWidget extends StatelessWidget {
required this.label,
this.isFirst = false,
this.isLast = false,
- this.isDelete = false,
this.isWarning = false,
this.onTap,
});
@@ -57,7 +55,7 @@ class MenuItemWidget extends StatelessWidget {
Expanded(
child: Text(
label,
- style: (isDelete || isWarning)
+ style: isWarning
? textTheme.body.copyWith(color: colorScheme.warning500)
: textTheme.body,
),
diff --git a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart b/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
index 8f6cc6148a..ec900dd9b4 100644
--- a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
@@ -10,8 +10,10 @@ import 'package:locker/models/info/info_item.dart';
import 'package:locker/models/item_view_type.dart';
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/collections/models/collection.dart';
+import "package:locker/services/files/download/service_locator.dart";
import 'package:locker/services/files/sync/models/file.dart';
import "package:locker/ui/collections/section_title.dart";
+import "package:locker/ui/components/empty_state_widget.dart";
import 'package:locker/ui/components/item_list_view.dart';
class RecentsSectionWidget extends StatefulWidget {
@@ -41,7 +43,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;
+ ItemViewType? _viewType;
@override
void initState() {
@@ -49,6 +51,7 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
_originalCollectionOrder = List.from(widget.collections);
_availableCollections = List.from(widget.collections);
_availableInfoTypes = _computeAvailableInfoTypes(widget.recentFiles);
+ _viewType = localSettings.itemViewType();
}
@override
@@ -99,6 +102,11 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
trailingWidget: GestureDetector(
onTap: () {
HapticFeedback.lightImpact();
+ localSettings.setItemViewType(
+ _viewType == ItemViewType.listView
+ ? ItemViewType.gridView
+ : ItemViewType.listView,
+ );
setState(() {
_viewType = _viewType == ItemViewType.listView
? ItemViewType.gridView
@@ -157,32 +165,16 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
Widget _buildRecentsTable() {
if (_displayedFiles.isEmpty) {
- return Container(
- padding: const EdgeInsets.symmetric(vertical: 40),
- child: Center(
- child: Column(
- children: [
- Icon(
- Icons.folder_off,
- size: 48,
- color: Colors.grey[400],
- ),
- const SizedBox(height: 16),
- Text(
- 'No items match the selected filters',
- style: getEnteTextTheme(context).body.copyWith(
- color: Colors.grey[600],
- ),
- ),
- ],
- ),
- ),
+ return const EmptyStateWidget(
+ assetPath: "assets/empty_state.png",
+ title: "Oops",
+ subtitle: "No items match the selected filters",
);
}
return ItemListView(
files: _displayedFiles,
- viewType: _viewType,
+ viewType: _viewType ?? ItemViewType.listView,
);
}
@@ -732,9 +724,7 @@ class _FilterChip extends StatelessWidget {
Text(
label,
style: textTheme.small.copyWith(
- color: isSelected
- ? colorScheme.backgroundBase
- : colorScheme.textBase,
+ color: isSelected ? colorScheme.backgroundBase : Colors.white,
),
),
AnimatedSwitcher(
diff --git a/mobile/apps/locker/lib/ui/pages/all_collections_page.dart b/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
index c570f9bce6..15e7a9cee7 100644
--- a/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
@@ -7,6 +7,7 @@ import 'package:flutter/material.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/models/ui_section_type.dart';
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/collections/models/collection.dart';
import 'package:locker/services/trash/trash_service.dart';
@@ -18,12 +19,6 @@ import "package:locker/ui/viewer/actions/collection_selection_overlay_bar.dart";
import 'package:locker/utils/collection_sort_util.dart';
import 'package:logging/logging.dart';
-enum UISectionType {
- incomingCollections,
- outgoingCollections,
- homeCollections,
-}
-
class AllCollectionsPage extends StatefulWidget {
final UISectionType viewType;
final SelectedCollections? selectedCollections;
@@ -160,6 +155,7 @@ class _AllCollectionsPageState extends State<AllCollectionsPage> {
CollectionSelectionOverlayBar(
collection: _sortedCollections,
selectedCollections: widget.selectedCollections!,
+ viewType: widget.viewType,
),
],
),
diff --git a/mobile/apps/locker/lib/ui/pages/collection_page.dart b/mobile/apps/locker/lib/ui/pages/collection_page.dart
index 3e7b520d5d..afdf2f3b67 100644
--- a/mobile/apps/locker/lib/ui/pages/collection_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/collection_page.dart
@@ -319,7 +319,7 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>
color: colorScheme.warning500,
size: 20,
),
- isDelete: true,
+ isWarning: true,
label: context.l10n.delete,
isFirst: itemIndex == 0,
isLast: itemIndex == totalItems - 1,
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index d763df9beb..d7d99a8f68 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -14,6 +14,7 @@ import 'package:listen_sharing_intent/listen_sharing_intent.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/models/ui_section_type.dart';
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/collections/models/collection.dart';
import 'package:locker/services/files/sync/models/file.dart';
diff --git a/mobile/apps/locker/lib/ui/pages/trash_page.dart b/mobile/apps/locker/lib/ui/pages/trash_page.dart
index 5102027126..1175a3c935 100644
--- a/mobile/apps/locker/lib/ui/pages/trash_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/trash_page.dart
@@ -1,17 +1,19 @@
import 'package:ente_ui/components/buttons/button_widget.dart';
-import 'package:ente_ui/components/buttons/models/button_type.dart';
import "package:ente_ui/components/title_bar_title_widget.dart";
import "package:ente_ui/theme/colors.dart";
import 'package:ente_ui/theme/ente_theme.dart';
import "package:ente_ui/theme/text_style.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/services/collections/collections_service.dart';
import 'package:locker/services/collections/models/collection.dart';
import 'package:locker/services/files/sync/models/file.dart';
import 'package:locker/services/trash/models/trash_file.dart';
import 'package:locker/services/trash/trash_service.dart';
+import "package:locker/ui/components/delete_confirmation_dialog.dart";
+import 'package:locker/ui/components/file_restore_dialog.dart';
import 'package:locker/ui/components/item_list_view.dart';
import 'package:locker/utils/snack_bar_utils.dart';
@@ -39,11 +41,16 @@ class _TrashPageState extends State<TrashPage> {
}
List<OverflowMenuAction> _getFileOverflowActions() {
+ final colorScheme = getEnteColorScheme(context);
return [
OverflowMenuAction(
id: 'restore',
label: context.l10n.restore,
- icon: Icons.restore,
+ icon: Icon(
+ Icons.restore,
+ color: colorScheme.textBase,
+ size: 20,
+ ),
onTap: (context, file, collection) {
_restoreFile(context, file!);
},
@@ -51,10 +58,15 @@ class _TrashPageState extends State<TrashPage> {
OverflowMenuAction(
id: 'delete',
label: context.l10n.delete,
- icon: Icons.delete_forever,
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedDelete01,
+ color: colorScheme.warning500,
+ size: 20,
+ ),
onTap: (context, file, collection) {
_deleteFilePermanently(context, file!);
},
+ isWarning: true,
),
];
}
@@ -74,14 +86,18 @@ class _TrashPageState extends State<TrashPage> {
return;
}
- final selectedCollection = await _showCollectionPickerDialog(
+ final dialogResult = await showFileRestoreDialog(
context,
- availableCollections,
- file.displayName,
+ file: file,
+ collections: availableCollections,
);
- if (selectedCollection != null) {
- await _performRestore(context, file, selectedCollection);
+ if (dialogResult != null && dialogResult.selectedCollections.isNotEmpty) {
+ await _performRestore(
+ context,
+ file,
+ dialogResult.selectedCollections.first,
+ );
}
}
@@ -103,21 +119,6 @@ class _TrashPageState extends State<TrashPage> {
});
}
- Future<Collection?> _showCollectionPickerDialog(
- BuildContext context,
- List<Collection> collections,
- String fileName,
- ) async {
- return showDialog<Collection>(
- context: context,
- barrierColor: getEnteColorScheme(context).backdropBase,
- builder: (context) => _CollectionPickerDialog(
- collections: collections,
- fileName: fileName,
- ),
- );
- }
-
Future<void> _performRestore(
BuildContext context,
EnteFile file,
@@ -159,14 +160,12 @@ class _TrashPageState extends State<TrashPage> {
}
Future<void> _emptyTrash() async {
- final result = await showChoiceDialog(
+ final result = await showDeleteConfirmationDialog(
context,
title: context.l10n.emptyTrash,
body: context.l10n.emptyTrashConfirmation,
- firstButtonLabel: context.l10n.emptyTrash,
- secondButtonLabel: context.l10n.cancel,
- firstButtonType: ButtonType.critical,
- isCritical: true,
+ deleteButtonLabel: context.l10n.emptyTrash,
+ assetPath: "assets/collection_delete_icon.png",
);
if (result?.action == ButtonAction.first && context.mounted) {
@@ -282,157 +281,26 @@ class _TrashPageState extends State<TrashPage> {
],
),
const SizedBox(height: 24),
- ItemListView(
- files: _sortedTrashFiles.cast<EnteFile>(),
- fileOverflowActions: _getFileOverflowActions(),
- ),
- ],
- ),
- );
- }
-}
-
-class _CollectionPickerDialog extends StatefulWidget {
- final List<Collection> collections;
- final String fileName;
-
- const _CollectionPickerDialog({
- required this.collections,
- required this.fileName,
- });
-
- @override
- State<_CollectionPickerDialog> createState() =>
- _CollectionPickerDialogState();
-}
-
-class _CollectionPickerDialogState extends State<_CollectionPickerDialog> {
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
-
- return Dialog(
- backgroundColor: colorScheme.backgroundElevated,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- ),
- child: Container(
- width: 400,
- constraints: const BoxConstraints(maxHeight: 600),
- padding: const EdgeInsets.all(20),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- const Icon(
- Icons.restore,
- color: Colors.green,
- size: 24,
- ),
- const SizedBox(width: 8),
- Expanded(
- child: Text(
- context.l10n.restoreFile(widget.fileName),
- style: textTheme.largeBold,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
+ Expanded(
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ return SingleChildScrollView(
+ physics: const BouncingScrollPhysics(),
+ padding: EdgeInsets.zero,
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ minHeight: constraints.maxHeight,
+ ),
+ child: ItemListView(
+ files: _sortedTrashFiles.cast<EnteFile>(),
+ fileOverflowActions: _getFileOverflowActions(),
+ ),
),
- ),
- ],
+ );
+ },
),
- const SizedBox(height: 20),
- Flexible(
- child: Container(
- height: 150,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(8),
- border: Border.all(color: colorScheme.strokeFaint),
- ),
- child: widget.collections.isEmpty
- ? Container(
- padding: const EdgeInsets.all(16),
- child: Center(
- child: Text(
- context.l10n.noCollectionsAvailable,
- style: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- ),
- )
- : Scrollbar(
- thumbVisibility: true,
- thickness: 6,
- radius: const Radius.circular(3),
- child: GridView.builder(
- gridDelegate:
- const SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: 2,
- childAspectRatio: 3.5,
- crossAxisSpacing: 6,
- mainAxisSpacing: 6,
- ),
- padding: const EdgeInsets.all(6),
- itemCount: widget.collections.length,
- itemBuilder: (context, index) {
- final collection = widget.collections[index];
- final collectionName =
- collection.name ?? 'Unnamed Collection';
-
- return InkWell(
- onTap: () =>
- Navigator.of(context).pop(collection),
- borderRadius: BorderRadius.circular(8),
- child: Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 6,
- vertical: 4,
- ),
- decoration: BoxDecoration(
- color: colorScheme.fillFaint,
- borderRadius: BorderRadius.circular(8),
- border: Border.all(
- color: colorScheme.strokeFaint,
- width: 1,
- ),
- ),
- child: Center(
- child: Text(
- collectionName,
- style: textTheme.small.copyWith(
- color: colorScheme.textBase,
- fontWeight: FontWeight.normal,
- ),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- ),
- ),
- ),
- );
- },
- ),
- ),
- ),
- ),
- const SizedBox(height: 20),
- Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- Flexible(
- child: ButtonWidget(
- buttonType: ButtonType.secondary,
- labelText: context.l10n.cancel,
- onTap: () async => Navigator.of(context).pop(),
- ),
- ),
- ],
- ),
- ],
- ),
+ ),
+ ],
),
);
}
diff --git a/mobile/apps/locker/lib/ui/settings/account_section_widget.dart b/mobile/apps/locker/lib/ui/settings/account_section_widget.dart
index d9fe1df3df..bc8fd2688d 100644
--- a/mobile/apps/locker/lib/ui/settings/account_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/settings/account_section_widget.dart
@@ -42,6 +42,7 @@ class AccountSectionWidget extends StatelessWidget {
title: l10n.changeEmail,
makeTextBold: true,
),
+ leadingSpace: 52,
trailingIcon: Icons.chevron_right_outlined,
onTap: () async {
final hasAuthenticated = await LocalAuthenticationService.instance
diff --git a/mobile/apps/locker/lib/ui/viewer/actions/collection_selection_overlay_bar.dart b/mobile/apps/locker/lib/ui/viewer/actions/collection_selection_overlay_bar.dart
index 2dc6e30184..be2300b19d 100644
--- a/mobile/apps/locker/lib/ui/viewer/actions/collection_selection_overlay_bar.dart
+++ b/mobile/apps/locker/lib/ui/viewer/actions/collection_selection_overlay_bar.dart
@@ -1,19 +1,27 @@
+import "package:ente_events/event_bus.dart";
import "package:ente_ui/theme/ente_theme.dart";
-import "package:ente_utils/navigation_util.dart";
+import "package:ente_ui/utils/dialog_util.dart";
import "package:flutter/material.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/models/ui_section_type.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/selection_action_button_widget.dart";
-import "package:locker/ui/sharing/add_participant_page.dart";
+import "package:locker/ui/sharing/share_collection_bottom_sheet.dart";
import "package:locker/utils/collection_actions.dart";
+import "package:logging/logging.dart";
class CollectionSelectionOverlayBar extends StatefulWidget {
final SelectedCollections selectedCollections;
final List<Collection> collection;
+ final UISectionType viewType;
const CollectionSelectionOverlayBar({
required this.selectedCollections,
required this.collection,
+ this.viewType = UISectionType.homeCollections,
super.key,
});
@@ -24,6 +32,8 @@ class CollectionSelectionOverlayBar extends StatefulWidget {
class _CollectionSelectionOverlayBarState
extends State<CollectionSelectionOverlayBar> {
+ static final _logger = Logger('CollectionSelectionOverlayBar');
+
@override
void initState() {
super.initState();
@@ -246,58 +256,144 @@ class _CollectionSelectionOverlayBarState
final isSingleSelection = selectedCollections.length == 1;
final collection = isSingleSelection ? selectedCollections.first : null;
final actions = <Widget>[];
+ final viewType = widget.viewType;
- if (isSingleSelection) {
- actions.addAll([
+ if (viewType == UISectionType.homeCollections ||
+ viewType == UISectionType.outgoingCollections) {
+ if (isSingleSelection) {
+ actions.addAll([
+ SelectionActionButton(
+ icon: Icons.share_outlined,
+ label: context.l10n.share,
+ onTap: () => _shareCollection(collection!),
+ ),
+ SelectionActionButton(
+ icon: Icons.edit_outlined,
+ label: context.l10n.edit,
+ onTap: () {
+ _editCollection(collection!);
+ },
+ ),
+ SelectionActionButton(
+ icon: Icons.delete_outline,
+ label: context.l10n.delete,
+ onTap: () {
+ _deleteCollection(collection!);
+ },
+ isDestructive: true,
+ ),
+ ]);
+ } else {
+ actions.addAll([
+ SelectionActionButton(
+ icon: Icons.delete_outline,
+ label: context.l10n.delete,
+ onTap: () {
+ _deleteMultipleCollections(
+ widget.selectedCollections.collections,
+ );
+ },
+ isDestructive: true,
+ ),
+ ]);
+ }
+ } else {
+ actions.add(
SelectionActionButton(
icon: Icons.share_outlined,
label: context.l10n.share,
- onTap: _shareCollection,
- ),
- SelectionActionButton(
- icon: Icons.edit_outlined,
- label: context.l10n.edit,
- onTap: () {
- CollectionActions.editCollection(
- context,
- collection!,
- );
- },
- ),
- SelectionActionButton(
- icon: Icons.delete_outline,
- label: context.l10n.delete,
- onTap: () {
- CollectionActions.deleteCollection(context, collection!);
- },
- isDestructive: true,
- ),
- ]);
- } else {
- actions.addAll([
- SelectionActionButton(
- icon: Icons.delete_outline,
- label: context.l10n.delete,
- onTap: () {
- CollectionActions.deleteMultipleCollections(
- context,
- selectedCollections.toList(),
- );
- },
- isDestructive: true,
+ onTap: _leaveCollection,
),
- ]);
+ );
}
+
return actions;
}
- Future<void> _shareCollection() async {
- await routeToPage(
+ Future<void> _editCollection(Collection collection) async {
+ try {
+ await CollectionActions.editCollection(
+ context,
+ collection,
+ );
+ widget.selectedCollections.clearAll();
+ } catch (e, s) {
+ _logger.severe(e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+
+ widget.selectedCollections.clearAll();
+ }
+
+ Future<void> _deleteCollection(Collection collection) async {
+ try {
+ await CollectionActions.deleteCollection(context, collection);
+ widget.selectedCollections.clearAll();
+ } catch (e, s) {
+ _logger.severe(e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+
+ widget.selectedCollections.clearAll();
+ }
+
+ Future<void> _deleteMultipleCollections(
+ Set<Collection> collections,
+ ) async {
+ try {
+ await CollectionActions.deleteMultipleCollections(
+ context,
+ collections.toList(),
+ );
+ widget.selectedCollections.clearAll();
+ } catch (e, s) {
+ _logger.severe(e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+
+ widget.selectedCollections.clearAll();
+ }
+
+ Future<void> _shareCollection(Collection collection) async {
+ final collectionViewType = getCollectionViewType(
+ collection,
+ Configuration.instance.getUserID()!,
+ );
+ try {
+ if ((collectionViewType != CollectionViewType.ownedCollection &&
+ collectionViewType != CollectionViewType.sharedCollection &&
+ collectionViewType != CollectionViewType.hiddenOwnedCollection &&
+ collectionViewType != CollectionViewType.favorite)) {
+ throw Exception(
+ "Cannot share collection of type $collectionViewType",
+ );
+ }
+
+ await showModalBottomSheet(
+ context: context,
+ backgroundColor: getEnteColorScheme(context).backgroundBase,
+ isScrollControlled: true,
+ builder: (context) => ShareCollectionBottomSheet(
+ collection: collection,
+ ),
+ );
+ } catch (e, s) {
+ _logger.severe(e, s);
+ await showGenericErrorDialog(context: context, error: e);
+ }
+
+ widget.selectedCollections.clearAll();
+ }
+
+ Future<void> _leaveCollection() async {
+ await CollectionActions.leaveMultipleCollection(
context,
- AddParticipantPage(
- widget.selectedCollections.collections.toList(),
- const [ActionTypesToShow.addViewer, ActionTypesToShow.addCollaborator],
- ),
+ widget.selectedCollections.collections.toList(),
+ onSuccess: () {
+ Bus.instance.fire(
+ CollectionsUpdatedEvent("leave_collection"),
+ );
+ },
);
widget.selectedCollections.clearAll();
}
diff --git a/mobile/apps/locker/lib/utils/collection_actions.dart b/mobile/apps/locker/lib/utils/collection_actions.dart
index 83579b762e..e063bde73f 100644
--- a/mobile/apps/locker/lib/utils/collection_actions.dart
+++ b/mobile/apps/locker/lib/utils/collection_actions.dart
@@ -123,15 +123,13 @@ class CollectionActions {
}) async {
if (collections.isEmpty) return;
- final dialogChoice = await showChoiceDialog(
+ final dialogChoice = await showDeleteConfirmationDialog(
context,
title: context.l10n.areYouSure,
body:
context.l10n.deleteMultipleCollectionsDialogBody(collections.length),
- firstButtonLabel: context.l10n.yesDeleteCollections(collections.length),
- secondButtonLabel: context.l10n.cancel,
- firstButtonType: ButtonType.critical,
- isCritical: true,
+ deleteButtonLabel: context.l10n.yesDeleteCollections(collections.length),
+ assetPath: "assets/collection_delete_icon.png",
);
if (dialogChoice?.action != ButtonAction.first) return;
@@ -277,6 +275,55 @@ class CollectionActions {
}
}
+ static Future<void> leaveMultipleCollection(
+ BuildContext context,
+ List<Collection> collections, {
+ VoidCallback? onSuccess,
+ }) async {
+ final actionResult = await showActionSheet(
+ context: context,
+ buttons: [
+ ButtonWidget(
+ buttonType: ButtonType.critical,
+ isInAlert: true,
+ shouldStickToDarkTheme: true,
+ buttonAction: ButtonAction.first,
+ shouldSurfaceExecutionStates: true,
+ labelText: context.l10n.leaveCollection,
+ onTap: () async {
+ for (final col in collections) {
+ await CollectionApiClient.instance.leaveCollection(col);
+ }
+ },
+ ),
+ ButtonWidget(
+ buttonType: ButtonType.secondary,
+ buttonAction: ButtonAction.cancel,
+ isInAlert: true,
+ shouldStickToDarkTheme: true,
+ labelText: context.l10n.cancel,
+ ),
+ ],
+ title: context.l10n.leaveCollection,
+ body: context.l10n.filesAddedByYouWillBeRemovedFromTheCollection,
+ );
+ if (actionResult?.action != null && context.mounted) {
+ if (actionResult!.action == ButtonAction.error) {
+ await showGenericErrorDialog(
+ context: context,
+ error: actionResult.exception,
+ );
+ } else if (actionResult.action == ButtonAction.first) {
+ onSuccess?.call();
+ Navigator.of(context).pop();
+ SnackBarUtils.showInfoSnackBar(
+ context,
+ "Leave collection successfully",
+ );
+ }
+ }
+ }
+
static Future<bool> enableUrl(
BuildContext context,
Collection collection, {
diff --git a/mobile/apps/locker/lib/utils/local_settings.dart b/mobile/apps/locker/lib/utils/local_settings.dart
new file mode 100644
index 0000000000..4c3a007fb8
--- /dev/null
+++ b/mobile/apps/locker/lib/utils/local_settings.dart
@@ -0,0 +1,19 @@
+import "package:locker/models/item_view_type.dart";
+import "package:shared_preferences/shared_preferences.dart";
+
+class LocalSettings {
+ static const kItemViewType = "item_view_type";
+
+ final SharedPreferences _prefs;
+
+ LocalSettings(this._prefs);
+
+ Future<void> setItemViewType(ItemViewType viewType) async {
+ await _prefs.setInt(kItemViewType, viewType.index);
+ }
+
+ ItemViewType itemViewType() {
+ final index = _prefs.getInt(kItemViewType) ?? 0;
+ return ItemViewType.values[index];
+ }
+}
diff --git a/mobile/packages/ui/lib/components/menu_item_child_widgets.dart b/mobile/packages/ui/lib/components/menu_item_child_widgets.dart
index 2b13dcd0e5..f825dfd12b 100644
--- a/mobile/packages/ui/lib/components/menu_item_child_widgets.dart
+++ b/mobile/packages/ui/lib/components/menu_item_child_widgets.dart
@@ -150,24 +150,28 @@ class LeadingWidget extends StatelessWidget {
if (leadingIcon == null && leadingIconWidget == null) {
return const SizedBox.shrink();
}
- return Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(12),
- color: getEnteColorScheme(context).backgroundElevated,
- ),
- padding: const EdgeInsets.all(8.0),
- child: leadingIcon == null
- ? FittedBox(
- fit: BoxFit.contain,
- child: leadingIconWidget,
- )
- : FittedBox(
- fit: BoxFit.contain,
- child: Icon(
- leadingIcon,
- color: leadingIconColor ?? getEnteColorScheme(context).fillBase,
+ return Padding(
+ padding: const EdgeInsets.only(right: 10),
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(12),
+ color: getEnteColorScheme(context).backgroundElevated,
+ ),
+ padding: const EdgeInsets.all(8.0),
+ child: leadingIcon == null
+ ? FittedBox(
+ fit: BoxFit.contain,
+ child: leadingIconWidget,
+ )
+ : FittedBox(
+ fit: BoxFit.contain,
+ child: Icon(
+ leadingIcon,
+ color:
+ leadingIconColor ?? getEnteColorScheme(context).fillBase,
+ ),
),
- ),
+ ),
);
}
}