Giter VIP home page Giter VIP logo

react-native-swipeable-list's Introduction

react-native-swipeable-list

npm version Downloads License PRs Build status

A zero-dependency, Swipeable FlatList for React-Native with Quick Actions, Gestures, and Animations.

animated screenshot of a swipeable flatlist email inbox mockup using react-native-swipeable-list

Usage

  1. Install the package in your project: npm install react-native-swipeable-list or yarn add react-native-swipeable-list

  2. Import the component into your component: import SwipeableFlatList from 'react-native-swipeable-list';

  3. Pass it a data array. It inherits FlatListProps from the standard FlatList component from react-native.

It can be passed additional props:

  • shouldBounceOnMount (default = true) - To alert the user that swiping is possible, the first row can bounce on component mount. Type boolean

  • maxSwipeDistance - Maximum distance to open to after a swipe. Type number || (Object => number)

  • renderQuickActions - Callback method to render the view that will be unveiled on swipe. Type renderItemType (which provides index and item, which will be very useful for performing actions on your items)

Example

Check out the example in the /examples folder. Clone this repo, then cd examples && yarn install && yarn start and then either react-native run-ios or react-native run-android to get the app up and running locally. Play with the code and see what you can do! ๐Ÿ˜Ž

History & Shoutouts

Started from the SwipeableFlatList component that was removed from react-native's experimental libraries. (See: https://github.com/facebook/react-native/commit/9ca7989f60cc8137705effeaad0f128fa73ed2e4)

react-native-swipeable-list's People

Contributors

dependabot[bot] avatar esthor avatar jlkalberer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-swipeable-list's Issues

disable bounce

Thanks for making a great library.
Is it possible to stop scrolling beyond the required range or get rid of the bounce?

Refactor to Native Animations (w/ Reanimated)

We should have native, butter smooth animations with zero frame drops, even on large, complex UIs. I have noticed slight dips (60fps -> 57fps) on the JS thread for a split second when initiating panning on the row on very large lists. Can be reproduced in the example app. We can do better!

Does this library still work?

I replaced an existing Flatlist with SwipeableFlatList and it doesn't handle any of the swipes. It behaves just like the regular Flatlist.
Does something else need to be done?

Here is what I have:

const GoalListItem = props => {
    let goal = props.goal;
    return (
   containerStyle={{ margin: 10 }}>
            <Card.Title>{goal.description}</Card.Title>
            <Card.Divider />
            <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
                <Text>{goal.reward}</Text>
                {/* <Divider orientation='vertical' width={2} /> */}
                <Text>{goal.targetDate}</Text>
            </View>
        </Card>
    )
};

That's the item I am rendering in the Flatlist and this is how I have the Flatlist configured:

 return (
        <View style={globalStyles.scrollViewContainer}>
            <SwipeableFlatList
                data={goalIds.filter(id => id !== 'temporary').map(Goal.getGoalById)}
                // Keep this item. Anything else, causes it to fail!
                renderItem={({ item }) => <GoalListItem goal={item} navigation={navigation} setter={setGoalIds} />}
                maxSwipeDistance={25}
                shouldBounceOnMount={true}
                keyExtractor={_ => nextId('g-')}
            />
     </View>
    );

Looks straightforward to me, but the cards do not handle any gestures and show no indication that they are not just the regular Flatlist.

Define Types

Add types throughout the SwipeableFlatList and SwipeableRow. Probably also define/export them in a d.ts.

Refactor to Native Gesture Handling (w/ React Native Gesture Handler)

We should have native, butter smooth animations with zero frame drops, even on large, complex UIs. I have noticed slight dips (60fps -> 57fps) on the JS thread for a split second when initiating panning on the row on very large lists. Can be reproduced in the example app. We can do better!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.