From 8f245f50716a5c56c5a28da031b44dc62700b237 Mon Sep 17 00:00:00 2001 From: Johan Cedborger Date: Mon, 3 Feb 2025 20:53:12 +0100 Subject: [PATCH] Added inverted prop to invert the calendar list order --- example/src/screens/calendarListScreen.tsx | 1 + src/calendar-list/calendarList.api.json | 6 ++++++ src/calendar-list/index.tsx | 7 +++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/example/src/screens/calendarListScreen.tsx b/example/src/screens/calendarListScreen.tsx index b9870cd01d..db32514515 100644 --- a/example/src/screens/calendarListScreen.tsx +++ b/example/src/screens/calendarListScreen.tsx @@ -54,6 +54,7 @@ const CalendarListScreen = (props: Props) => { horizontal={horizontalView} pagingEnabled={horizontalView} staticHeader={horizontalView} + inverted={false} /> ); }; diff --git a/src/calendar-list/calendarList.api.json b/src/calendar-list/calendarList.api.json index 4df8051322..d40351f16a 100644 --- a/src/calendar-list/calendarList.api.json +++ b/src/calendar-list/calendarList.api.json @@ -50,6 +50,12 @@ "type": "boolean", "description": "Whether to enable or disable vertical / horizontal scroll indicator", "default": "false" + }, + { + "name": "inverted", + "type": "boolean", + "description": "Whether to invert the calendar", + "default": "false" } ] } diff --git a/src/calendar-list/index.tsx b/src/calendar-list/index.tsx index 458348d007..856f72dc6b 100644 --- a/src/calendar-list/index.tsx +++ b/src/calendar-list/index.tsx @@ -39,6 +39,8 @@ export interface CalendarListProps extends CalendarProps, Omit { calendarWidth = CALENDAR_WIDTH, calendarStyle, animateScroll = false, + inverted = false, showScrollIndicator = false, staticHeader, /** View props */ @@ -124,8 +127,8 @@ const CalendarList = (props: CalendarListProps & ContextProp, ref: any) => { const rangeDate = initialDate.current?.clone().addMonths(i - pastScrollRange, true); months.push(rangeDate); } - return months; - }, [pastScrollRange, futureScrollRange]); + return inverted ? months.reverse() : months; + }, [pastScrollRange, futureScrollRange, inverted]); const staticHeaderStyle = useMemo(() => { return [style.current.staticHeader, headerStyle];