import 'package:flutter/material.dart'; import '../../theme/design_tokens.dart'; class DivinationSummaryTagData { const DivinationSummaryTagData({ required this.label, required this.background, required this.foreground, }); final String label; final Color background; final Color foreground; } class DivinationSummaryCard extends StatelessWidget { const DivinationSummaryCard({ super.key, required this.question, required this.leading, required this.tags, this.leadingBackgroundColor, this.onTap, this.questionMaxLines = 1, }); final String question; final Widget leading; final List tags; final Color? leadingBackgroundColor; final VoidCallback? onTap; final int questionMaxLines; @override Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; final card = Card( margin: EdgeInsets.zero, color: colors.surface, elevation: 2, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppRadius.md), ), child: Padding( padding: const EdgeInsets.all(AppSpacing.lg), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( width: 40, height: 40, decoration: BoxDecoration( color: leadingBackgroundColor ?? colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(AppRadius.sm), ), child: Center(child: leading), ), const SizedBox(width: AppSpacing.md), Expanded( child: Text( question, maxLines: questionMaxLines, overflow: TextOverflow.ellipsis, style: Theme.of(context).textTheme.titleMedium, ), ), ], ), if (tags.isNotEmpty) ...[ const SizedBox(height: AppSpacing.sm), Wrap( spacing: AppSpacing.sm, runSpacing: AppSpacing.sm, children: tags .map( (tag) => _DivinationSummaryTag( label: tag.label, background: tag.background, foreground: tag.foreground, ), ) .toList(growable: false), ), ], ], ), ), ); if (onTap == null) { return SizedBox(width: double.infinity, child: card); } return SizedBox( width: double.infinity, child: Material( color: colors.surface.withValues(alpha: 0), child: InkWell( borderRadius: BorderRadius.circular(AppRadius.md), onTap: onTap, child: card, ), ), ); } } class _DivinationSummaryTag extends StatelessWidget { const _DivinationSummaryTag({ required this.label, required this.background, required this.foreground, }); final String label; final Color background; final Color foreground; @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.symmetric( horizontal: AppSpacing.sm, vertical: AppSpacing.xs, ), decoration: BoxDecoration( color: background, borderRadius: BorderRadius.circular(AppRadius.sm), ), child: Text( label, style: Theme.of( context, ).textTheme.bodySmall?.copyWith(color: foreground), ), ); } }