2022-12-30 12:10:17 +00:00
|
|
|
import 'package:collection/collection.dart' show IterableExtension;
|
2022-10-27 07:23:45 +00:00
|
|
|
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/selected_files.dart';
|
|
|
|
import 'package:photos/services/collections_service.dart';
|
2022-12-16 07:42:13 +00:00
|
|
|
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
|
2022-11-03 04:28:06 +00:00
|
|
|
import 'package:photos/ui/viewer/gallery/empty_hidden_widget.dart';
|
2022-10-27 07:23:45 +00:00
|
|
|
import 'package:photos/ui/viewer/gallery/gallery.dart';
|
|
|
|
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
|
|
|
|
|
|
|
|
class HiddenPage extends StatelessWidget {
|
|
|
|
final String tagPrefix;
|
|
|
|
final GalleryType appBarType;
|
|
|
|
final GalleryType overlayType;
|
|
|
|
final _selectedFiles = SelectedFiles();
|
|
|
|
|
|
|
|
HiddenPage({
|
|
|
|
this.tagPrefix = "hidden_page",
|
|
|
|
this.appBarType = GalleryType.hidden,
|
|
|
|
this.overlayType = GalleryType.hidden,
|
2022-12-30 12:10:17 +00:00
|
|
|
Key? key,
|
2022-10-27 07:23:45 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(Object context) {
|
|
|
|
final gallery = Gallery(
|
|
|
|
asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) {
|
|
|
|
return FilesDB.instance.getFilesInCollections(
|
|
|
|
CollectionsService.instance.getHiddenCollections().toList(),
|
|
|
|
creationStartTime,
|
|
|
|
creationEndTime,
|
2022-12-30 12:10:17 +00:00
|
|
|
Configuration.instance.getUserID()!,
|
2022-10-27 07:23:45 +00:00
|
|
|
limit: limit,
|
|
|
|
asc: asc,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
reloadEvent: Bus.instance.on<FilesUpdatedEvent>().where(
|
|
|
|
(event) =>
|
2022-12-30 12:10:17 +00:00
|
|
|
event.updatedFiles.firstWhereOrNull(
|
2022-10-27 07:23:45 +00:00
|
|
|
(element) => element.uploadedFileID != null,
|
|
|
|
) !=
|
|
|
|
null,
|
|
|
|
),
|
2022-11-12 09:02:51 +00:00
|
|
|
removalEventTypes: const {
|
|
|
|
EventType.unhide,
|
|
|
|
EventType.deletedFromEverywhere,
|
|
|
|
EventType.deletedFromRemote
|
|
|
|
},
|
2022-10-27 07:23:45 +00:00
|
|
|
forceReloadEvents: [
|
|
|
|
Bus.instance.on<FilesUpdatedEvent>().where(
|
|
|
|
(event) =>
|
2022-12-30 12:10:17 +00:00
|
|
|
event.updatedFiles.firstWhereOrNull(
|
2022-10-27 07:23:45 +00:00
|
|
|
(element) => element.uploadedFileID != null,
|
|
|
|
) !=
|
|
|
|
null,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
tagPrefix: tagPrefix,
|
|
|
|
selectedFiles: _selectedFiles,
|
|
|
|
initialFiles: null,
|
2022-11-03 04:25:55 +00:00
|
|
|
emptyState: const EmptyHiddenWidget(),
|
2022-10-27 07:23:45 +00:00
|
|
|
);
|
|
|
|
return Scaffold(
|
|
|
|
appBar: PreferredSize(
|
|
|
|
preferredSize: const Size.fromHeight(50.0),
|
|
|
|
child: GalleryAppBarWidget(
|
|
|
|
appBarType,
|
2022-10-31 09:56:59 +00:00
|
|
|
"Hidden",
|
2022-10-27 07:23:45 +00:00
|
|
|
_selectedFiles,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: Stack(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
children: [
|
|
|
|
gallery,
|
2022-12-16 07:42:13 +00:00
|
|
|
FileSelectionOverlayBar(
|
2022-10-27 07:23:45 +00:00
|
|
|
overlayType,
|
|
|
|
_selectedFiles,
|
2022-12-16 07:42:13 +00:00
|
|
|
),
|
2022-10-27 07:23:45 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|