2023-06-06 16:43:32 +00:00
|
|
|
import "package:flutter/material.dart";
|
|
|
|
import "package:photos/generated/l10n.dart";
|
2023-08-25 04:39:30 +00:00
|
|
|
import 'package:photos/models/collection/collection.dart';
|
|
|
|
import 'package:photos/models/collection/collection_items.dart';
|
|
|
|
import 'package:photos/models/file/file.dart';
|
2023-06-19 05:35:30 +00:00
|
|
|
import "package:photos/services/collections_service.dart";
|
2023-06-24 16:00:07 +00:00
|
|
|
import "package:photos/theme/colors.dart";
|
|
|
|
import "package:photos/theme/ente_theme.dart";
|
|
|
|
import "package:photos/ui/common/loading_widget.dart";
|
2023-06-14 08:45:11 +00:00
|
|
|
import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";
|
2023-06-06 16:43:32 +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-24 15:29:23 +00:00
|
|
|
class QuickLinkAlbumItem extends StatelessWidget {
|
2023-06-19 10:57:53 +00:00
|
|
|
final Collection c;
|
2023-06-19 05:49:39 +00:00
|
|
|
static const heroTagPrefix = "outgoing_collection";
|
2023-06-06 16:43:32 +00:00
|
|
|
|
2023-06-24 15:29:23 +00:00
|
|
|
const QuickLinkAlbumItem({super.key, required this.c});
|
2023-06-06 16:43:32 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
child: Container(
|
2023-07-19 12:45:20 +00:00
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
2023-06-06 16:43:32 +00:00
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(1),
|
|
|
|
child: SizedBox(
|
|
|
|
height: 60,
|
|
|
|
width: 60,
|
2023-08-24 16:56:24 +00:00
|
|
|
child: FutureBuilder<EnteFile?>(
|
2023-06-19 10:57:53 +00:00
|
|
|
future: CollectionsService.instance.getCover(c),
|
2023-06-19 05:35:30 +00:00
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasData) {
|
2023-06-19 05:49:39 +00:00
|
|
|
final String heroTag = heroTagPrefix + snapshot.data!.tag;
|
2023-06-19 05:35:30 +00:00
|
|
|
return Hero(
|
2023-06-14 08:45:11 +00:00
|
|
|
tag: heroTag,
|
|
|
|
child: ThumbnailWidget(
|
2023-06-19 05:35:30 +00:00
|
|
|
snapshot.data!,
|
2023-06-14 08:45:11 +00:00
|
|
|
key: ValueKey(heroTag),
|
|
|
|
),
|
2023-06-19 05:35:30 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return const NoThumbnailWidget();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2023-06-06 16:43:32 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const Padding(padding: EdgeInsets.all(8)),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2023-06-24 16:00:07 +00:00
|
|
|
Text(
|
|
|
|
c.displayName,
|
|
|
|
style: getEnteTextTheme(context).body,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 4, 0, 0),
|
|
|
|
child: FutureBuilder<int>(
|
2023-07-06 07:59:31 +00:00
|
|
|
future: CollectionsService.instance.getFileCount(c),
|
2023-06-24 16:00:07 +00:00
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (!snapshot.hasError) {
|
|
|
|
// final String textCount = NumberFormat().format(snapshot.data);
|
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
(!snapshot.hasData)
|
|
|
|
? const Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 16.0,
|
|
|
|
),
|
|
|
|
child: EnteLoadingWidget(size: 10),
|
|
|
|
)
|
|
|
|
: Padding(
|
|
|
|
padding:
|
|
|
|
const EdgeInsets.only(right: 8.0),
|
|
|
|
child: Text(
|
|
|
|
S.of(context).itemCount(snapshot.data!),
|
|
|
|
style: getEnteTextTheme(context)
|
|
|
|
.smallMuted,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
c.hasLink
|
|
|
|
? (c.publicURLs!.first!.isExpired
|
|
|
|
? const Icon(
|
|
|
|
Icons.link_outlined,
|
|
|
|
color: warning500,
|
|
|
|
)
|
|
|
|
: Icon(
|
|
|
|
Icons.link_outlined,
|
|
|
|
color: getEnteColorScheme(context)
|
|
|
|
.strokeMuted,
|
|
|
|
))
|
|
|
|
: const SizedBox.shrink(),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
} else if (snapshot.hasError) {
|
|
|
|
return Text(S.of(context).somethingWentWrong);
|
|
|
|
} else {
|
|
|
|
return const EnteLoadingWidget(size: 10);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2023-06-06 16:43:32 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-06-19 10:57:53 +00:00
|
|
|
onTap: () async {
|
|
|
|
final thumbnail = await CollectionsService.instance.getCover(c);
|
2023-06-06 16:43:32 +00:00
|
|
|
final page = CollectionPage(
|
2023-06-19 10:57:53 +00:00
|
|
|
CollectionWithThumbnail(
|
|
|
|
c,
|
|
|
|
thumbnail,
|
|
|
|
),
|
2023-06-19 05:49:39 +00:00
|
|
|
tagPrefix: heroTagPrefix,
|
2023-06-06 16:43:32 +00:00
|
|
|
);
|
2023-12-21 07:34:06 +00:00
|
|
|
// ignore: unawaited_futures
|
2023-06-06 16:43:32 +00:00
|
|
|
routeToPage(context, page);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|