ente/lib/ui/collection_page.dart

76 lines
2.4 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/db/files_db.dart';
import 'package:photos/events/collection_updated_event.dart';
import 'package:photos/events/files_updated_event.dart';
2021-05-13 18:05:32 +00:00
import 'package:photos/models/collection_items.dart';
import 'package:photos/models/galleryType.dart';
import 'package:photos/models/selected_files.dart';
import 'package:photos/ui/common/bottomShadow.dart';
2021-10-30 05:51:23 +00:00
import 'package:photos/ui/gallery.dart';
import 'package:photos/ui/gallery_app_bar_widget.dart';
import 'package:photos/ui/gallery_overlay_widget.dart';
class CollectionPage extends StatelessWidget {
2021-05-13 18:05:32 +00:00
final CollectionWithThumbnail c;
2020-11-02 14:38:59 +00:00
final String tagPrefix;
final GalleryType appBarType;
final GalleryType overlayType;
final _selectedFiles = SelectedFiles();
CollectionPage(this.c,
{this.tagPrefix = "collection",
this.appBarType = GalleryType.owned_collection,
this.overlayType = GalleryType.owned_collection,
Key key})
2020-11-16 08:00:40 +00:00
: super(key: key);
@override
Widget build(Object context) {
2021-05-13 18:05:32 +00:00
final initialFiles = c.thumbnail != null ? [c.thumbnail] : null;
final gallery = Gallery(
asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) {
return FilesDB.instance.getFilesInCollection(
2021-05-13 18:05:32 +00:00
c.collection.id, creationStartTime, creationEndTime,
limit: limit, asc: asc);
},
reloadEvent: Bus.instance
.on<CollectionUpdatedEvent>()
2021-05-13 18:05:32 +00:00
.where((event) => event.collectionID == c.collection.id),
removalEventTypes: const {
2021-10-29 23:56:27 +00:00
EventType.deletedFromRemote,
EventType.deletedFromEverywhere,
},
tagPrefix: tagPrefix,
selectedFiles: _selectedFiles,
2021-05-13 18:05:32 +00:00
initialFiles: initialFiles,
smallerTodayFont: true,
2022-04-30 12:18:26 +00:00
albumName: c.collection.name,
);
return Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(50.0),
child: GalleryAppBarWidget(
appBarType,
c.collection.name,
_selectedFiles,
collection: c.collection,
),
),
// body: gallery,
body: Stack(
alignment: Alignment.bottomCenter,
children: [
gallery,
BottomShadowWidget(),
GalleryOverlayWidget(
overlayType,
_selectedFiles,
collection: c.collection,
)
],
),
);
}
}