78 lines
2.0 KiB
Dart
78 lines
2.0 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 colors = theme.colorScheme;
|
|
final radius = theme.radius.resolve(TextDirection.ltr);
|
|
final decoration = BoxDecoration(
|
|
color: color == YantingColors.card ? colors.card : color,
|
|
borderRadius: radius,
|
|
border: Border.all(
|
|
color: borderColor == YantingColors.border
|
|
? colors.border
|
|
: borderColor,
|
|
),
|
|
);
|
|
if (onTap == null) {
|
|
return DecoratedBox(
|
|
decoration: decoration,
|
|
child: Padding(padding: padding, child: child),
|
|
);
|
|
}
|
|
|
|
return Material(
|
|
color: Colors.transparent,
|
|
borderRadius: radius,
|
|
child: Ink(
|
|
decoration: decoration,
|
|
child: InkWell(
|
|
borderRadius: radius,
|
|
splashColor: colors.mutedForeground.withValues(alpha: 0.08),
|
|
highlightColor: colors.mutedForeground.withValues(alpha: 0.04),
|
|
onTap: onTap,
|
|
child: Padding(padding: padding, child: child),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HeroReportCard extends StatelessWidget {
|
|
const HeroReportCard({required this.child, this.onTap, super.key});
|
|
|
|
final Widget child;
|
|
final VoidCallback? onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colors = ShadTheme.of(context).colorScheme;
|
|
return AppCard(
|
|
onTap: onTap,
|
|
color: colors.brandSoft,
|
|
borderColor: colors.brandSoftBorder,
|
|
padding: const EdgeInsets.all(YantingSpacing.cardPadding),
|
|
child: child,
|
|
);
|
|
}
|
|
}
|