import 'package:flutter/material.dart'; import '../../models/routine.dart'; class RoutineCard extends StatelessWidget { final Routine routine; final VoidCallback? onTap; final VoidCallback? onComplete; const RoutineCard({ super.key, required this.routine, this.onTap, this.onComplete, }); @override Widget build(BuildContext context) { return Card( margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: InkWell( onTap: onTap, borderRadius: BorderRadius.circular(12), child: Padding( padding: const EdgeInsets.all(16.0), child: Row( children: [ // Icon Container( width: 56, height: 56, decoration: BoxDecoration( color: _getCategoryColor().withOpacity(0.1), borderRadius: BorderRadius.circular(16), ), child: Center( child: Text( routine.category.icon, style: const TextStyle(fontSize: 28), ), ), ), const SizedBox(width: 16), // Info Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( routine.name, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w600, ), ), const SizedBox(height: 4), Text( '${routine.schedule.time} ยท ${routine.category.displayName}', style: TextStyle( fontSize: 13, color: Colors.grey[600], ), ), if (routine.description != null && routine.description!.isNotEmpty) Padding( padding: const EdgeInsets.only(top: 4), child: Text( routine.description!, style: TextStyle( fontSize: 12, color: Colors.grey[500], ), maxLines: 1, overflow: TextOverflow.ellipsis, ), ), ], ), ), // Complete button if (onComplete != null) IconButton( onPressed: onComplete, icon: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: _getCategoryColor().withOpacity(0.1), shape: BoxShape.circle, ), child: Icon( Icons.check, color: _getCategoryColor(), ), ), ), ], ), ), ), ); } Color _getCategoryColor() { return routine.category.color; } } // Extension for category colors extension CategoryColor on RoutineCategory { Color get color { switch (this) { case RoutineCategory.medication: return const Color(0xFFE74C3C); case RoutineCategory.vitamin: return const Color(0xFFF39C12); case RoutineCategory.appointment: return const Color(0xFF9B59B6); case RoutineCategory.sleep: return const Color(0xFF8E44AD); case RoutineCategory.food: return const Color(0xFFE67E22); case RoutineCategory.hydration: return const Color(0xFF3498DB); case RoutineCategory.exercise: return const Color(0xFF27AE60); case RoutineCategory.hygiene: return const Color(0xFF1ABC9C); case RoutineCategory.selfCare: return const Color(0xFF16A085); case RoutineCategory.custom: return const Color(0xFF4A90E2); } } }