@momo-kits/swipe 0.76.1-beta.2 → 0.77.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.tsx +62 -0
- package/package.json +5 -5
- package/publish.sh +1 -1
- package/styles.ts +16 -0
- package/types.ts +23 -0
- package/SwipeAction.js +0 -708
- package/SwipeActionList.js +0 -162
- package/Swiper.js +0 -845
- package/index.js +0 -7
package/index.tsx
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, {FC, forwardRef, useContext, useRef} from 'react';
|
|
2
|
+
import {Animated, TouchableOpacity, View} from 'react-native';
|
|
3
|
+
import {Swipeable} from 'react-native-gesture-handler';
|
|
4
|
+
import {ApplicationContext, Icon, Text, Colors} from '@momo-kits/foundation';
|
|
5
|
+
import {SwipeAction, SwipeProps} from './types';
|
|
6
|
+
import styles from './styles';
|
|
7
|
+
|
|
8
|
+
const Swipe: FC<SwipeProps> = forwardRef(
|
|
9
|
+
({children, leftActions, rightActions, ...props}, ref) => {
|
|
10
|
+
const {theme} = useContext(ApplicationContext);
|
|
11
|
+
const renderActionItem = (action: SwipeAction) => {
|
|
12
|
+
const {
|
|
13
|
+
label,
|
|
14
|
+
icon,
|
|
15
|
+
onPress,
|
|
16
|
+
backgroundColor = theme.colors.highlight.primary,
|
|
17
|
+
} = action;
|
|
18
|
+
return (
|
|
19
|
+
<TouchableOpacity
|
|
20
|
+
style={[styles.action, {backgroundColor}]}
|
|
21
|
+
onPress={onPress}>
|
|
22
|
+
{!!icon && <Icon source={icon} color={Colors.black_01} />}
|
|
23
|
+
<Text
|
|
24
|
+
style={styles.textCenter}
|
|
25
|
+
numberOfLines={1}
|
|
26
|
+
color={Colors.black_01}
|
|
27
|
+
typography={'label_s'}>
|
|
28
|
+
{label}
|
|
29
|
+
</Text>
|
|
30
|
+
</TouchableOpacity>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const renderActions = (actions: SwipeAction[] | undefined) => {
|
|
35
|
+
return (
|
|
36
|
+
<View style={styles.row}>
|
|
37
|
+
{actions?.map((item, index) => {
|
|
38
|
+
//maximum 3 actions
|
|
39
|
+
if (index < 3) {
|
|
40
|
+
return renderActionItem(item);
|
|
41
|
+
}
|
|
42
|
+
})}
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Swipeable
|
|
49
|
+
{...props}
|
|
50
|
+
friction={2}
|
|
51
|
+
ref={ref}
|
|
52
|
+
overshootLeft={false}
|
|
53
|
+
overshootRight={false}
|
|
54
|
+
renderRightActions={() => renderActions(rightActions)}
|
|
55
|
+
renderLeftActions={() => renderActions(leftActions)}>
|
|
56
|
+
{children}
|
|
57
|
+
</Swipeable>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export default Swipe;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/swipe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.2-beta.02",
|
|
4
4
|
"private": false,
|
|
5
|
-
"main": "index.
|
|
5
|
+
"main": "index.tsx",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
+
"@momo-kits/foundation": "latest",
|
|
8
9
|
"prop-types": "^15.7.2",
|
|
9
|
-
"react": "
|
|
10
|
-
"react-native": ">=0.55"
|
|
11
|
-
"@momo-kits/core-v2": ">=0.0.5-beta"
|
|
10
|
+
"react": "16.9.0",
|
|
11
|
+
"react-native": ">=0.55"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {},
|
|
14
14
|
"license": "MoMo"
|
package/publish.sh
CHANGED
|
@@ -26,4 +26,4 @@ cd ..
|
|
|
26
26
|
rm -rf dist
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
##curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/swipe new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/swipe"}'
|
package/styles.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
action: {
|
|
5
|
+
width: 56,
|
|
6
|
+
height: '100%',
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
},
|
|
10
|
+
row: {
|
|
11
|
+
flexDirection: 'row',
|
|
12
|
+
},
|
|
13
|
+
textCenter: {
|
|
14
|
+
textAlign: 'center',
|
|
15
|
+
},
|
|
16
|
+
});
|
package/types.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {Ref, RefObject} from 'react';
|
|
2
|
+
import {Swipeable} from 'react-native-gesture-handler';
|
|
3
|
+
|
|
4
|
+
export type SwipeAction = {
|
|
5
|
+
label: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
onPress: () => void;
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type SwipeProps = {
|
|
12
|
+
leftActions?: SwipeAction[];
|
|
13
|
+
rightActions?: SwipeAction[];
|
|
14
|
+
onSwipeableLeftOpen?: () => void;
|
|
15
|
+
onSwipeableRightOpen?: () => void;
|
|
16
|
+
onSwipeableOpen?: () => void;
|
|
17
|
+
onSwipeableClose?: () => void;
|
|
18
|
+
onSwipeableLeftWillOpen?: () => void;
|
|
19
|
+
onSwipeableRightWillOpen?: () => void;
|
|
20
|
+
onSwipeableWillOpen?: () => void;
|
|
21
|
+
onSwipeableWillClose?: () => void;
|
|
22
|
+
ref?: Ref<Swipeable>;
|
|
23
|
+
};
|