2022-08-11 12:28:06 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-05-05 10:04:48 +00:00
|
|
|
import "package:intl/intl.dart";
|
2023-06-23 13:23:43 +00:00
|
|
|
import "package:photos/core/configuration.dart";
|
2022-08-11 12:28:06 +00:00
|
|
|
import 'package:photos/db/files_db.dart';
|
2022-12-15 11:24:51 +00:00
|
|
|
import 'package:photos/models/collection.dart';
|
2022-08-11 12:28:06 +00:00
|
|
|
import 'package:photos/models/collection_items.dart';
|
2023-06-19 17:07:03 +00:00
|
|
|
import "package:photos/models/file.dart";
|
2022-12-15 11:24:51 +00:00
|
|
|
import 'package:photos/models/gallery_type.dart';
|
2023-06-19 17:07:03 +00:00
|
|
|
import "package:photos/services/collections_service.dart";
|
2023-06-24 15:05:46 +00:00
|
|
|
import "package:photos/theme/colors.dart";
|
2022-10-19 11:16:27 +00:00
|
|
|
import 'package:photos/theme/ente_theme.dart';
|
2023-06-24 13:57:57 +00:00
|
|
|
import "package:photos/ui/sharing/album_share_info_widget.dart";
|
2023-06-23 10:11:40 +00:00
|
|
|
import "package:photos/ui/sharing/user_avator_widget.dart";
|
2022-10-19 09:49:32 +00:00
|
|
|
import 'package:photos/ui/viewer/file/no_thumbnail_widget.dart';
|
2022-08-11 12:28:06 +00:00
|
|
|
import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
|
|
|
|
import 'package:photos/ui/viewer/gallery/collection_page.dart';
|
|
|
|
import 'package:photos/utils/navigation_util.dart';
|
|
|
|
|
2023-06-06 16:43:32 +00:00
|
|
|
class AlbumRowItemWidget extends StatelessWidget {
|
2023-06-19 17:07:03 +00:00
|
|
|
final Collection c;
|
2022-10-19 11:16:27 +00:00
|
|
|
final double sideOfThumbnail;
|
2023-03-07 09:25:23 +00:00
|
|
|
final bool showFileCount;
|
2023-06-24 16:27:34 +00:00
|
|
|
final String tag;
|
2023-06-23 10:11:40 +00:00
|
|
|
|
|
|
|
const AlbumRowItemWidget(
|
2022-10-19 11:16:27 +00:00
|
|
|
this.c,
|
|
|
|
this.sideOfThumbnail, {
|
2023-06-23 10:11:40 +00:00
|
|
|
super.key,
|
2023-03-07 09:25:23 +00:00
|
|
|
this.showFileCount = true,
|
2023-06-24 16:27:34 +00:00
|
|
|
this.tag = "",
|
2023-06-23 10:11:40 +00:00
|
|
|
});
|
2022-08-11 12:28:06 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-06-23 13:23:43 +00:00
|
|
|
final bool isOwner = c.isOwner(Configuration.instance.getUserID()!);
|
2023-06-24 16:27:34 +00:00
|
|
|
final String tagPrefix = (isOwner ? "collection" : "shared_collection")
|
|
|
|
+ tag;
|
2022-10-19 11:16:27 +00:00
|
|
|
final enteTextTheme = getEnteTextTheme(context);
|
2022-08-11 12:28:06 +00:00
|
|
|
return GestureDetector(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
2022-11-17 05:32:24 +00:00
|
|
|
Stack(
|
|
|
|
children: [
|
|
|
|
ClipRRect(
|
2022-11-21 12:07:24 +00:00
|
|
|
borderRadius: BorderRadius.circular(1),
|
2022-11-17 05:32:24 +00:00
|
|
|
child: SizedBox(
|
|
|
|
height: sideOfThumbnail,
|
|
|
|
width: sideOfThumbnail,
|
2023-06-23 10:11:40 +00:00
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
FutureBuilder<File?>(
|
|
|
|
future: CollectionsService.instance.getCover(c),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
final thumbnail = snapshot.data!;
|
|
|
|
final String heroTag = tagPrefix + thumbnail.tag;
|
|
|
|
return Hero(
|
|
|
|
tag: heroTag,
|
|
|
|
child: ThumbnailWidget(
|
|
|
|
thumbnail,
|
2023-06-23 13:23:43 +00:00
|
|
|
shouldShowArchiveStatus: isOwner
|
|
|
|
? c.isArchived()
|
|
|
|
: c.hasShareeArchived(),
|
2023-06-23 10:11:40 +00:00
|
|
|
showFavForAlbumOnly: true,
|
|
|
|
shouldShowSyncStatus: false,
|
|
|
|
key: Key(heroTag),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return const NoThumbnailWidget();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2023-06-24 15:05:46 +00:00
|
|
|
if (isOwner && (c.hasSharees || c.hasLink))
|
|
|
|
if (c.hasSharees)
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: AlbumSharesIcons(
|
|
|
|
sharees: c.getSharees(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (isOwner && c.hasLink)
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.topRight,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 4.0,
|
|
|
|
left: 10.0,
|
|
|
|
right: 10.0,
|
|
|
|
),
|
|
|
|
child: c.publicURLs!.first!.isExpired
|
|
|
|
? const Icon(
|
|
|
|
Icons.link,
|
|
|
|
color: warning500,
|
|
|
|
)
|
|
|
|
: const Icon(
|
|
|
|
Icons.link,
|
|
|
|
color: strokeBaseDark,
|
|
|
|
),
|
|
|
|
),
|
2023-06-24 13:57:57 +00:00
|
|
|
),
|
2023-06-23 13:23:43 +00:00
|
|
|
if (!isOwner)
|
2023-06-23 10:11:40 +00:00
|
|
|
Align(
|
|
|
|
alignment: Alignment.bottomRight,
|
|
|
|
child: Padding(
|
|
|
|
padding:
|
|
|
|
const EdgeInsets.only(right: 8.0, bottom: 8.0),
|
|
|
|
child: UserAvatarWidget(
|
|
|
|
c.owner!,
|
|
|
|
thumbnailView: true,
|
|
|
|
),
|
2023-06-19 17:07:03 +00:00
|
|
|
),
|
2023-06-23 10:11:40 +00:00
|
|
|
),
|
|
|
|
],
|
2022-11-17 05:32:24 +00:00
|
|
|
),
|
|
|
|
),
|
2022-08-11 12:28:06 +00:00
|
|
|
),
|
2022-11-17 05:32:24 +00:00
|
|
|
],
|
2022-08-11 12:28:06 +00:00
|
|
|
),
|
2023-06-23 07:52:37 +00:00
|
|
|
const SizedBox(height: 4),
|
2023-06-23 09:39:41 +00:00
|
|
|
SizedBox(
|
|
|
|
width: sideOfThumbnail,
|
2023-06-23 09:53:42 +00:00
|
|
|
child: FutureBuilder<int>(
|
|
|
|
future: showFileCount
|
|
|
|
? FilesDB.instance.collectionFileCount(c.id)
|
|
|
|
: Future.value(0),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasData && snapshot.data! > 0) {
|
|
|
|
final String textCount = NumberFormat().format(snapshot.data);
|
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
maxWidth:
|
|
|
|
sideOfThumbnail - ((textCount.length + 3) * 10),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
c.displayName,
|
|
|
|
style: enteTextTheme.small,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: enteTextTheme.smallMuted,
|
|
|
|
children: [
|
|
|
|
TextSpan(text: ' \u2022 $textCount'),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Text(
|
|
|
|
c.displayName,
|
|
|
|
style: enteTextTheme.small,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2023-06-23 09:39:41 +00:00
|
|
|
),
|
2022-08-11 12:28:06 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-06-19 17:07:03 +00:00
|
|
|
onTap: () async {
|
|
|
|
final thumbnail = await CollectionsService.instance.getCover(c);
|
2022-12-15 11:24:51 +00:00
|
|
|
routeToPage(
|
|
|
|
context,
|
|
|
|
CollectionPage(
|
2023-06-19 17:07:03 +00:00
|
|
|
CollectionWithThumbnail(c, thumbnail),
|
|
|
|
tagPrefix: tagPrefix,
|
2023-06-23 13:23:43 +00:00
|
|
|
appBarType: isOwner
|
|
|
|
? (c.type == CollectionType.favorites
|
|
|
|
? GalleryType.favorite
|
|
|
|
: GalleryType.ownedCollection)
|
|
|
|
: GalleryType.sharedCollection,
|
2022-12-15 11:24:51 +00:00
|
|
|
),
|
|
|
|
);
|
2022-08-11 12:28:06 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|