@@ -27,7 +27,7 @@ const AnimationValues = {
2727
2828type BasePressableProps = Pick <
2929 PressableProps ,
30- Exclude < keyof PressableProps , 'onPress' >
30+ Exclude < keyof PressableProps , 'onPress' | 'onLongPress' >
3131> ;
3232
3333interface BouncyCheckboxProps extends BasePressableProps {
@@ -59,6 +59,7 @@ interface BouncyCheckboxProps extends BasePressableProps {
5959 textContainerStyle ?: StyleProp < ViewStyle > ;
6060 checkIconImageSource ?: ImageSourcePropType ;
6161 onPress ?: ( checked : boolean ) => void ;
62+ onLongPress ?: ( checked : boolean ) => void ;
6263}
6364
6465const BouncyCheckbox : React . FC < BouncyCheckboxProps > = ( {
@@ -74,6 +75,7 @@ const BouncyCheckbox: React.FC<BouncyCheckboxProps> = ({
7475 textContainerStyle,
7576 size = 25 ,
7677 onPress,
78+ onLongPress,
7779 fillColor = '#ffc484' ,
7880 ImageComponent = Image ,
7981 unFillColor = 'transparent' ,
@@ -103,6 +105,16 @@ const BouncyCheckbox: React.FC<BouncyCheckboxProps> = ({
103105 }
104106 } ;
105107
108+ const handleLongPress = ( ) => {
109+ if ( ! disableBuiltInState ) {
110+ setChecked ( ! checked , newCheckedValue => {
111+ onLongPress && onLongPress ( newCheckedValue ) ;
112+ } ) ;
113+ } else {
114+ onLongPress && onLongPress ( checked ) ;
115+ }
116+ } ;
117+
106118 const renderCheckIcon = ( ) => {
107119 const checkStatus = disableBuiltInState ? isChecked ! : checked ;
108120 const scaleAnimation = { transform : [ { scale : bounceValue } ] } ;
@@ -155,6 +167,7 @@ const BouncyCheckbox: React.FC<BouncyCheckboxProps> = ({
155167 animateBounce ( bounceEffectOut , bounceVelocityOut , bouncinessOut ) ;
156168 } }
157169 onPress = { handlePress }
170+ onLongPress = { handleLongPress }
158171 { ...rest } >
159172 { renderCheckIcon ( ) }
160173 { renderCheckboxText ( ) }
0 commit comments