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

87 lines
2.7 KiB
Dart
Raw Normal View History

2023-01-12 05:15:30 +00:00
import 'package:collection/collection.dart' show IterableExtension;
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/files_updated_event.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/viewer/actions/file_selection_overlay_bar.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
class ArchivePage extends StatelessWidget {
final String tagPrefix;
final GalleryType appBarType;
final GalleryType overlayType;
final _selectedFiles = SelectedFiles();
ArchivePage({
this.tagPrefix = "archived_page",
this.appBarType = GalleryType.archive,
this.overlayType = GalleryType.archive,
Key? key,
}) : super(key: key);
@override
Widget build(Object context) {
final Set<int> hiddenCollectionIDs =
CollectionsService.instance.getHiddenCollections();
final gallery = Gallery(
asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) {
return FilesDB.instance.getAllPendingOrUploadedFiles(
creationStartTime,
creationEndTime,
Configuration.instance.getUserID()!,
visibility: visibilityArchive,
limit: limit,
asc: asc,
ignoredCollectionIDs: hiddenCollectionIDs,
);
},
reloadEvent: Bus.instance.on<FilesUpdatedEvent>().where(
(event) =>
event.updatedFiles.firstWhereOrNull(
(element) => element.uploadedFileID != null,
) !=
null,
),
removalEventTypes: const {EventType.unarchived},
forceReloadEvents: [
Bus.instance.on<FilesUpdatedEvent>().where(
(event) =>
event.updatedFiles.firstWhereOrNull(
(element) => element.uploadedFileID != null,
) !=
null,
),
],
tagPrefix: tagPrefix,
selectedFiles: _selectedFiles,
initialFiles: null,
);
return Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(50.0),
child: GalleryAppBarWidget(
appBarType,
"Archive",
_selectedFiles,
),
),
body: Stack(
alignment: Alignment.bottomCenter,
children: [
gallery,
FileSelectionOverlayBar(
overlayType,
_selectedFiles,
),
],
),
);
}
}