40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme/colors.dart';
|
|
|
|
class CategoryIcon extends StatelessWidget {
|
|
final String emoji;
|
|
final String category;
|
|
final double size;
|
|
|
|
const CategoryIcon({
|
|
super.key,
|
|
required this.emoji,
|
|
required this.category,
|
|
this.size = 40,
|
|
});
|
|
|
|
Color _bgColor() {
|
|
switch (category) {
|
|
case '餐饮': return AppColors.brand.withOpacity(0.08);
|
|
case '交通': return AppColors.brandLight.withOpacity(0.08);
|
|
case '购物': return AppColors.brand.withOpacity(0.06);
|
|
case '医疗': return AppColors.expense.withOpacity(0.06);
|
|
case '工资': return AppColors.income.withOpacity(0.08);
|
|
default: return AppColors.textSecondary.withOpacity(0.08);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: size,
|
|
height: size,
|
|
decoration: BoxDecoration(
|
|
color: _bgColor(),
|
|
shape: BoxShape.circle,
|
|
boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 4, offset: Offset(0, 2))],
|
|
),
|
|
child: Center(child: Text(emoji, style: TextStyle(fontSize: size * 0.45))),
|
|
);
|
|
}
|
|
} |