Files
yanting/lib/widgets/app_card.dart
T
2026-06-05 15:04:39 +08:00

69 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../theme/yanting_tokens.dart';
class AppCard extends StatelessWidget {
const AppCard({
required this.child,
this.onTap,
this.padding = const EdgeInsets.all(YantingSpacing.cardPadding),
this.color = YantingColors.card,
this.borderColor = YantingColors.border,
super.key,
});
final Widget child;
final VoidCallback? onTap;
final EdgeInsetsGeometry padding;
final Color color;
final Color borderColor;
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final radius = BorderRadius.circular(YantingRadius.xl);
final content = ShadCard(
padding: padding,
backgroundColor: color,
radius: radius,
border: ShadBorder.all(color: borderColor),
shadows: const [],
child: child,
);
if (onTap == null) return content;
return Material(
color: Colors.transparent,
borderRadius: radius,
child: InkWell(
borderRadius: radius,
splashColor: theme.colorScheme.mutedForeground.withValues(alpha: 0.08),
highlightColor: theme.colorScheme.mutedForeground.withValues(
alpha: 0.04,
),
onTap: onTap,
child: content,
),
);
}
}
class HeroReportCard extends StatelessWidget {
const HeroReportCard({required this.child, this.onTap, super.key});
final Widget child;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
return AppCard(
onTap: onTap,
color: YantingColors.brandSoft,
borderColor: YantingColors.brandSoftBorder,
padding: const EdgeInsets.all(YantingSpacing.cardPadding),
child: child,
);
}
}