mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
* re-write localization service and add translation extension * Revert "re-write localization service and add translation extension" This reverts commit fdd7386020f638b92ad4f4691667d67e8c2935fc. * fix can't use context for easy_localization * fix lint * update new translate context * handle context null * revert main file * Revert "revert main file" This reverts commit 16faca46d0a36abafe41a19bb46b38fffa4940f1. * remove fix nested MaterialApp * change use t extenstion and remove translation utils * update function call similar for consistently --------- Co-authored-by: dvbthien <dvbthien@gmail.com>
130 lines
4.1 KiB
Dart
130 lines
4.1 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:immich_mobile/entities/album.entity.dart';
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
|
import 'package:immich_mobile/routing/router.dart';
|
|
import 'package:immich_mobile/services/api.service.dart';
|
|
import 'package:immich_mobile/utils/image_url_builder.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
class AlbumThumbnailListTile extends StatelessWidget {
|
|
const AlbumThumbnailListTile({
|
|
super.key,
|
|
required this.album,
|
|
this.onTap,
|
|
});
|
|
|
|
final Album album;
|
|
final void Function()? onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var cardSize = 68.0;
|
|
|
|
buildEmptyThumbnail() {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: context.isDarkTheme ? Colors.grey[800] : Colors.grey[200],
|
|
),
|
|
child: SizedBox(
|
|
height: cardSize,
|
|
width: cardSize,
|
|
child: const Center(
|
|
child: Icon(Icons.no_photography),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
buildAlbumThumbnail() {
|
|
return CachedNetworkImage(
|
|
width: cardSize,
|
|
height: cardSize,
|
|
fit: BoxFit.cover,
|
|
fadeInDuration: const Duration(milliseconds: 200),
|
|
imageUrl: getAlbumThumbnailUrl(
|
|
album,
|
|
type: AssetMediaSize.thumbnail,
|
|
),
|
|
httpHeaders: ApiService.getRequestHeaders(),
|
|
cacheKey:
|
|
getAlbumThumbNailCacheKey(album, type: AssetMediaSize.thumbnail),
|
|
errorWidget: (context, url, error) =>
|
|
const Icon(Icons.image_not_supported_outlined),
|
|
);
|
|
}
|
|
|
|
return GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: onTap ??
|
|
() {
|
|
context.pushRoute(AlbumViewerRoute(albumId: album.id));
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(bottom: 12.0),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
child: album.thumbnail.value == null
|
|
? buildEmptyThumbnail()
|
|
: buildAlbumThumbnail(),
|
|
),
|
|
Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
album.name,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
'items_count'.t(
|
|
context: context,
|
|
args: {
|
|
'count': album.assetCount,
|
|
},
|
|
),
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
if (album.shared) ...[
|
|
const Text(
|
|
' • ',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
Text(
|
|
'shared'.tr(),
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|