2022-04-02 19:31:53 +02:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2023-11-09 18:19:53 +02:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2023-03-23 03:36:44 +02:00
|
|
|
import 'package:immich_mobile/shared/models/store.dart';
|
2023-11-09 18:19:53 +02:00
|
|
|
import 'package:immich_mobile/extensions/string_extensions.dart';
|
2022-04-02 19:31:53 +02:00
|
|
|
|
2023-03-28 17:34:06 +02:00
|
|
|
// ignore: must_be_immutable
|
2022-04-02 19:31:53 +02:00
|
|
|
class ThumbnailWithInfo extends StatelessWidget {
|
2023-03-28 17:34:06 +02:00
|
|
|
ThumbnailWithInfo({
|
2024-01-27 18:14:32 +02:00
|
|
|
super.key,
|
2022-07-13 14:23:48 +02:00
|
|
|
required this.textInfo,
|
2023-02-13 14:29:45 +02:00
|
|
|
this.imageUrl,
|
|
|
|
this.noImageIcon,
|
2023-03-28 17:34:06 +02:00
|
|
|
this.borderRadius = 10,
|
2022-07-13 14:23:48 +02:00
|
|
|
required this.onTap,
|
2024-01-27 18:14:32 +02:00
|
|
|
});
|
2022-04-02 19:31:53 +02:00
|
|
|
|
|
|
|
final String textInfo;
|
2023-02-13 14:29:45 +02:00
|
|
|
final String? imageUrl;
|
2022-04-02 19:31:53 +02:00
|
|
|
final Function onTap;
|
2023-02-13 14:29:45 +02:00
|
|
|
final IconData? noImageIcon;
|
2023-03-28 17:34:06 +02:00
|
|
|
double borderRadius;
|
2022-04-02 19:31:53 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-11-09 18:19:53 +02:00
|
|
|
var textAndIconColor =
|
|
|
|
context.isDarkTheme ? Colors.grey[100] : Colors.grey[700];
|
2022-04-02 19:31:53 +02:00
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
onTap();
|
|
|
|
},
|
2023-03-23 17:08:14 +02:00
|
|
|
child: Stack(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
2023-03-28 17:34:06 +02:00
|
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
2023-11-09 18:19:53 +02:00
|
|
|
color: context.isDarkTheme ? Colors.grey[900] : Colors.grey[100],
|
2023-03-23 17:08:14 +02:00
|
|
|
),
|
|
|
|
child: imageUrl != null
|
|
|
|
? ClipRRect(
|
2023-03-28 17:34:06 +02:00
|
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
2023-03-23 17:08:14 +02:00
|
|
|
child: CachedNetworkImage(
|
|
|
|
width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
imageUrl: imageUrl!,
|
|
|
|
httpHeaders: {
|
2024-02-04 22:35:13 +02:00
|
|
|
"x-immich-user-token": Store.get(StoreKey.accessToken),
|
2023-03-23 17:08:14 +02:00
|
|
|
},
|
|
|
|
errorWidget: (context, url, error) =>
|
|
|
|
const Icon(Icons.image_not_supported_outlined),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Center(
|
|
|
|
child: Icon(
|
|
|
|
noImageIcon ?? Icons.not_listed_location,
|
|
|
|
color: textAndIconColor,
|
2022-04-02 19:31:53 +02:00
|
|
|
),
|
|
|
|
),
|
2023-03-23 17:08:14 +02:00
|
|
|
),
|
2023-03-28 17:34:06 +02:00
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
|
|
|
color: Colors.white,
|
|
|
|
gradient: LinearGradient(
|
|
|
|
begin: FractionalOffset.topCenter,
|
|
|
|
end: FractionalOffset.bottomCenter,
|
|
|
|
colors: [
|
|
|
|
Colors.grey.withOpacity(0.0),
|
|
|
|
textInfo == ''
|
|
|
|
? Colors.black.withOpacity(0.1)
|
|
|
|
: Colors.black.withOpacity(0.5),
|
|
|
|
],
|
|
|
|
stops: const [0.0, 1.0],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2023-03-23 17:08:14 +02:00
|
|
|
Positioned(
|
|
|
|
bottom: 12,
|
|
|
|
left: 14,
|
|
|
|
child: Text(
|
2023-06-27 19:26:23 +02:00
|
|
|
textInfo == '' ? textInfo : textInfo.capitalize(),
|
2023-03-23 17:08:14 +02:00
|
|
|
style: const TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontWeight: FontWeight.bold,
|
2023-03-28 17:34:06 +02:00
|
|
|
fontSize: 14,
|
2022-04-02 19:31:53 +02:00
|
|
|
),
|
2023-03-23 17:08:14 +02:00
|
|
|
),
|
2022-04-02 19:31:53 +02:00
|
|
|
),
|
2023-03-23 17:08:14 +02:00
|
|
|
],
|
2022-04-02 19:31:53 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|