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 17:19:53 +01:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2024-06-24 16:24:57 +02:00
|
|
|
import 'package:immich_mobile/widgets/search/thumbnail_with_info_container.dart';
|
2024-06-26 21:31:55 +02:00
|
|
|
import 'package:immich_mobile/services/api.service.dart';
|
2022-04-02 19:31:53 +02:00
|
|
|
|
|
|
|
class ThumbnailWithInfo extends StatelessWidget {
|
2024-06-24 16:24:57 +02:00
|
|
|
const ThumbnailWithInfo({
|
2024-01-27 17:14:32 +01:00
|
|
|
super.key,
|
2022-07-13 14:23:48 +02:00
|
|
|
required this.textInfo,
|
2023-02-13 13:29:45 +01:00
|
|
|
this.imageUrl,
|
|
|
|
this.noImageIcon,
|
2023-03-28 17:34:06 +02:00
|
|
|
this.borderRadius = 10,
|
2024-06-24 16:24:57 +02:00
|
|
|
this.onTap,
|
2024-01-27 17:14:32 +01:00
|
|
|
});
|
2022-04-02 19:31:53 +02:00
|
|
|
|
|
|
|
final String textInfo;
|
2023-02-13 13:29:45 +01:00
|
|
|
final String? imageUrl;
|
2024-06-24 16:24:57 +02:00
|
|
|
final VoidCallback? onTap;
|
2023-02-13 13:29:45 +01:00
|
|
|
final IconData? noImageIcon;
|
2024-06-24 16:24:57 +02:00
|
|
|
final double borderRadius;
|
2022-04-02 19:31:53 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-11-09 17:19:53 +01:00
|
|
|
var textAndIconColor =
|
|
|
|
context.isDarkTheme ? Colors.grey[100] : Colors.grey[700];
|
2024-06-24 16:24:57 +02:00
|
|
|
return ThumbnailWithInfoContainer(
|
|
|
|
onTap: onTap,
|
|
|
|
borderRadius: borderRadius,
|
|
|
|
label: textInfo,
|
|
|
|
child: imageUrl != null
|
|
|
|
? ClipRRect(
|
2023-03-28 17:34:06 +02:00
|
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
2024-06-24 16:24:57 +02:00
|
|
|
child: CachedNetworkImage(
|
|
|
|
width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
imageUrl: imageUrl!,
|
2024-06-26 21:31:55 +02:00
|
|
|
httpHeaders: ApiService.getRequestHeaders(),
|
2024-06-24 16:24:57 +02:00
|
|
|
errorWidget: (context, url, error) =>
|
|
|
|
const Icon(Icons.image_not_supported_outlined),
|
2023-03-28 17:34:06 +02:00
|
|
|
),
|
2024-06-24 16:24:57 +02:00
|
|
|
)
|
|
|
|
: Center(
|
|
|
|
child: Icon(
|
|
|
|
noImageIcon ?? Icons.not_listed_location,
|
|
|
|
color: textAndIconColor,
|
2022-04-02 19:31:53 +02:00
|
|
|
),
|
2023-03-23 16:08:14 +01:00
|
|
|
),
|
2022-04-02 19:31:53 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|