feat:更新主题色适配
This commit is contained in:
@@ -146,42 +146,47 @@ class _RecipeCalendarState extends State<RecipeCalendar> {
|
||||
bool isToday,
|
||||
FoodProvider provider,
|
||||
) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
// 检查当前日期是否在需要显示红点的列表中
|
||||
bool shouldShowRedDot = provider.recordList.any(
|
||||
(item) => item.date == formatDateTime(day),
|
||||
);
|
||||
|
||||
late Color boxColor;
|
||||
if (isSelected) {
|
||||
boxColor = colors.secondary;
|
||||
} else {
|
||||
boxColor = isToday ? colors.primary : Colors.transparent;
|
||||
}
|
||||
|
||||
late Color textColor;
|
||||
if (isSelected) {
|
||||
textColor = colors.surface;
|
||||
} else {
|
||||
textColor = isToday ? colors.surface : colors.onSurface;
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
margin: EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
isSelected
|
||||
? Theme.of(context).primaryColor
|
||||
: isToday
|
||||
? Colors.grey[300]
|
||||
: Colors.transparent,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
decoration: BoxDecoration(color: boxColor, shape: BoxShape.circle),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
// 日期数字
|
||||
Text(
|
||||
day.day.toString(),
|
||||
style: TextStyle(color: isSelected ? Colors.white : Colors.black),
|
||||
),
|
||||
// 底部红点 - 只在指定日期显示
|
||||
// 日期数字始终居中
|
||||
Text(day.day.toString(), style: TextStyle(color: textColor)),
|
||||
|
||||
// 红点
|
||||
if (shouldShowRedDot)
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 2),
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
Align(
|
||||
alignment: Alignment(0, 0.8),
|
||||
child: Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user