Add a gallery for shared collections
This commit is contained in:
parent
6a73308bd1
commit
f6b9e50f8a
5 changed files with 69 additions and 13 deletions
|
@ -149,6 +149,20 @@ class FilesDB {
|
|||
return _convertToFiles(results);
|
||||
}
|
||||
|
||||
Future<List<File>> 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<List<File>> getFilesCreatedWithinDuration(
|
||||
int startCreationTime, int endCreationTime) async {
|
||||
final db = await instance.database;
|
||||
|
|
|
@ -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<GalleryAppBarWidget> {
|
|||
List<Widget> _getActions(BuildContext context) {
|
||||
List<Widget> actions = List<Widget>();
|
||||
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),
|
||||
|
|
|
@ -32,7 +32,7 @@ class _RemoteFolderPageState extends State<RemoteFolderPage> {
|
|||
);
|
||||
return Scaffold(
|
||||
appBar: GalleryAppBarWidget(
|
||||
GalleryAppBarType.remote_folder,
|
||||
GalleryAppBarType.shared_collection,
|
||||
widget.folder.name,
|
||||
_selectedFiles,
|
||||
widget.folder.deviceFolder,
|
||||
|
|
42
lib/ui/shared_collection_page.dart
Normal file
42
lib/ui/shared_collection_page.dart
Normal file
|
@ -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<SharedCollectionPage> {
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<SharedCollectionGallery> {
|
|||
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<SharedCollectionGallery> {
|
|||
],
|
||||
),
|
||||
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;
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue