Skip to content

Commit e73a55d

Browse files
committed
fix:docs:SwipeAction
1 parent 6e1fd76 commit e73a55d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/core/src/SwipeAction/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,19 @@ const styles = StyleSheet.create({
104104
组件继承react-native-gesture-handler[`Swipeable`](https://docs.swmansion.com/react-native-gesture-handler/docs/api/components/swipeable)
105105
```tsx
106106
export interface SwipeActionProps {
107-
right: Array<{
107+
right?: Array<{
108108
text: string;
109109
color: string;
110110
x?: number;
111-
onPress?: () => void
111+
onPress?: () => void;
112112
}>;
113+
left?: Array<{
114+
text: string;
115+
color: string;
116+
onPress?: () => void;
117+
}>;
118+
// 滑动条宽度 20%
119+
swipeWidth?:string | number
113120
enableTrackpadTwoFingerGesture?: boolean;
114121
friction?: number;
115122
leftThreshold?: number;

packages/core/src/SwipeAction/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface SwipeActionProps {
1515
color: string;
1616
onPress?: () => void;
1717
}>;
18+
swipeWidth?: string | number;
1819
enableTrackpadTwoFingerGesture?: boolean;
1920
friction?: number;
2021
leftThreshold?: number;
@@ -46,7 +47,7 @@ export interface SwipeActionProps {
4647
}
4748

4849
const SwipeAction = (props: SwipeActionProps, ref: any) => {
49-
const { children, right = [], left = [], ...others } = props;
50+
const { children, right = [], left = [], swipeWidth = '20%', ...others } = props;
5051
const swipeableRef: React.MutableRefObject<null> = useRef(null);
5152

5253
// 右侧滑出
@@ -62,7 +63,7 @@ const SwipeAction = (props: SwipeActionProps, ref: any) => {
6263
return (
6364
<View
6465
style={{
65-
width: '20%',
66+
width: swipeWidth,
6667
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
6768
}}
6869
>
@@ -95,7 +96,7 @@ const SwipeAction = (props: SwipeActionProps, ref: any) => {
9596
return (
9697
<View
9798
style={{
98-
width: '20%',
99+
width: swipeWidth,
99100
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
100101
}}
101102
>

0 commit comments

Comments
 (0)