1.1.3 • Published 2 years ago

react-native-easy-swipe v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-easy-swipe

Swipeable component for react native powered by Reanimated 2 and Gesture Handler

alt text

Installation

yarn add react-native-easy-swipe

Also add dependencies, and follow instructions there to setup your project

yarn add react-native-reanimated react-native-gesture-handler

Usage

import {
  SwipeableItem,
  withSwipeableContext,
  useSwipeableContext,
} from 'react-native-easy-swipe';

// ...

function YourComponent() {
    const { close } = useSwipeableContext();

    ... 

    const renderLeftActions = useCallback(() => {
        return (
            <SwipeableItem.Button onPress={handlePinPress}>
                <View style={[styles.delete, { backgroundColor: 'yellow' }]}>
                    <Text>Pin</Text>
                </View>
            </SwipeableItem.Button>
        );
    }, [handlePinPress]);

    return (
        <SwipeableItem
            containerStyle={styles.container}
            renderRightActions={renderRightActions}
            renderLeftActions={renderLeftActions}
            onStartDrag={handleStartDrag}
            onOpened={handleOnOpened}
            onClosed={handleOnClosed}
            onItemPress={handleItemPress}
        >
            <View style={styles.overlay}>
            <Image source={{ uri: item.avatar }} style={styles.avatar} />
            <View style={styles.info}>
                <Text style={styles.name}>{item.name}</Text>
                <Text>
                Lorem Ipsum is simply dummy text of the printing and typesetting
                industry.
                </Text>
            </View>
            </View>
        </SwipeableItem>
    );
}

export default withSwipeableContext(YourComponent);

Check Example for the trick I did to close the item when other opened.

Hint: I used Animated.ShareValue<number> to set the current item with menu opened

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago