@@ -12,7 +12,8 @@ import {
1212 StyleProp ,
1313 ViewStyle ,
1414 AccessibilityActionEvent ,
15- ColorValue
15+ ColorValue ,
16+ Insets
1617} from 'react-native' ;
1718import { formatNumbers , weekDayNames } from '../../dateutils' ;
1819import {
@@ -50,6 +51,8 @@ export interface CalendarHeaderProps {
5051 onPressArrowLeft ?: ( method : ( ) => void , month ?: XDate ) => void ; //TODO: replace with string
5152 /** Handler which gets executed when press arrow icon right. It receive a callback can go next month */
5253 onPressArrowRight ?: ( method : ( ) => void , month ?: XDate ) => void ; //TODO: replace with string
54+ /** Left & Right arrows. Additional distance outside of the buttons in which a press is detected, default: 20 */
55+ arrowsHitSlop ?: Insets | number ;
5356 /** Disable left arrow */
5457 disableArrowLeft ?: boolean ;
5558 /** Disable right arrow */
@@ -75,7 +78,6 @@ export interface CalendarHeaderProps {
7578 timelineLeftInset ?: number ;
7679}
7780
78- const arrowHitSlop = { left : 20 , right : 20 , top : 20 , bottom : 20 } ;
7981const accessibilityActions = [
8082 { name : 'increment' , label : 'increment' } ,
8183 { name : 'decrement' , label : 'decrement' }
@@ -95,6 +97,7 @@ const CalendarHeader = forwardRef((props: CalendarHeaderProps, ref) => {
9597 renderArrow,
9698 onPressArrowLeft,
9799 onPressArrowRight,
100+ arrowsHitSlop = 20 ,
98101 disableArrowLeft,
99102 disableArrowRight,
100103 disabledDaysIndexes,
@@ -123,7 +126,14 @@ const CalendarHeader = forwardRef((props: CalendarHeaderProps, ref) => {
123126 const dayNamesStyle = useMemo ( ( ) => {
124127 return [ style . current . week , numberOfDaysCondition ? partialWeekStyle : undefined ] ;
125128 } , [ numberOfDaysCondition , partialWeekStyle ] ) ;
126-
129+ const hitSlop : Insets | undefined = useMemo (
130+ ( ) =>
131+ typeof arrowsHitSlop === 'number'
132+ ? { top : arrowsHitSlop , left : arrowsHitSlop , bottom : arrowsHitSlop , right : arrowsHitSlop }
133+ : arrowsHitSlop ,
134+ [ arrowsHitSlop ]
135+ ) ;
136+
127137 useImperativeHandle ( ref , ( ) => ( {
128138 onPressLeft,
129139 onPressRight
@@ -225,14 +235,14 @@ const CalendarHeader = forwardRef((props: CalendarHeaderProps, ref) => {
225235 const shouldDisable = isLeft ? disableArrowLeft : disableArrowRight ;
226236 const onPress = ! shouldDisable ? isLeft ? onPressLeft : onPressRight : undefined ;
227237 const imageSource = isLeft ? require ( '../img/previous.png' ) : require ( '../img/next.png' ) ;
228- const renderArrowDirection = isLeft ? 'left' : 'right' ;
229-
238+ const renderArrowDirection = isLeft ? 'left' : 'right' ;
239+
230240 return (
231241 < TouchableOpacity
232242 onPress = { onPress }
233243 disabled = { shouldDisable }
234244 style = { style . current . arrow }
235- hitSlop = { arrowHitSlop }
245+ hitSlop = { hitSlop }
236246 testID = { testId }
237247 >
238248 { renderArrow ? (
@@ -301,5 +311,6 @@ export default CalendarHeader;
301311CalendarHeader . displayName = 'CalendarHeader' ;
302312CalendarHeader . defaultProps = {
303313 monthFormat : 'MMMM yyyy' ,
304- webAriaLevel : 1
314+ webAriaLevel : 1 ,
315+ arrowsHitSlop : 20
305316} ;
0 commit comments