1.11.0 • Published 3 years ago

rn-simple-swipe v1.11.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

rn-simple-swipe npm version

Easy to use swipeable component for React Native built on top of react-native-gesture-handler/Swipeable, support both iOS and Android.

Installation

  1. First install react-native-gesture-handler

  2. Add rn-simple-swipe to your project:

npm i --save react-native-swipeable

or

yarn add rn-simple-swipe

Usage

Check out full example

import Swipeable from 'rn-simple-swipe'

const SwipeableComponent = () => {
    const rightActions = [
        {
            label: 'Add',
            color: '#8daef0',
            onPress: () => Alert.alert(`Add ${first_name}`),
            children: <FontAwesome name='plus' size={30} color='#fff' />,
        },
        {
            label: 'Remove',
            color: '#f07067',
            onPress: () => Alert.alert(`Remove ${first_name}`),
            children: <FontAwesome name='trash-o' size={30} color='#fff' />,
        },
    ]

    const leftAction = {
        label: 'Boo',
        onPress: () => alert('Boo'),
        icon: <FontAwesome name='snapchat-ghost' size={30} color='#fff' />,
    }

    return (
        <Swipeable rightActions={rightActions} leftAction={leftAction}>
            <View style={styles.item}>
                <Text>My Swipeable component</Text>
            </View>
        </Swipeable>
    )
}

Props

proptypedefaultdescription
rightActionsArray RightActionsProps[]Right swipe action buttons props
leftActionObject {LeftActionProps}{}Left swipe button props

RightActionsProps

proptypedefaultrequireddescription
labelString''trueText label for the action button
colorStringtransparentfalseAction button background color
widthNumber75falseAction button width
styleObject{}falseAdditional action button style
onPressFunundefinedfalseOn action button press callback
childrenElementundefinedfalseCustom action button children (you can render icon here for instance)
labelColorString#ffffalseLabel text color
labelStyleObject{}falseLabel text style
   {
	label: PropTypes.string.isRequired,
    color: PropTypes.string,
    onPress: PropTypes.func,
    children: PropTypes.element,
    style: PropTypes.object,
    width: PropTypes.number,
    labelColor: PropTypes.string,
    labelStyle: PropTypes.object,
   }

LeftActionProps

proptypedefaultrequireddescription
labelString''trueText label for the action button
colorStringtransparentfalseButton background color
iconElementundefinedfalseIcon that will be render before label
styleObject{}falseAdditional button style
onPressFunundefinedfalseOn button press callback
childrenElementundefinedfalseCustom children
labelColorString#ffffalseLabel text color
labelStyleObject{}falseLabel text style
   {
    label: PropTypes.string.isRequired,
    color: PropTypes.string,
    onPress: PropTypes.func,
    children: PropTypes.element,
    style: PropTypes.object,
    labelColor: PropTypes.string,
    labelStyle: PropTypes.object,
    icon: PropTypes.element,
   }

Example

To run the example

npm run build
cd example
npm install
react-native run-ios # or run-android
1.9.0

3 years ago

1.11.0

3 years ago

1.10.0

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago