import 'package:flutter/material.dart'; import '../mappers/tmdb_image_url.dart'; import '../theme/app_theme.dart'; import 'app_card.dart'; import 'metadata_chip.dart'; import 'smart_image.dart'; class TmdbPosterCard extends StatelessWidget { final String title; final String? posterPath; final double? voteAverage; final String? mediaTypeLabel; final String imageBaseUrl; final double width; final VoidCallback? onTap; final Color? textColor; const TmdbPosterCard({ super.key, required this.title, required this.imageBaseUrl, required this.width, this.posterPath, this.voteAverage, this.mediaTypeLabel, this.onTap, this.textColor, }); @override Widget build(BuildContext context) { final theme = Theme.of(context); final tokens = context.appTokens; final posterUrl = TmdbImageUrl.poster(imageBaseUrl, posterPath); final chipFg = textColor?.withValues(alpha: 0.65); final chipBg = textColor?.withValues(alpha: 0.12); return SizedBox( width: width, child: AppCard( filled: false, enableHover: onTap != null, radius: tokens.radiusCard, padding: EdgeInsets.zero, onTap: onTap, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: SmartImage( url: posterUrl, fallbackIcon: Icons.movie_outlined, borderRadius: 8, ), ), const SizedBox(height: 8), Text( title, maxLines: 1, overflow: TextOverflow.ellipsis, style: theme.textTheme.bodySmall?.copyWith( fontWeight: FontWeight.w500, color: textColor, ), ), if (voteAverage != null && voteAverage! > 0) ...[ const SizedBox(height: 2), Row( children: [ MetadataChip( icon: Icons.star_rounded, label: voteAverage!.toStringAsFixed(1), foreground: tokens.ratingColor, background: chipBg, ), if (mediaTypeLabel != null) ...[ const SizedBox(width: 6), MetadataChip( label: mediaTypeLabel!, foreground: chipFg, background: chipBg, ), ], ], ), ], ], ), ), ); } }