Refactor colleciton_page & galleryType detection
This commit is contained in:
parent
2ccc913662
commit
2b52aa74c1
|
@ -195,11 +195,6 @@ class AlbumRowItemWidget extends StatelessWidget {
|
||||||
CollectionPage(
|
CollectionPage(
|
||||||
CollectionWithThumbnail(c, thumbnail),
|
CollectionWithThumbnail(c, thumbnail),
|
||||||
tagPrefix: tagPrefix,
|
tagPrefix: tagPrefix,
|
||||||
appBarType: isOwner
|
|
||||||
? (c.type == CollectionType.favorites
|
|
||||||
? GalleryType.favorite
|
|
||||||
: GalleryType.ownedCollection)
|
|
||||||
: GalleryType.sharedCollection,
|
|
||||||
hasVerifiedLock: hasVerifiedLock,
|
hasVerifiedLock: hasVerifiedLock,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -121,7 +121,7 @@ class QuickLinkAlbumItem extends StatelessWidget {
|
||||||
c,
|
c,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
),
|
),
|
||||||
appBarType: GalleryType.ownedCollection,
|
galleryType: GalleryType.ownedCollection,
|
||||||
tagPrefix: heroTagPrefix,
|
tagPrefix: heroTagPrefix,
|
||||||
);
|
);
|
||||||
routeToPage(context, page);
|
routeToPage(context, page);
|
||||||
|
|
|
@ -92,9 +92,6 @@ class AlbumsItemWidget extends StatelessWidget {
|
||||||
context,
|
context,
|
||||||
CollectionPage(
|
CollectionPage(
|
||||||
CollectionWithThumbnail(c, null),
|
CollectionWithThumbnail(c, null),
|
||||||
appBarType: c.isOwner(currentUserID)
|
|
||||||
? GalleryType.ownedCollection
|
|
||||||
: GalleryType.sharedCollection,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,13 +21,11 @@ import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
|
||||||
class CollectionPage extends StatelessWidget {
|
class CollectionPage extends StatelessWidget {
|
||||||
final CollectionWithThumbnail c;
|
final CollectionWithThumbnail c;
|
||||||
final String tagPrefix;
|
final String tagPrefix;
|
||||||
final GalleryType appBarType;
|
|
||||||
final bool? hasVerifiedLock;
|
final bool? hasVerifiedLock;
|
||||||
|
|
||||||
CollectionPage(
|
CollectionPage(
|
||||||
this.c, {
|
this.c, {
|
||||||
this.tagPrefix = "collection",
|
this.tagPrefix = "collection",
|
||||||
this.appBarType = GalleryType.ownedCollection,
|
|
||||||
this.hasVerifiedLock = false,
|
this.hasVerifiedLock = false,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
@ -42,7 +40,8 @@ class CollectionPage extends StatelessWidget {
|
||||||
return const EmptyState();
|
return const EmptyState();
|
||||||
}
|
}
|
||||||
|
|
||||||
final galleryType = _getGalleryType(c.collection);
|
final galleryType =
|
||||||
|
_getGalleryType(c.collection, Configuration.instance.getUserID()!);
|
||||||
final List<File>? initialFiles =
|
final List<File>? initialFiles =
|
||||||
c.thumbnail != null ? [c.thumbnail!] : null;
|
c.thumbnail != null ? [c.thumbnail!] : null;
|
||||||
final gallery = Gallery(
|
final gallery = Gallery(
|
||||||
|
@ -113,9 +112,8 @@ class CollectionPage extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
GalleryType _getGalleryType(Collection c) {
|
GalleryType _getGalleryType(Collection c, int userID) {
|
||||||
final currentUserID = Configuration.instance.getUserID()!;
|
if (!c.isOwner(userID)) {
|
||||||
if (!c.isOwner(currentUserID)) {
|
|
||||||
return GalleryType.sharedCollection;
|
return GalleryType.sharedCollection;
|
||||||
}
|
}
|
||||||
if (c.isDefaultHidden()) {
|
if (c.isDefaultHidden()) {
|
||||||
|
@ -127,6 +125,8 @@ class CollectionPage extends StatelessWidget {
|
||||||
} else if (c.isQuickLinkCollection()) {
|
} else if (c.isQuickLinkCollection()) {
|
||||||
return GalleryType.quickLink;
|
return GalleryType.quickLink;
|
||||||
}
|
}
|
||||||
return appBarType;
|
debugPrint("Unknown gallery type for collection ${c.id}, falling back to "
|
||||||
|
"default");
|
||||||
|
return GalleryType.ownedCollection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue