Load all items within a collection
This commit is contained in:
parent
3bceabe6ac
commit
50150f507f
1 changed files with 27 additions and 16 deletions
|
@ -4,7 +4,9 @@ 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/models/collection.dart';
|
||||
import 'package:photos/models/file.dart';
|
||||
import 'package:photos/models/selected_files.dart';
|
||||
import 'package:photos/ui/loading_widget.dart';
|
||||
|
||||
import 'gallery.dart';
|
||||
import 'gallery_app_bar_widget.dart';
|
||||
|
@ -13,7 +15,9 @@ class CollectionPage extends StatefulWidget {
|
|||
final Collection collection;
|
||||
final String tagPrefix;
|
||||
|
||||
const CollectionPage(this.collection, {this.tagPrefix = "collection", Key key}) : super(key: key);
|
||||
const CollectionPage(this.collection,
|
||||
{this.tagPrefix = "collection", Key key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_CollectionPageState createState() => _CollectionPageState();
|
||||
|
@ -24,20 +28,6 @@ class _CollectionPageState extends State<CollectionPage> {
|
|||
|
||||
@override
|
||||
Widget build(Object context) {
|
||||
var gallery = Gallery(
|
||||
asyncLoader: (lastFile, limit) => FilesDB.instance
|
||||
.getAllInCollectionBeforeCreationTime(
|
||||
widget.collection.id,
|
||||
lastFile == null
|
||||
? DateTime.now().microsecondsSinceEpoch
|
||||
: lastFile.creationTime,
|
||||
limit),
|
||||
reloadEvent: Bus.instance
|
||||
.on<CollectionUpdatedEvent>()
|
||||
.where((event) => event.collectionID == widget.collection.id),
|
||||
tagPrefix: widget.tagPrefix,
|
||||
selectedFiles: _selectedFiles,
|
||||
);
|
||||
return Scaffold(
|
||||
appBar: GalleryAppBarWidget(
|
||||
GalleryAppBarType.collection,
|
||||
|
@ -45,7 +35,28 @@ class _CollectionPageState extends State<CollectionPage> {
|
|||
_selectedFiles,
|
||||
collection: widget.collection,
|
||||
),
|
||||
body: gallery,
|
||||
body: _getGallery(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getGallery() {
|
||||
return FutureBuilder<List<File>>(
|
||||
future: FilesDB.instance.getAllInCollection(widget.collection.id),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Gallery(
|
||||
syncLoader: () => snapshot.data,
|
||||
reloadEvent: Bus.instance
|
||||
.on<CollectionUpdatedEvent>()
|
||||
.where((event) => event.collectionID == widget.collection.id),
|
||||
tagPrefix: widget.tagPrefix,
|
||||
selectedFiles: _selectedFiles,
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text(snapshot.error.toString());
|
||||
}
|
||||
return loadWidget;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue