-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeline calendar num of days issues #2080
Changes from 4 commits
7fd7b89
34f265a
975b27a
b6f700c
b67d914
bd4985a
d6be172
d8554ed
30487e2
9bc43c7
04b1419
ba37afb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import XDate from 'xdate'; | |
import React, {useCallback, useContext, useMemo, useRef, useState} from 'react'; | ||
import {FlatList, View, ViewToken} from 'react-native'; | ||
|
||
import {sameWeek} from '../../dateutils'; | ||
import {sameWeek, sameWeekRange} from '../../dateutils'; | ||
import {toMarkingFormat} from '../../interface'; | ||
import {DateData} from '../../types'; | ||
import styleConstructor from '../style'; | ||
|
@@ -23,6 +23,7 @@ const APPLY_ANDROID_FIX = constants.isAndroid && constants.isRTL; | |
export interface WeekCalendarProps extends CalendarListProps { | ||
/** whether to have shadow/elevation for the calendar */ | ||
allowShadow?: boolean; | ||
disableDaySelection?: boolean; | ||
yuvalsho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/** | ||
|
@@ -36,7 +37,8 @@ const WeekCalendar = (props: WeekCalendarProps) => { | |
hideDayNames, | ||
current, | ||
theme, | ||
testID | ||
testID, | ||
disableDaySelection, | ||
} = props; | ||
const context = useContext(CalendarContext); | ||
const {allowShadow = true, ...calendarListProps} = props; | ||
|
@@ -52,7 +54,10 @@ const WeekCalendar = (props: WeekCalendarProps) => { | |
|
||
useDidUpdate(() => { | ||
if (updateSource !== UpdateSources.WEEK_SCROLL) { | ||
const pageIndex = items.current.findIndex(item => sameWeek(item, date, firstDay)); | ||
const pageIndex = items.current.findIndex( | ||
item => (numberOfDays && numberOfDays > 1) ? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better move this condition (numberOfDays && numberOfDays > 1) to a const since you're using the same one later in line 250 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extracted to a function (it's used outside of the component so it cant be a const/memoized) |
||
sameWeekRange(item, date, numberOfDays, item) : | ||
yuvalsho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sameWeek(item, date, firstDay)); | ||
if (pageIndex !== currentIndex.current) { | ||
if (pageIndex >= 0) { | ||
visibleWeek.current = items.current[pageIndex]; | ||
|
@@ -95,9 +100,10 @@ const WeekCalendar = (props: WeekCalendarProps) => { | |
onDayPress={_onDayPress} | ||
numberOfDays={numberOfDays} | ||
timelineLeftInset={timelineLeftInset} | ||
disableDaySelection={disableDaySelection} | ||
/> | ||
); | ||
},[firstDay, _onDayPress, context, date]); | ||
},[firstDay, _onDayPress, context, date, disableDaySelection]); | ||
|
||
const keyExtractor = useCallback((item) => item, []); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is
disableDaySelection
part of the 'props' if it's not a prop? It's confusing, why not add an option object or another pharam?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree, moved to be a different parameter