-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathSwipeableExpenseRow.js
More file actions
69 lines (63 loc) · 1.77 KB
/
SwipeableExpenseRow.js
File metadata and controls
69 lines (63 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React, { useRef } from 'react';
import { StyleSheet, View } from 'react-native';
import ReanimatedSwipeable from 'react-native-gesture-handler/ReanimatedSwipeable';
import Reanimated, { useAnimatedStyle, interpolate, Extrapolation } from 'react-native-reanimated';
import { IconButton } from 'react-native-paper';
const SwipeableExpenseRow = ({ children, onSwipeableOpen }) => {
const swipeableRef = useRef(null);
const renderRightActions = (progress, drag) => {
const style = useAnimatedStyle(() => {
const scale = interpolate(
drag.value,
[-80, 0],
[1, 0],
Extrapolation.CLAMP
);
return {
transform: [{ scale }],
};
});
return (
<View style={styles.rightActionContainer}>
<Reanimated.View style={[styles.rightAction, style]}>
<IconButton
icon="delete"
iconColor="white"
size={24}
onPress={() => {
swipeableRef.current?.close();
onSwipeableOpen();
}}
/>
</Reanimated.View>
</View>
);
};
return (
<ReanimatedSwipeable
ref={swipeableRef}
renderRightActions={renderRightActions}
onSwipeableOpen={onSwipeableOpen}
rightThreshold={40}
>
{children}
</ReanimatedSwipeable>
);
};
const styles = StyleSheet.create({
rightActionContainer: {
width: 80,
backgroundColor: '#dd2c00',
justifyContent: 'center',
alignItems: 'center',
marginBottom: 16, // Matches the card margin in GroupDetailsScreen
borderTopRightRadius: 12, // Approximate card radius
borderBottomRightRadius: 12,
},
rightAction: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
export default SwipeableExpenseRow;