Skip to content

Commit edefc58

Browse files
committed
doc:SwipeAction文档修改
1 parent f5d0335 commit edefc58

File tree

1 file changed

+44
-115
lines changed

1 file changed

+44
-115
lines changed
Lines changed: 44 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,54 @@
11
SwipeAction 滑动操作组件。
22
---
3-
43
结合手势操作,从屏幕一侧唤出操作。
54

6-
![](https://user-images.githubusercontent.com/57083007/146733663-6c83fca4-72df-424d-8364-47533f57ece6.gif)
7-
85
### 基础示例
96

10-
```tsx
11-
import React, { Component } from 'react';
12-
import { StyleSheet } from 'react-native';
13-
import { SwipeAction } from '@uiw/react-native';
14-
15-
export interface SwipeActionProps {
7+
```jsx
8+
import React from 'react';
9+
import {SwipeAction} from '@uiw/react-native';
10+
import { View,Text } from 'react-native'
11+
12+
function Demo() {
13+
const right = [
14+
{
15+
text: '查看',
16+
color: 'orange',
17+
x: 250,
18+
},
19+
{
20+
text: '删除',
21+
color: 'red',
22+
x: 400,
23+
},
24+
{
25+
text: '不显示',
26+
color: 'green',
27+
x: 400,
28+
},
29+
];
30+
return (
31+
<SwipeAction buttonWidth={60} right={right}>
32+
<View><Text>滑动</Text></View>
33+
</SwipeAction>
34+
);
1635
}
17-
18-
export default class SwipeActionView extends Component<SwipeActionProps> {
19-
newRef: any;
20-
render() {
21-
const right = [
22-
{
23-
text: '查看',
24-
color: 'orange',
25-
x: 250,
26-
onPress: () => {
27-
this.newRef?.swipeable?.close()
28-
},
29-
},
30-
{
31-
text: '删除',
32-
color: 'red',
33-
x: 400,
34-
onPress: () => {
35-
this.newRef?.swipeable?.close()
36-
},
37-
},
38-
{
39-
text: '不显示',
40-
color: 'green',
41-
x: 400,
42-
onPress: () => {
43-
this.newRef?.swipeable?.close()
44-
},
45-
},
46-
];
47-
return (
48-
<SwipeAction
49-
buttonWidth={60}
50-
ref={ref => this.newRef = ref}
51-
right={right}
52-
onSwipeableRightOpen={() => console.log('right')}
53-
onSwipeableLeftOpen={() => () => console.log('left')}
54-
>
55-
<View style={[styles.view]}>
56-
<Text>滑动</Text>
57-
</View>
58-
</SwipeAction>
59-
);
60-
}
61-
}
62-
63-
const styles = StyleSheet.create({
64-
card: {
65-
backgroundColor: '#fff',
66-
paddingLeft: 20,
67-
paddingRight: 20,
68-
paddingBottom: 30,
69-
},
70-
view: {
71-
height: 30
72-
},
73-
});
74-
36+
export default Demo;
7537
```
7638

77-
78-
### Props
7939
组件继承react-native-gesture-handler[`Swipeable`](https://docs.swmansion.com/react-native-gesture-handler/docs/api/components/swipeable)
80-
```tsx
81-
export interface Column {
82-
/** 显示文字 */
83-
text: string;
84-
/** 背景色 */
85-
color: string;
86-
/** 点击元素触发 */
87-
onPress?: () => void;
88-
/** 是否禁用 */
89-
disabled?: boolean;
90-
/** 自定义元素 */
91-
render?: (text: string, record: Column, index: number) => React.ReactNode;
92-
}
93-
94-
export interface SwipeActionProps {
95-
/** 右边滑动出来的元素 */
96-
right?: Array<Column>;
97-
/** 左边滑动出来的元素 */
98-
left?: Array<Column>;
99-
/** 按钮宽度 默认60 */
100-
buttonWidth?:string | number
101-
/** 其余api参考文档 react-native-gesture-handler/Swipeable */
102-
enableTrackpadTwoFingerGesture?: boolean;
103-
friction?: number;
104-
leftThreshold?: number;
105-
rightThreshold?: number;
106-
overshootLeft?: boolean;
107-
overshootRight?: boolean;
108-
overshootFriction?: number;
109-
onSwipeableLeftOpen?: () => void;
110-
onSwipeableRightOpen?: () => void;
111-
onSwipeableOpen?: () => void;
112-
onSwipeableClose?: () => void;
113-
onSwipeableLeftWillOpen?: () => void;
114-
onSwipeableRightWillOpen?: () => void;
115-
onSwipeableWillOpen?: () => void;
116-
onSwipeableWillClose?: () => void;
117-
children?: React.ReactNode;
118-
renderLeftActions?: (progressAnimatedValue: Animated.AnimatedInterpolation, dragAnimatedValue: Animated.AnimatedInterpolation) => React.ReactNode;
119-
renderRightActions?: (progressAnimatedValue: Animated.AnimatedInterpolation, dragAnimatedValue: Animated.AnimatedInterpolation) => React.ReactNode;
120-
useNativeAnimations?: boolean;
121-
animationOptions?: Record<string, unknown>;
122-
containerStyle?: StyleProp<ViewStyle>;
123-
childrenContainerStyle?: StyleProp<ViewStyle>;
124-
}
125-
```
40+
### Props
41+
| 参数 | 说明 | 类型 | 默认值 |
42+
|------|------|-----|------|
43+
| `right` | 右边滑动出来的元素 | Array<Column> | - |
44+
| `left` | 左边滑动出来的元素 | Array<Column> | - |
45+
| `buttonWidth` | 按钮宽度 | string | number | 60 |
46+
47+
### ColumnProps
48+
| 参数 | 说明 | 类型 | 默认值 |
49+
|------|------|-----|------|
50+
| `text` | 显示文字 | string | - |
51+
| `color` | 背景色 | string | - |
52+
| `onPress` | 点击元素触发 | () => void | - |
53+
| `disabled` | 是否禁用 | Boolean | - |
54+
| `render` | 自定义元素 | (text: string, record: Column, index: number) => React.ReactNode | - |

0 commit comments

Comments
 (0)