2022-04-02 19:31:53 +02:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
|
|
|
import 'package:immich_mobile/constants/hive_box.dart';
|
|
|
|
|
|
|
|
class ThumbnailWithInfo extends StatelessWidget {
|
2022-07-13 14:23:48 +02:00
|
|
|
const ThumbnailWithInfo({
|
|
|
|
Key? key,
|
|
|
|
required this.textInfo,
|
2023-02-13 14:29:45 +02:00
|
|
|
this.imageUrl,
|
|
|
|
this.noImageIcon,
|
2022-07-13 14:23:48 +02:00
|
|
|
required this.onTap,
|
|
|
|
}) : super(key: key);
|
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;
|
2022-04-02 19:31:53 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var box = Hive.box(userInfoBox);
|
2023-02-13 14:29:45 +02:00
|
|
|
var isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
var textAndIconColor = isDarkMode ? Colors.grey[100] : Colors.grey[700];
|
2022-04-02 19:31:53 +02:00
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
onTap();
|
|
|
|
},
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
child: SizedBox(
|
2022-08-16 01:53:30 +02:00
|
|
|
width: MediaQuery.of(context).size.width / 3,
|
2022-04-02 19:31:53 +02:00
|
|
|
child: Stack(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
children: [
|
|
|
|
Container(
|
2023-02-13 14:29:45 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(25),
|
|
|
|
color: isDarkMode ? Colors.grey[900] : Colors.grey[100],
|
|
|
|
border: Border.all(
|
|
|
|
color: isDarkMode ? Colors.grey[800]! : Colors.grey[400]!,
|
|
|
|
width: 1,
|
2022-04-02 19:31:53 +02:00
|
|
|
),
|
|
|
|
),
|
2023-02-13 14:29:45 +02:00
|
|
|
child: imageUrl != null
|
|
|
|
? ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
child: CachedNetworkImage(
|
|
|
|
width: 250,
|
|
|
|
height: 250,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
imageUrl: imageUrl!,
|
|
|
|
httpHeaders: {
|
|
|
|
"Authorization": "Bearer ${box.get(accessTokenKey)}"
|
|
|
|
},
|
2023-03-15 23:29:07 +02:00
|
|
|
errorWidget: (context, url, error) =>
|
|
|
|
const Icon(Icons.image_not_supported_outlined),
|
2023-02-13 14:29:45 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
: Center(
|
|
|
|
child: Icon(
|
|
|
|
noImageIcon ?? Icons.not_listed_location,
|
|
|
|
color: textAndIconColor,
|
|
|
|
),
|
|
|
|
),
|
2022-04-02 19:31:53 +02:00
|
|
|
),
|
|
|
|
Positioned(
|
2023-02-13 14:29:45 +02:00
|
|
|
bottom: 12,
|
|
|
|
left: 14,
|
2022-04-02 19:31:53 +02:00
|
|
|
child: SizedBox(
|
|
|
|
width: MediaQuery.of(context).size.width / 3,
|
|
|
|
child: Text(
|
2022-07-07 20:40:54 +02:00
|
|
|
textInfo,
|
2022-04-02 19:31:53 +02:00
|
|
|
style: const TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontWeight: FontWeight.bold,
|
2023-02-13 14:29:45 +02:00
|
|
|
fontSize: 12,
|
2022-04-02 19:31:53 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|