Skip to content

Commit f704140

Browse files
committed
(SwipeAction): 增加actionViewStyle & rectButtonStyle属性
1 parent e6e766d commit f704140

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

example/examples/src/routes/SwipeAction/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default class SwipeActionView extends Component<SwipeActionProps> {
4545
<Card title="左右滑动,显示按钮" style={styles.card}>
4646
<SwipeAction
4747
buttonWidth={80}
48+
rectButtonStyle={{marginLeft: -20, marginRight: 20}}
4849
ref={ref => (this.newRef = ref)}
4950
right={right}
5051
onSwipeableRightOpen={() => console.log('right')}
@@ -71,5 +72,7 @@ const styles = StyleSheet.create({
7172
},
7273
view: {
7374
height: 30,
75+
backgroundColor: 'red',
76+
marginRight: 20,
7477
},
7578
});

packages/core/src/Drawer/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export interface DrawerState {
3333
}
3434

3535
export default function Drawer(props: DrawerProps) {
36-
console.log(333);
3736
const getInitPosition = () => {
3837
const { drawerWidth, placement, drawerHeight } = props;
3938
const xy = { x: 0, y: 0 };

packages/core/src/SwipeAction/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ export default Demo;
133133
| `right` | 右边滑动出来的元素 | Array<`ColumnProps`> | - |
134134
| `left` | 左边滑动出来的元素 | Array<`ColumnProps`> | - |
135135
| `buttonWidth` | 按钮宽度 | number | 60 |
136+
| `actionViewStyle` | 弹出框样式 | ViewStyle | - |
137+
| `rectButtonStyle` | 弹出button样式 | ViewStyle | - |
138+
136139
137140
### ColumnProps
138141
| 参数 | 说明 | 类型 | 默认值 |

packages/core/src/SwipeAction/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useImperativeHandle, forwardRef, useRef } from 'react';
2-
import { Animated, StyleSheet, View, Text, I18nManager } from 'react-native';
2+
import { Animated, StyleSheet, View, Text, I18nManager, ViewStyle } from 'react-native';
33
import { RectButton } from 'react-native-gesture-handler';
44
import Swipeable, { SwipeableProps } from 'react-native-gesture-handler/Swipeable';
55

@@ -23,14 +23,16 @@ export interface SwipeActionProps extends SwipeableProps {
2323
left?: Array<Column>;
2424
/** 按钮宽度 默认60 */
2525
buttonWidth?: number;
26+
actionViewStyle?: ViewStyle;
27+
rectButtonStyle?: ViewStyle;
2628
children?: React.ReactNode;
2729
}
2830

2931
const SwipeAction = (
3032
props: SwipeActionProps,
3133
ref: React.ForwardedRef<Partial<React.LegacyRef<Swipeable>> | undefined | null>,
3234
) => {
33-
const { right = [], left = [], buttonWidth = 60, children, ...others } = props;
35+
const { right = [], left = [], buttonWidth = 60, children, actionViewStyle, rectButtonStyle, ...others } = props;
3436
const swipeableRef: React.MutableRefObject<null> = useRef(null);
3537

3638
useImperativeHandle(ref, () => ({ swipeable: swipeableRef.current }));
@@ -48,7 +50,7 @@ const SwipeAction = (
4850
const length = buttons.length;
4951
const width = buttonWidth * length;
5052
return (
51-
<View style={[styles.viewActions, { width: width }]}>
53+
<View style={[styles.viewActions, { width: width, ...actionViewStyle }]}>
5254
{buttons &&
5355
buttons.map(({ text, color, onPress, disabled, render }, idx) => {
5456
const x = isLeft ? -idx * buttonWidth : (length - idx) * buttonWidth;
@@ -60,7 +62,7 @@ const SwipeAction = (
6062
return (
6163
<Animated.View key={idx} style={{ flex: 1, transform: [{ translateX: trans }] }}>
6264
<RectButton
63-
style={[styles.rightAction, { backgroundColor: color }]}
65+
style={[styles.rightAction, { backgroundColor: color, ...rectButtonStyle }]}
6466
onPress={() => {
6567
if (disabled && disabled) {
6668
return;

0 commit comments

Comments
 (0)