2023-06-27 23:00:20 +02:00
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-11-20 16:58:03 +02:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2023-06-27 23:00:20 +02:00
|
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/store.dart';
|
|
|
|
import 'package:immich_mobile/shared/ui/immich_image.dart';
|
|
|
|
import 'package:immich_mobile/utils/image_url_builder.dart';
|
|
|
|
import 'package:openapi/api.dart';
|
|
|
|
|
|
|
|
class MemoryCard extends HookConsumerWidget {
|
|
|
|
final Asset asset;
|
|
|
|
final void Function() onTap;
|
|
|
|
final void Function() onClose;
|
|
|
|
final String title;
|
|
|
|
final String? rightCornerText;
|
|
|
|
final bool showTitle;
|
|
|
|
|
|
|
|
const MemoryCard({
|
|
|
|
required this.asset,
|
|
|
|
required this.onTap,
|
|
|
|
required this.onClose,
|
|
|
|
required this.title,
|
|
|
|
required this.showTitle,
|
|
|
|
this.rightCornerText,
|
|
|
|
super.key,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final authToken = 'Bearer ${Store.get(StoreKey.accessToken)}';
|
|
|
|
|
|
|
|
buildTitle() {
|
|
|
|
return Text(
|
|
|
|
title,
|
2023-11-20 16:58:03 +02:00
|
|
|
style: context.textTheme.headlineMedium?.copyWith(
|
2023-06-27 23:00:20 +02:00
|
|
|
color: Colors.white,
|
2023-11-20 16:58:03 +02:00
|
|
|
fontWeight: FontWeight.w500,
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Card(
|
|
|
|
color: Colors.black,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(25.0),
|
|
|
|
side: const BorderSide(
|
|
|
|
color: Colors.black,
|
|
|
|
width: 1.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
2023-06-30 20:49:17 +02:00
|
|
|
ImageFiltered(
|
|
|
|
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: DecorationImage(
|
|
|
|
image: CachedNetworkImageProvider(
|
|
|
|
getThumbnailUrl(
|
|
|
|
asset,
|
|
|
|
),
|
|
|
|
cacheKey: getThumbnailCacheKey(
|
|
|
|
asset,
|
|
|
|
),
|
|
|
|
headers: {"Authorization": authToken},
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
2023-06-30 20:49:17 +02:00
|
|
|
fit: BoxFit.cover,
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
|
|
|
),
|
2023-06-30 20:49:17 +02:00
|
|
|
child: Container(color: Colors.black.withOpacity(0.2)),
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: onTap,
|
|
|
|
child: ImmichImage(
|
|
|
|
asset,
|
|
|
|
fit: BoxFit.fitWidth,
|
|
|
|
height: double.infinity,
|
|
|
|
width: double.infinity,
|
|
|
|
type: ThumbnailFormat.JPEG,
|
2024-01-30 17:24:31 +02:00
|
|
|
preferredLocalAssetSize: 2048,
|
2023-06-27 23:00:20 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
top: 2.0,
|
|
|
|
left: 2.0,
|
|
|
|
child: IconButton(
|
|
|
|
onPressed: onClose,
|
|
|
|
icon: const Icon(Icons.close_rounded),
|
|
|
|
color: Colors.grey[400],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
right: 18.0,
|
|
|
|
top: 18.0,
|
|
|
|
child: Text(
|
|
|
|
rightCornerText ?? "",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.grey[200],
|
|
|
|
fontSize: 12.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (showTitle)
|
|
|
|
Positioned(
|
|
|
|
left: 18.0,
|
|
|
|
bottom: 18.0,
|
|
|
|
child: buildTitle(),
|
2023-08-19 00:52:40 +02:00
|
|
|
),
|
2023-06-27 23:00:20 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|