ente/lib/ui/viewer/search/collections/files_in_location_page.dart

90 lines
2.8 KiB
Dart
Raw Normal View History

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