Browse Source

Merge pull request #870 from ente-io/archived_albums

Show archived albums inside archive section
Neeraj Gupta 2 years ago
parent
commit
fd79f91260

+ 7 - 1
lib/services/collections_service.dart

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

+ 6 - 3
lib/ui/collections_gallery_widget.dart

@@ -85,9 +85,12 @@ class _CollectionsGalleryWidgetState extends State<CollectionsGalleryWidget>
     final List<CollectionWithThumbnail> collectionsWithThumbnail =
     final List<CollectionWithThumbnail> collectionsWithThumbnail =
         await CollectionsService.instance.getCollectionsWithThumbnails();
         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 =
     final ListMatch<CollectionWithThumbnail> favMathResult =
         collectionsWithThumbnail.splitMatch(
         collectionsWithThumbnail.splitMatch(
       (element) => element.collection.type == CollectionType.favorites,
       (element) => element.collection.type == CollectionType.favorites,

+ 0 - 9
lib/ui/notification/update/change_log_page.dart

@@ -123,15 +123,6 @@ class _ChangeLogPageState extends State<ChangeLogPage> {
         ),
         ),
       );
       );
     }
     }
-    items.add(
-      ChangeLogEntry(
-        "Object Detection (Beta)",
-        "This release comes packed with another goodie – the ability to "
-            "identify objects within a photo.\nYou can preview this feature "
-            "within the Info section of your files.\n\nPlease note that this "
-            "feature is in beta, and once fine tuned, you will be able to search through your photos based on their contents.",
-      ),
-    );
 
 
     return Container(
     return Container(
       padding: const EdgeInsets.only(left: 16),
       padding: const EdgeInsets.only(left: 16),

+ 47 - 0
lib/ui/viewer/gallery/archive_page.dart

@@ -1,14 +1,19 @@
 import 'package:collection/collection.dart' show IterableExtension;
 import 'package:collection/collection.dart' show IterableExtension;
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
+import "package:logging/logging.dart";
 import 'package:photos/core/configuration.dart';
 import 'package:photos/core/configuration.dart';
 import 'package:photos/core/event_bus.dart';
 import 'package:photos/core/event_bus.dart';
 import 'package:photos/db/files_db.dart';
 import 'package:photos/db/files_db.dart';
 import 'package:photos/events/files_updated_event.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/gallery_type.dart';
 import 'package:photos/models/magic_metadata.dart';
 import 'package:photos/models/magic_metadata.dart';
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/services/collections_service.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/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.dart';
 import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
 import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
 
 
@@ -17,6 +22,7 @@ class ArchivePage extends StatelessWidget {
   final GalleryType appBarType;
   final GalleryType appBarType;
   final GalleryType overlayType;
   final GalleryType overlayType;
   final _selectedFiles = SelectedFiles();
   final _selectedFiles = SelectedFiles();
+  final Logger _logger = Logger("ArchivePage");
 
 
   ArchivePage({
   ArchivePage({
     this.tagPrefix = "archived_page",
     this.tagPrefix = "archived_page",
@@ -61,6 +67,47 @@ class ArchivePage extends StatelessWidget {
       tagPrefix: tagPrefix,
       tagPrefix: tagPrefix,
       selectedFiles: _selectedFiles,
       selectedFiles: _selectedFiles,
       initialFiles: null,
       initialFiles: null,
+      emptyState: const EmptyState(
+        text: "You don't have any archived items.",
+      ),
+      header: FutureBuilder(
+        future: CollectionsService.instance.getArchivedCollectionWithThumb(),
+        builder: (context, snapshot) {
+          if (snapshot.hasError) {
+            _logger.severe("failed to fetch archived albums", snapshot.error);
+            return const Text("Something went wrong");
+          } 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(
     return Scaffold(
       appBar: PreferredSize(
       appBar: PreferredSize(