import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import '../../domain/entities/subscription.dart'; class SubscriptionCard extends StatelessWidget { final Subscription subscription; final bool isActive; const SubscriptionCard({super.key, required this.subscription, required this.isActive}); @override Widget build(BuildContext context) { final minPriceOption = subscription.options.isNotEmpty ? subscription.options.reduce((a, b) => a.price < b.price ? a : b) : null; final maxDaysOption = subscription.options.isNotEmpty ? subscription.options.reduce((a, b) => a.days > b.days ? a : b) : null; return Container( margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: const Color(0xFF0D143C), borderRadius: BorderRadius.circular(24), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: isActive ? MainAxisAlignment.spaceBetween : MainAxisAlignment.start, children: [ Text( subscription.title, style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold), ), if (isActive) Container( width: 100, alignment: Alignment.center, padding: EdgeInsets.all(4), decoration: BoxDecoration( color: Colors.white.withOpacity(0.3), borderRadius: BorderRadius.circular(12), // Опционально: скругление углов ), child: Text( "АКТИВНА", style: TextStyle( color: Colors.greenAccent, fontSize: 12, fontWeight: FontWeight.bold, letterSpacing: 0.5, ), ), ), ] ), const SizedBox(height: 12), Text( subscription.shortDescription, style: TextStyle(color: Colors.white.withOpacity(0.7), fontSize: 14), ), const SizedBox(height: 16), if (maxDaysOption != null) ...[ const SizedBox(height: 16), Text( "Период действия: до ${maxDaysOption.days} дней", style: const TextStyle(color: Colors.white, fontSize: 14), ), ], const SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ if (minPriceOption != null) Text( "от ${minPriceOption.pricePrint}", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500), ) else const SizedBox.shrink(), ElevatedButton( onPressed: () => context.push("/home/subscriptions/${subscription.id}"), style: ElevatedButton.styleFrom( backgroundColor: const Color(0xFF80FFD1), foregroundColor: Colors.black, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), ), child: const Text("Подробнее", style: TextStyle(fontWeight: FontWeight.bold)), ), ], ), ], ), ); } }