Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/src/screens/calendarListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const CalendarListScreen = (props: Props) => {
horizontal={horizontalView}
pagingEnabled={horizontalView}
staticHeader={horizontalView}
descendingOrder={false}
/>
);
};
Expand Down
10 changes: 7 additions & 3 deletions src/calendar-list/calendarList.api.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"name": "CalendarList",
"description": "Calendar list component",
"images": [
"https://github.com/wix/react-native-calendars/blob/master/demo/assets/calendar-list.gif?raw=true"
],
"images": ["https://github.com/wix/react-native-calendars/blob/master/demo/assets/calendar-list.gif?raw=true"],
"extends": ["Calendar", "FlatList"],
"extendsLink": [
"https://github.com/wix/react-native-calendars/blob/master/src/calendar/index.tsx",
Expand Down Expand Up @@ -50,6 +48,12 @@
"type": "boolean",
"description": "Whether to enable or disable vertical / horizontal scroll indicator",
"default": "false"
},
{
"name": "descendingOrder",
"type": "boolean",
"description": "Whether to load the calendar list items in descending order (most recent month at the top)",
"default": "false"
}
]
}
5 changes: 4 additions & 1 deletion src/calendar-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export interface CalendarListProps extends CalendarProps, Omit<FlatListProps<any
showScrollIndicator?: boolean;
/** Whether to animate the auto month scroll */
animateScroll?: boolean;
/** Whether to load the calendar list items in descending order (most recent month at the top) */
descendingOrder?: boolean;
}

export interface CalendarListImperativeMethods {
Expand Down Expand Up @@ -78,6 +80,7 @@ const CalendarList = (props: CalendarListProps & ContextProp, ref: any) => {
calendarWidth = CALENDAR_WIDTH,
calendarStyle,
animateScroll = false,
descendingOrder = false,
showScrollIndicator = false,
staticHeader,
/** View props */
Expand Down Expand Up @@ -120,7 +123,7 @@ const CalendarList = (props: CalendarListProps & ContextProp, ref: any) => {
const rangeDate = initialDate.current?.clone().addMonths(i - pastScrollRange, true);
months.push(rangeDate);
}
return months;
return descendingOrder ? months.reverse() : months;
}, [pastScrollRange, futureScrollRange]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}, [descendingOrder, pastScrollRange, futureScrollRange]);


const staticHeaderStyle = useMemo(() => {
Expand Down