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 f225f4f0e2..a6f38568a9 100644 --- a/mobile/apps/locker/lib/ui/pages/all_collections_page.dart +++ b/mobile/apps/locker/lib/ui/pages/all_collections_page.dart @@ -18,8 +18,19 @@ import 'package:locker/ui/pages/trash_page.dart'; import 'package:locker/utils/collection_sort_util.dart'; import 'package:logging/logging.dart'; +enum CollectionViewType { + homeCollections, + outgoingCollections, + incomingCollections, +} + class AllCollectionsPage extends StatefulWidget { - const AllCollectionsPage({super.key}); + final CollectionViewType viewType; + + const AllCollectionsPage({ + super.key, + this.viewType = CollectionViewType.homeCollections, + }); @override State createState() => _AllCollectionsPageState(); @@ -34,6 +45,8 @@ class _AllCollectionsPageState extends State List _allFiles = []; bool _isLoading = true; String? _error; + bool showTrash = false; + bool showUncategorized = false; final _logger = Logger("AllCollectionsPage"); @override @@ -68,6 +81,10 @@ class _AllCollectionsPageState extends State Bus.instance.on().listen((event) async { await _loadCollections(); }); + if (widget.viewType == CollectionViewType.homeCollections) { + showTrash = true; + showUncategorized = true; + } } Future _loadCollections() async { @@ -77,7 +94,23 @@ class _AllCollectionsPageState extends State }); try { - final collections = await CollectionService.instance.getCollections(); + List collections = []; + + switch (widget.viewType) { + case CollectionViewType.homeCollections: + collections = await CollectionService.instance.getCollections(); + break; + case CollectionViewType.outgoingCollections: + final sharedCollections = + await CollectionService.instance.getSharedCollections(); + collections = sharedCollections.outgoing; + break; + case CollectionViewType.incomingCollections: + final sharedCollections = + await CollectionService.instance.getSharedCollections(); + collections = sharedCollections.incoming; + break; + } final regularCollections = []; Collection? uncategorized; @@ -94,8 +127,12 @@ class _AllCollectionsPageState extends State _allCollections = List.from(collections); _sortedCollections = List.from(regularCollections); - _uncategorizedCollection = uncategorized; - _uncategorizedFileCount = uncategorized != null + _uncategorizedCollection = + widget.viewType == CollectionViewType.homeCollections + ? uncategorized + : null; + _uncategorizedFileCount = uncategorized != null && + widget.viewType == CollectionViewType.homeCollections ? (await CollectionService.instance .getFilesInCollection(uncategorized)) .length @@ -122,7 +159,7 @@ class _AllCollectionsPageState extends State child: Scaffold( appBar: AppBar( leading: buildSearchLeading(), - title: Text(context.l10n.collections), + title: Text(_getTitle(context)), centerTitle: false, backgroundColor: Theme.of(context).scaffoldBackgroundColor, foregroundColor: Theme.of(context).textTheme.bodyLarge?.color, @@ -237,9 +274,11 @@ class _AllCollectionsPageState extends State enableSorting: true, ), ), - if (!isSearchActive && _uncategorizedCollection != null) + if (!isSearchActive && + _uncategorizedCollection != null && + showUncategorized) _buildUncategorizedHook(), - _buildTrashHook(), + if (showTrash) _buildTrashHook(), ], ), ); @@ -254,9 +293,9 @@ class _AllCollectionsPageState extends State child: Container( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.surface.withOpacity(0.3), + color: Theme.of(context).colorScheme.surface.withAlpha(30), border: Border.all( - color: Theme.of(context).dividerColor.withOpacity(0.5), + color: Theme.of(context).dividerColor.withAlpha(50), width: 0.5, ), borderRadius: BorderRadius.circular(12.0), @@ -265,11 +304,8 @@ class _AllCollectionsPageState extends State children: [ Icon( Icons.delete_outline, - color: Theme.of(context) - .textTheme - .bodyLarge - ?.color - ?.withOpacity(0.7), + color: + Theme.of(context).textTheme.bodyLarge?.color?.withAlpha(70), size: 22, ), const SizedBox(width: 12), @@ -287,7 +323,7 @@ class _AllCollectionsPageState extends State .textTheme .bodyMedium ?.color - ?.withOpacity(0.6), + ?.withAlpha(60), size: 20, ), ], @@ -326,9 +362,9 @@ class _AllCollectionsPageState extends State child: Container( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), decoration: BoxDecoration( - color: Theme.of(context).colorScheme.surface.withOpacity(0.3), + color: Theme.of(context).colorScheme.surface.withAlpha(30), border: Border.all( - color: Theme.of(context).dividerColor.withOpacity(0.5), + color: Theme.of(context).dividerColor.withAlpha(50), width: 0.5, ), borderRadius: BorderRadius.circular(12.0), @@ -337,11 +373,8 @@ class _AllCollectionsPageState extends State children: [ Icon( Icons.folder_open_outlined, - color: Theme.of(context) - .textTheme - .bodyLarge - ?.color - ?.withOpacity(0.7), + color: + Theme.of(context).textTheme.bodyLarge?.color?.withAlpha(70), size: 22, ), const SizedBox(width: 12), @@ -363,7 +396,7 @@ class _AllCollectionsPageState extends State .textTheme .bodySmall ?.color - ?.withOpacity(0.5), + ?.withAlpha(50), ), ), const SizedBox(width: 8), @@ -374,7 +407,7 @@ class _AllCollectionsPageState extends State .textTheme .bodySmall ?.color - ?.withOpacity(0.7), + ?.withAlpha(70), ), ), ], @@ -387,7 +420,7 @@ class _AllCollectionsPageState extends State .textTheme .bodyMedium ?.color - ?.withOpacity(0.6), + ?.withAlpha(60), size: 20, ), ], @@ -405,4 +438,15 @@ class _AllCollectionsPageState extends State ), ); } + + String _getTitle(BuildContext context) { + switch (widget.viewType) { + case CollectionViewType.homeCollections: + return context.l10n.collections; + case CollectionViewType.outgoingCollections: + return "Shared by you"; + case CollectionViewType.incomingCollections: + return "Shared with you"; + } + } }