ente/lib/ui/viewer/gallery/archive_page.dart

95 lines
3.1 KiB
Dart
Raw Normal View History

import 'package:collection/collection.dart' show IterableExtension;
2021-09-17 04:44:10 +00:00
import 'package:flutter/material.dart';
import 'package:photos/core/configuration.dart';
2021-09-17 04:44:10 +00:00
import 'package:photos/core/event_bus.dart';
import 'package:photos/db/files_db.dart';
import 'package:photos/events/files_updated_event.dart';
2022-07-03 10:09:01 +00:00
import 'package:photos/models/gallery_type.dart';
2021-09-20 06:41:38 +00:00
import 'package:photos/models/magic_metadata.dart';
2021-09-17 04:44:10 +00:00
import 'package:photos/models/selected_files.dart';
import 'package:photos/services/collections_service.dart';
import "package:photos/ui/components/album_horizontal_list_widget.dart";
2022-12-16 07:27:29 +00:00
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';
2021-09-17 04:44:10 +00:00
class ArchivePage extends StatelessWidget {
final String tagPrefix;
final GalleryType appBarType;
final GalleryType overlayType;
2021-09-17 04:44:10 +00:00
final _selectedFiles = SelectedFiles();
2022-06-11 08:23:52 +00:00
ArchivePage({
this.tagPrefix = "archived_page",
this.appBarType = GalleryType.archive,
this.overlayType = GalleryType.archive,
Key? key,
2022-06-11 08:23:52 +00:00
}) : super(key: key);
2021-09-17 04:44:10 +00:00
@override
Widget build(Object context) {
final Set<int> hiddenCollectionIDs =
CollectionsService.instance.getHiddenCollections();
2021-09-17 04:44:10 +00:00
final gallery = Gallery(
asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) {
return FilesDB.instance.getAllPendingOrUploadedFiles(
2022-06-11 08:23:52 +00:00
creationStartTime,
creationEndTime,
Configuration.instance.getUserID()!,
visibility: visibilityArchive,
2022-06-11 08:23:52 +00:00
limit: limit,
asc: asc,
ignoredCollectionIDs: hiddenCollectionIDs,
2022-06-11 08:23:52 +00:00
);
2021-09-17 04:44:10 +00:00
},
2021-09-23 11:09:56 +00:00
reloadEvent: Bus.instance.on<FilesUpdatedEvent>().where(
(event) =>
event.updatedFiles.firstWhereOrNull(
2022-06-11 08:23:52 +00:00
(element) => element.uploadedFileID != null,
) !=
2021-09-23 11:09:56 +00:00
null,
),
removalEventTypes: const {EventType.unarchived},
2021-09-23 11:09:56 +00:00
forceReloadEvents: [
Bus.instance.on<FilesUpdatedEvent>().where(
(event) =>
event.updatedFiles.firstWhereOrNull(
2022-06-11 08:23:52 +00:00
(element) => element.uploadedFileID != null,
) !=
2021-09-23 11:09:56 +00:00
null,
),
],
2021-09-17 04:44:10 +00:00
tagPrefix: tagPrefix,
selectedFiles: _selectedFiles,
initialFiles: null,
emptyState: const EmptyState(
2023-02-18 11:21:27 +00:00
text: "You don't have any archived items.",
),
header: AlbumHorizontalListWidget(
2023-02-23 01:22:08 +00:00
CollectionsService.instance.getArchivedCollectionWithThumb,
),
2021-09-17 04:44:10 +00:00
);
return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(50.0),
child: GalleryAppBarWidget(
appBarType,
2022-10-31 09:56:59 +00:00
"Archive",
_selectedFiles,
2021-09-17 04:44:10 +00:00
),
),
body: Stack(
alignment: Alignment.bottomCenter,
children: [
gallery,
2022-12-16 07:27:29 +00:00
FileSelectionOverlayBar(
overlayType,
_selectedFiles,
2022-12-16 07:27:29 +00:00
),
],
),
2021-09-17 04:44:10 +00:00
);
}
}