Skip to content

Commit 6932c1d

Browse files
committed
chore: pressable with children
1 parent 626b4c4 commit 6932c1d

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

package/src/components/UIComponents/SwipableWrapper.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { PropsWithChildren, useCallback, useEffect, useRef } from 'react';
2-
import { StyleSheet } from 'react-native';
2+
import { Alert, StyleSheet, View } from 'react-native';
33

4+
import { Pressable } from 'react-native-gesture-handler';
45
import Animated, {
56
Extrapolation,
67
SharedValue,
@@ -18,6 +19,7 @@ import { useSwipeRegistryContext } from '../../contexts/swipeableContext/SwipeRe
1819

1920
const ACTION_WIDTH = 80;
2021
const DEFAULT_RIGHT_ACTIONS_WIDTH = ACTION_WIDTH * 2;
22+
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
2123

2224
const animationOptions = {
2325
damping: 24,
@@ -43,8 +45,18 @@ const DefaultRightActions = ({ translation }: { translation: SharedValue<number>
4345

4446
return (
4547
<Animated.View style={styles.rightActionsContainer}>
46-
<Animated.View style={[styles.action, styles.redAction, animatedActionWidthStyle]} />
47-
<Animated.View style={[styles.action, styles.blueAction, animatedActionWidthStyle]} />
48+
<AnimatedPressable
49+
onPress={() => Alert.alert('Red pressed')}
50+
style={[styles.action, animatedActionWidthStyle]}
51+
>
52+
<View style={{ flex: 1, backgroundColor: 'red' }} />
53+
</AnimatedPressable>
54+
<AnimatedPressable
55+
onPress={() => Alert.alert('Blue pressed')}
56+
style={[styles.action, animatedActionWidthStyle]}
57+
>
58+
<View style={{ flex: 1, backgroundColor: 'blue' }} />
59+
</AnimatedPressable>
4860
</Animated.View>
4961
);
5062
};

0 commit comments

Comments
 (0)