优化日历模态框,添加过去日期检查,调整今天和过去日期的样式
This commit is contained in:
@@ -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 },
|
||||||
]}
|
]}
|
||||||
|
|||||||
Reference in New Issue
Block a user