优化日历模态框,添加过去日期检查,调整今天和过去日期的样式

This commit is contained in:
yuchenglong
2026-01-12 17:58:08 +08:00
parent c1990203ed
commit 15fed264bb

View File

@@ -155,8 +155,17 @@ export function CalendarModal({
date.getMonth() === selectedDate.getMonth() && date.getMonth() === selectedDate.getMonth() &&
date.getFullYear() === selectedDate.getFullYear(); date.getFullYear() === selectedDate.getFullYear();
const isToday = const isToday = today.toDateString() === date.toDateString();
new Date().toDateString() === date.toDateString();
// Check if date is in the past (before today)
const isPast =
!isToday &&
date <
new Date(
today.getFullYear(),
today.getMonth(),
today.getDate()
);
return ( return (
<Pressable <Pressable
@@ -173,6 +182,8 @@ export function CalendarModal({
<ThemedText <ThemedText
style={[ style={[
styles.dayText, styles.dayText,
{ color: textColor },
isPast && { color: subTextColor, opacity: 0.5 },
isSelected && { color: "#fff", fontWeight: "bold" }, isSelected && { color: "#fff", fontWeight: "bold" },
!isSelected && isToday && { color: Colors[theme].tint }, !isSelected && isToday && { color: Colors[theme].tint },
]} ]}