import 'package:flutter/material.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; import '../core/app_theme.dart'; /// 统一样式的清新卡片 class AppCard extends StatelessWidget { final Widget child; final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? margin; final VoidCallback? onTap; final Color? backgroundColor; final BorderRadius? borderRadius; const AppCard({ super.key, required this.child, this.padding = const EdgeInsets.all(AppTheme.sLg), this.margin, this.onTap, this.backgroundColor, this.borderRadius, }); @override Widget build(BuildContext context) { final theme = ShadTheme.of(context); final card = Container( margin: margin ?? const EdgeInsets.symmetric(horizontal: AppTheme.sLg, vertical: AppTheme.sSm), padding: padding, decoration: BoxDecoration( color: backgroundColor ?? theme.colorScheme.card, borderRadius: borderRadius ?? BorderRadius.circular(AppTheme.rMd), boxShadow: [AppTheme.shadowLight], ), child: child, ); if (onTap != null) { return GestureDetector( onTap: onTap, child: card, ); } return card; } }