diff --git a/lib/db/files_db.dart b/lib/db/files_db.dart index 2dd4801db517f11017e142a3bdfb0d4a59027051..5f47b4894d8de0e6c78c7f7d21e96d389e903e56 100644 --- a/lib/db/files_db.dart +++ b/lib/db/files_db.dart @@ -149,6 +149,20 @@ class FilesDB { return _convertToFiles(results); } + Future> getAllInCollection( + int collectionID, int beforeCreationTime, int limit) async { + final db = await instance.database; + final results = await db.query( + table, + where: + '$columnCollectionID = ? AND $columnIsDeleted = 0 AND $columnCreationTime < ?', + whereArgs: [collectionID, beforeCreationTime], + orderBy: '$columnCreationTime DESC', + limit: limit, + ); + return _convertToFiles(results); + } + Future> getFilesCreatedWithinDuration( int startCreationTime, int endCreationTime) async { final db = await instance.database; diff --git a/lib/ui/gallery_app_bar_widget.dart b/lib/ui/gallery_app_bar_widget.dart index 21a4041a04dca1defa6cf2043abfcf8924714958..50dd4bfa1da56b474f4bc8d599e29e01a45afe77 100644 --- a/lib/ui/gallery_app_bar_widget.dart +++ b/lib/ui/gallery_app_bar_widget.dart @@ -19,7 +19,7 @@ import 'package:photos/utils/share_util.dart'; enum GalleryAppBarType { homepage, local_folder, - remote_folder, + shared_collection, search_results, } @@ -156,7 +156,7 @@ class _GalleryAppBarWidgetState extends State { List _getActions(BuildContext context) { List actions = List(); if (widget.selectedFiles.files.isNotEmpty) { - if (widget.type != GalleryAppBarType.remote_folder && + if (widget.type != GalleryAppBarType.shared_collection && widget.type != GalleryAppBarType.search_results) { actions.add(IconButton( icon: Icon(Icons.delete), diff --git a/lib/ui/remote_folder_page.dart b/lib/ui/remote_folder_page.dart index 9054fcd1808ae31d8f9ce9421873b9bc1554f6a6..d31b71614c16f641586e20dc6f7eb7532f6aa20a 100644 --- a/lib/ui/remote_folder_page.dart +++ b/lib/ui/remote_folder_page.dart @@ -32,7 +32,7 @@ class _RemoteFolderPageState extends State { ); return Scaffold( appBar: GalleryAppBarWidget( - GalleryAppBarType.remote_folder, + GalleryAppBarType.shared_collection, widget.folder.name, _selectedFiles, widget.folder.deviceFolder, diff --git a/lib/ui/shared_collection_page.dart b/lib/ui/shared_collection_page.dart new file mode 100644 index 0000000000000000000000000000000000000000..25a56d3725ae8c0127711cdb484ffbf54a78b5aa --- /dev/null +++ b/lib/ui/shared_collection_page.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; +import 'package:photos/db/files_db.dart'; +import 'package:photos/models/selected_files.dart'; +import 'package:photos/models/shared_collection.dart'; +import 'package:photos/ui/gallery.dart'; +import 'package:photos/ui/gallery_app_bar_widget.dart'; + +class SharedCollectionPage extends StatefulWidget { + final SharedCollection collection; + + const SharedCollectionPage(this.collection, {Key key}) : super(key: key); + + @override + _SharedCollectionPageState createState() => _SharedCollectionPageState(); +} + +class _SharedCollectionPageState extends State { + final _selectedFiles = SelectedFiles(); + + @override + Widget build(Object context) { + var gallery = Gallery( + asyncLoader: (lastFile, limit) => FilesDB.instance.getAllInCollection( + widget.collection.id, + lastFile == null + ? DateTime.now().microsecondsSinceEpoch + : lastFile.creationTime, + limit), + // onRefresh: () => FolderSharingService.instance.syncDiff(widget.folder), + tagPrefix: "shared_collection", + selectedFiles: _selectedFiles, + ); + return Scaffold( + appBar: GalleryAppBarWidget( + GalleryAppBarType.shared_collection, + widget.collection.name, + _selectedFiles, + ), + body: gallery, + ); + } +} diff --git a/lib/ui/shared_collections_gallery.dart b/lib/ui/shared_collections_gallery.dart index 7827005a022b286614ee5f1c569f0e08ddb449ce..566975eb91c33c12df432259adf02d664ec97a16 100644 --- a/lib/ui/shared_collections_gallery.dart +++ b/lib/ui/shared_collections_gallery.dart @@ -11,6 +11,7 @@ import 'package:photos/models/file.dart'; import 'package:photos/models/shared_collection.dart'; import 'package:photos/ui/common_elements.dart'; import 'package:photos/ui/loading_widget.dart'; +import 'package:photos/ui/shared_collection_page.dart'; import 'package:photos/ui/thumbnail_widget.dart'; class SharedCollectionGallery extends StatefulWidget { @@ -101,7 +102,7 @@ class _SharedCollectionGalleryState extends State { null // When the user has shared a folder without photos ? Icon(Icons.error) : Hero( - tag: "remote_folder" + c.thumbnail.tag(), + tag: "shared_collection" + c.thumbnail.tag(), child: ThumbnailWidget(c.thumbnail)), height: 150, width: 150, @@ -118,15 +119,14 @@ class _SharedCollectionGalleryState extends State { ], ), onTap: () { - // TODO - // final page = RemoteFolderPage(folder); - // Navigator.of(context).push( - // MaterialPageRoute( - // builder: (BuildContext context) { - // return page; - // }, - // ), - // ); + final page = SharedCollectionPage(c.collection); + Navigator.of(context).push( + MaterialPageRoute( + builder: (BuildContext context) { + return page; + }, + ), + ); }, ); }