优化日历模态框,添加过去日期检查,调整今天和过去日期的样式
This commit is contained in:
@@ -155,8 +155,17 @@ export function CalendarModal({
|
||||
date.getMonth() === selectedDate.getMonth() &&
|
||||
date.getFullYear() === selectedDate.getFullYear();
|
||||
|
||||
const isToday =
|
||||
new Date().toDateString() === date.toDateString();
|
||||
const isToday = today.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 (
|
||||
<Pressable
|
||||
@@ -173,6 +182,8 @@ export function CalendarModal({
|
||||
<ThemedText
|
||||
style={[
|
||||
styles.dayText,
|
||||
{ color: textColor },
|
||||
isPast && { color: subTextColor, opacity: 0.5 },
|
||||
isSelected && { color: "#fff", fontWeight: "bold" },
|
||||
!isSelected && isToday && { color: Colors[theme].tint },
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user