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';
|
|
|
|
|
2022-08-10 06:28:16 +00:00
|
|
|
class FilesInLocationPage extends StatelessWidget {
|
2022-08-10 04:48:40 +00:00
|
|
|
final LocationSearchResult locationSearchResult;
|
2022-08-03 09:36:38 +00:00
|
|
|
|
2022-08-10 10:09:56 +00:00
|
|
|
final _selectedFiles = SelectedFiles();
|
|
|
|
static const String kTagPrefix = "location_search";
|
|
|
|
static const GalleryType appBarType = GalleryType.searchResults;
|
|
|
|
static const GalleryType overlayType = GalleryType.searchResults;
|
2022-08-10 06:28:16 +00:00
|
|
|
FilesInLocationPage({
|
2022-08-10 04:48:40 +00:00
|
|
|
this.locationSearchResult,
|
2022-08-03 09:36:38 +00:00
|
|
|
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
|
2022-08-03 13:28:18 +00:00
|
|
|
.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,
|
|
|
|
),
|
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,
|
|
|
|
),
|
|
|
|
forceReloadEvents: [
|
|
|
|
Bus.instance.on<FilesUpdatedEvent>().where(
|
|
|
|
(event) =>
|
|
|
|
event.updatedFiles.firstWhere(
|
|
|
|
(element) => element.uploadedFileID != null,
|
|
|
|
orElse: () => null,
|
|
|
|
) !=
|
|
|
|
null,
|
|
|
|
),
|
|
|
|
],
|
2022-08-10 10:09:56 +00:00
|
|
|
tagPrefix: kTagPrefix,
|
2022-08-03 09:36:38 +00:00
|
|
|
selectedFiles: _selectedFiles,
|
2022-08-10 04:48:40 +00:00
|
|
|
initialFiles: [locationSearchResult.files[0]],
|
2022-08-03 09:36:38 +00:00
|
|
|
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,
|
2022-08-03 09:36:38 +00:00
|
|
|
_selectedFiles,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: Stack(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
children: [
|
|
|
|
gallery,
|
|
|
|
GalleryOverlayWidget(
|
|
|
|
overlayType,
|
|
|
|
_selectedFiles,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|