import 'package:flutter/material.dart'; import 'package:water_management_system/utils/constants.dart'; class CustomCard extends StatelessWidget { final String? title; final String? subtitle; final Widget? trailing; final List? children; final Color? color; final IconData? icon; final String? value; const CustomCard({ super.key, this.title, this.subtitle, this.trailing, this.children, this.color, this.icon, this.value, }); @override Widget build(BuildContext context) { if (title != null && value != null && icon != null) { return Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: color?.withOpacity(0.1) ?? Colors.white, borderRadius: BorderRadius.circular(8), border: Border.all(color: color?.withOpacity(0.3) ?? Colors.grey[300]!), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Icon(icon, color: color ?? AppConstants.primaryColor, size: 24), const SizedBox(height: 8), Text(title!, style: TextStyle(fontSize: 12, color: Colors.grey[600])), const SizedBox(height: 4), Text(value!, style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: color ?? AppConstants.primaryColor)), ], ), ); } return Card( margin: const EdgeInsets.symmetric(vertical: 4), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), elevation: 2, child: Padding( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (title != null || trailing != null) Row(children: [ if (title != null) Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(title!, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16)), if (subtitle != null) Text(subtitle!, style: TextStyle(color: Colors.grey[600], fontSize: 12)), ])), if (trailing != null) trailing!, ]), if (children != null) ...children!, ], ), ), ); } }