75 lines
2.2 KiB
Dart
75 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_lucide/flutter_lucide.dart';
|
|
import '../../core/theme/app_colors.dart';
|
|
import '../../core/theme/app_spacing.dart';
|
|
import '../../core/theme/app_typography.dart';
|
|
|
|
/// Credits badge with sparkles icon - matches Pencil creditsBadge
|
|
class CreditsBadge extends StatelessWidget {
|
|
const CreditsBadge({
|
|
super.key,
|
|
required this.credits,
|
|
this.onTap,
|
|
this.foregroundColor,
|
|
this.capsuleColor,
|
|
});
|
|
|
|
final String credits;
|
|
final VoidCallback? onTap;
|
|
/// 图标与数字颜色;默认 [AppColors.primary]
|
|
final Color? foregroundColor;
|
|
/// 胶囊背景;默认 [AppColors.primaryLight]
|
|
final Color? capsuleColor;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final fg = foregroundColor ?? AppColors.primary;
|
|
final capsule = capsuleColor ?? AppColors.primaryLight;
|
|
final lightOnDarkNav = foregroundColor != null;
|
|
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.lg,
|
|
vertical: AppSpacing.sm,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: capsule,
|
|
borderRadius: BorderRadius.circular(14),
|
|
boxShadow: lightOnDarkNav
|
|
? [
|
|
BoxShadow(
|
|
color: Colors.black.withValues(alpha: 0.28),
|
|
blurRadius: 6,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
]
|
|
: [
|
|
BoxShadow(
|
|
color: AppColors.primaryShadow.withValues(alpha: 0.13),
|
|
blurRadius: 6,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(LucideIcons.sparkles, size: 16, color: fg),
|
|
const SizedBox(width: AppSpacing.sm),
|
|
Text(
|
|
credits,
|
|
style: AppTypography.bodyRegular.copyWith(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: fg,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|