π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
update archive empty state
AmanRajSinghMouryaa3204959efab
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/archive_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/archive_page.dartindex 41b6eee59e..584ef7d63c 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/archive_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/archive_page.dart@@ -1,11 +1,15 @@+import "dart:async";+import 'package:collection/collection.dart' show IterableExtension;import "package:ente_pure_utils/ente_pure_utils.dart";import 'package:flutter/material.dart';import 'package:photos/core/configuration.dart';import 'package:photos/core/event_bus.dart';import 'package:photos/db/files_db.dart';+import "package:photos/events/collection_updated_event.dart";import 'package:photos/events/files_updated_event.dart';import "package:photos/generated/l10n.dart";+import "package:photos/models/collection/collection.dart";import 'package:photos/models/gallery_type.dart';import "package:photos/models/metadata/common_keys.dart";import 'package:photos/models/selected_files.dart';@@ -13,33 +17,72 @@ import 'package:photos/services/collections_service.dart';import "package:photos/services/filter/db_filters.dart";import "package:photos/ui/collections/album/horizontal_list.dart";import "package:photos/ui/collections/collection_list_page.dart";+import "package:photos/ui/components/empty_state_component.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';import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.dart";import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";import "package:photos/ui/viewer/gallery/state/selection_state.dart";-class ArchivePage extends StatelessWidget {+class ArchivePage extends StatefulWidget {final String tagPrefix;final GalleryType appBarType;final GalleryType overlayType;- final _selectedFiles = SelectedFiles();- ArchivePage({+ const ArchivePage({this.tagPrefix = "archived_page",this.appBarType = GalleryType.archive,this.overlayType = GalleryType.archive,super.key,});+ @override+ State<ArchivePage> createState() => _ArchivePageState();+}++class _ArchivePageState extends State<ArchivePage> {+ final _selectedFiles = SelectedFiles();+ final _archivedCollections = <Collection>[];+ late StreamSubscription<CollectionUpdatedEvent>+ _collectionUpdatesSubscription;++ @override+ void initState() {+ super.initState();+ _collectionUpdatesSubscription = Bus.instance+ .on<CollectionUpdatedEvent>()+ .listen((event) {+ unawaited(_refreshArchivedCollections());+ });+ unawaited(_refreshArchivedCollections());+ }++ @override+ void dispose() {+ _collectionUpdatesSubscription.cancel();+ super.dispose();+ }++ Future<void> _refreshArchivedCollections() async {+ final archivedCollections = await CollectionsService.instance+ .getArchivedCollection();+ if (!mounted) {+ return;+ }+ setState(() {+ _archivedCollections+ ..clear()+ ..addAll(archivedCollections);+ });+ }+@overrideWidget build(BuildContext context) {final Set<int> hiddenCollectionIDs = CollectionsService.instance.getHiddenCollectionIds();final appBar = GalleryAppBarWidget.sliverConfig(- appBarType,+ widget.appBarType,AppLocalizations.of(context).archive,_selectedFiles,);@@ -78,22 +121,23 @@ class ArchivePage extends StatelessWidget {null,),],- tagPrefix: tagPrefix,+ tagPrefix: widget.tagPrefix,selectedFiles: _selectedFiles,initialFiles: null,- emptyState: EmptyState(- text: AppLocalizations.of(context).youDontHaveAnyArchivedItems,- ),+ emptyState: _archivedCollections.isEmpty+ ? EmptyStateComponent(+ assetPath: "assets/empty_state_archive.png",+ title: AppLocalizations.of(context).archivedItemsWillShowUpHere,+ )+ : const SizedBox.shrink(),header: AlbumHorizontalList(- CollectionsService.instance.getArchivedCollection,+ () async => _archivedCollections,onViewAllTapped: () async {- final collections = await CollectionsService.instance- .getArchivedCollection();if (context.mounted) {await routeToPage(context,CollectionListPage(- collections,+ _archivedCollections,sectionType: UISectionType.archivedCollections,appTitle: Text(AppLocalizations.of(context).archiveCollectionName,@@ -102,6 +146,7 @@ class ArchivePage extends StatelessWidget {),);}+ unawaited(_refreshArchivedCollections());},),);@@ -114,7 +159,7 @@ class ArchivePage extends StatelessWidget {alignment: Alignment.bottomCenter,children: [gallery,- FileSelectionOverlayBar(overlayType, _selectedFiles),+ FileSelectionOverlayBar(widget.overlayType, _selectedFiles),],),),