11import 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' ;
33import { RectButton } from 'react-native-gesture-handler' ;
44import 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
2931const 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