Show archived albums inside archive section

This commit is contained in:
Neeraj Gupta 2023-02-18 14:58:11 +05:30
parent 55b0f76987
commit 28410ce621
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
3 changed files with 59 additions and 4 deletions

View file

@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
import 'package:collection/collection.dart';
import 'package:dio/dio.dart';
@ -183,6 +182,13 @@ class CollectionsService {
.toSet();
}
Future<List<CollectionWithThumbnail>> getArchivedCollectionWithThumb() async {
final allCollections = await getCollectionsWithThumbnails();
return allCollections
.where((element) => element.collection.isArchived())
.toList();
}
Set<int> getHiddenCollections() {
return _collectionIDToCollections.values
.toList()

View file

@ -85,9 +85,12 @@ class _CollectionsGalleryWidgetState extends State<CollectionsGalleryWidget>
final List<CollectionWithThumbnail> collectionsWithThumbnail =
await CollectionsService.instance.getCollectionsWithThumbnails();
// Remove uncategorized collection
collectionsWithThumbnail
.removeWhere((t) => t.collection.type == CollectionType.uncategorized);
// Remove uncategorized collection and archived collections
collectionsWithThumbnail.removeWhere(
(t) =>
t.collection.type == CollectionType.uncategorized ||
t.collection.isArchived(),
);
final ListMatch<CollectionWithThumbnail> favMathResult =
collectionsWithThumbnail.splitMatch(
(element) => element.collection.type == CollectionType.favorites,

View file

@ -4,11 +4,15 @@ import 'package:photos/core/configuration.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/db/files_db.dart';
import 'package:photos/events/files_updated_event.dart';
import "package:photos/models/collection_items.dart";
import 'package:photos/models/gallery_type.dart';
import 'package:photos/models/magic_metadata.dart';
import 'package:photos/models/selected_files.dart';
import 'package:photos/services/collections_service.dart';
import "package:photos/ui/collections/collection_item_widget.dart";
import "package:photos/ui/common/loading_widget.dart";
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import "package:photos/ui/viewer/gallery/empty_state.dart";
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
@ -61,6 +65,48 @@ class ArchivePage extends StatelessWidget {
tagPrefix: tagPrefix,
selectedFiles: _selectedFiles,
initialFiles: null,
emptyState: const EmptyState(
text: "You don't have any archived photos.\n\n "
"Archived albums will be shown on top of this gallery.",
),
header: FutureBuilder(
future: CollectionsService.instance.getArchivedCollectionWithThumb(),
builder: (context, snapshot) {
if (snapshot.hasError) {
//Need to show an error on the UI here
return const SizedBox.shrink();
} else if (snapshot.hasData) {
final collectionsWithThumbnail =
snapshot.data as List<CollectionWithThumbnail>;
return SizedBox(
height: 200,
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: collectionsWithThumbnail.length,
padding: const EdgeInsets.fromLTRB(6, 6, 6, 6),
itemBuilder: (context, index) {
final item = collectionsWithThumbnail[index];
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () async {},
child: Padding(
padding: const EdgeInsets.all(2.0),
child: CollectionItem(
item,
120,
shouldRender: true,
),
),
);
},
),
);
} else {
return const EnteLoadingWidget();
}
},
),
);
return Scaffold(
appBar: PreferredSize(