2022-08-03 09:36:38 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:photos/core/event_bus.dart';
|
|
|
|
import 'package:photos/events/files_updated_event.dart';
|
2022-08-03 13:28:18 +00:00
|
|
|
import 'package:photos/models/file_load_result.dart';
|
2022-08-03 09:36:38 +00:00
|
|
|
import 'package:photos/models/gallery_type.dart';
|
2022-08-04 16:16:16 +00:00
|
|
|
import 'package:photos/models/search/location_search_result.dart';
|
2022-08-03 09:36:38 +00:00
|
|
|
import 'package:photos/models/selected_files.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_overlay_widget.dart';
|
|
|
|
|
|
|
|
class LocationCollectionPage extends StatelessWidget {
|
2022-08-04 16:16:16 +00:00
|
|
|
final LocationSearchResult locationAndFiles;
|
2022-08-03 09:36:38 +00:00
|
|
|
final String tagPrefix;
|
|
|
|
final GalleryType appBarType;
|
|
|
|
final GalleryType overlayType;
|
|
|
|
final _selectedFiles = SelectedFiles();
|
|
|
|
|
|
|
|
LocationCollectionPage({
|
2022-08-04 07:38:31 +00:00
|
|
|
this.locationAndFiles,
|
2022-08-03 09:36:38 +00:00
|
|
|
this.tagPrefix = "location_collection_page",
|
|
|
|
this.appBarType = GalleryType.archive,
|
|
|
|
this.overlayType = GalleryType.archive,
|
|
|
|
Key key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final gallery = Gallery(
|
|
|
|
asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) {
|
2022-08-04 07:38:31 +00:00
|
|
|
final result = locationAndFiles.files
|
2022-08-03 13:28:18 +00:00
|
|
|
.where(
|
|
|
|
(file) =>
|
|
|
|
file.creationTime >= creationStartTime &&
|
|
|
|
file.creationTime <= creationEndTime,
|
|
|
|
)
|
|
|
|
.toList();
|
|
|
|
return Future.value(
|
2022-08-04 07:38:31 +00:00
|
|
|
FileLoadResult(result, result.length < locationAndFiles.files.length),
|
2022-08-03 09:36:38 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
reloadEvent: Bus.instance.on<FilesUpdatedEvent>().where(
|
|
|
|
(event) =>
|
|
|
|
event.updatedFiles.firstWhere(
|
|
|
|
(element) => element.uploadedFileID != null,
|
|
|
|
orElse: () => null,
|
|
|
|
) !=
|
|
|
|
null,
|
|
|
|
),
|
|
|
|
removalEventTypes: const {EventType.unarchived},
|
|
|
|
forceReloadEvents: [
|
|
|
|
Bus.instance.on<FilesUpdatedEvent>().where(
|
|
|
|
(event) =>
|
|
|
|
event.updatedFiles.firstWhere(
|
|
|
|
(element) => element.uploadedFileID != null,
|
|
|
|
orElse: () => null,
|
|
|
|
) !=
|
|
|
|
null,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
tagPrefix: tagPrefix,
|
|
|
|
selectedFiles: _selectedFiles,
|
|
|
|
initialFiles: null,
|
|
|
|
footer: const SizedBox(height: 120),
|
|
|
|
);
|
|
|
|
return Scaffold(
|
|
|
|
appBar: PreferredSize(
|
|
|
|
preferredSize: const Size.fromHeight(50.0),
|
|
|
|
child: GalleryAppBarWidget(
|
|
|
|
appBarType,
|
2022-08-04 07:38:31 +00:00
|
|
|
locationAndFiles.location,
|
2022-08-03 09:36:38 +00:00
|
|
|
_selectedFiles,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: Stack(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
children: [
|
|
|
|
gallery,
|
|
|
|
GalleryOverlayWidget(
|
|
|
|
overlayType,
|
|
|
|
_selectedFiles,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|