diff --git a/src/expandableCalendar/WeekCalendar/index.tsx b/src/expandableCalendar/WeekCalendar/index.tsx index 8195fbf59..bbe16df4f 100644 --- a/src/expandableCalendar/WeekCalendar/index.tsx +++ b/src/expandableCalendar/WeekCalendar/index.tsx @@ -22,6 +22,7 @@ const NUM_OF_ITEMS = NUMBER_OF_PAGES * 2 + 1; // NUMBER_OF_PAGES before + NUMBER export interface WeekCalendarProps extends CalendarListProps { /** whether to have shadow/elevation for the calendar */ allowShadow?: boolean; + onWeekScroll?: (newDate: string) => {}; } /** @@ -37,6 +38,7 @@ const WeekCalendar = (props: WeekCalendarProps) => { theme, testID, markedDates, + onWeekScroll = () => {} } = props; const context = useContext(CalendarContext); const {allowShadow = true, ...calendarListProps} = props; @@ -80,6 +82,7 @@ const WeekCalendar = (props: WeekCalendarProps) => { pageIndex <= 0 ? onEndReached() : list?.current?.scrollToIndex({index: adjustedIndexFrScroll, animated: false}); } } + onWeekScroll(date) }, [date, updateSource]); const containerWidth = useMemo(() => { diff --git a/src/expandableCalendar/WeekCalendar/new.tsx b/src/expandableCalendar/WeekCalendar/new.tsx index bc68b7073..4e1b2bad9 100644 --- a/src/expandableCalendar/WeekCalendar/new.tsx +++ b/src/expandableCalendar/WeekCalendar/new.tsx @@ -24,7 +24,7 @@ const NUMBER_OF_PAGES = 50; const DEFAULT_PAGE_HEIGHT = 48; const WeekCalendar = (props: WeekCalendarProps) => { - const {current, firstDay = 0, markedDates, allowShadow = true, hideDayNames, theme, calendarWidth, calendarHeight = DEFAULT_PAGE_HEIGHT, testID} = props; + const {current, firstDay = 0, markedDates, allowShadow = true, hideDayNames, theme, calendarWidth, calendarHeight = DEFAULT_PAGE_HEIGHT, testID, onWeekScroll} = props; const context = useContext(CalendarContext); const {date, updateSource} = context; const style = useRef(styleConstructor(theme)); @@ -62,6 +62,7 @@ const WeekCalendar = (props: WeekCalendarProps) => { (pageIndex: number, _prevPage, {scrolledByUser}) => { if (scrolledByUser) { context?.setDate(items[pageIndex], UpdateSources.WEEK_SCROLL); + onWeekScroll(items[pageIndex]) } }, [items]