npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-tinder-cards-view

v1.0.1

Published

A high performance, beautiful and fully customizable Animated swipe card list for React Native without any third party library and support pagination.

Downloads

23

Readme

react-native-tinder-cards-view

A high performance, beautiful and fully customizable Animated swipe card list for React Native without any third party library and support pagination.

Getting started

npm install react-native-tinder-cards-view --save

or

yarn add react-native-tinder-cards-view

Important Note

For the best experience in your app we prefer adding images with FastImage plugin.

React Native FastImage is a quick way to load images in React Native. All loaded pictures are aggressively cached by FastImage. You may add your own auth headers and preload pictures to your requests. GIF caching is also supported by react-native-fast-image.

To get started with React Native FastImage, first, add the FastImage component to your project:

yarn add react-native-fast-image

or

npm install –save react-native-fast-image

Platforms Supported

  • [x] iOS
  • [x] Android

Demo

Props

| Props | Params | isRequired | Default | Description | |--------------------|--------------------------------|------------|-------------------------|--------------------------------------------------------------------------------------------------| | data | Array | Yes | | For simplicity, data is a plain array. If you want to use something else, like an immutable list | | renderItem | ({ item: any }) => JSX.Element | Yes | | Function that returns a React element to display as Card. | | onSwipeRight | (item: any) => void | No | - | Function that fire when a card swiped in the right direction. | | onSwipeLeft | (item: any) => void | No | - | Function that fire when a card swiped in the left direction. | | actionOffset | Number | No | 100 | The value that when the card swipe over it will fire an action. | | cardWidth | Number | No | 96% from screen width | Card width | | cardHeight | Number | No | 90% from screen height | Card height | | renderRightElement | () => JSX.Element | No | Tinder Nope Image | Render right element | | renderLeftElement | () => JSX.Element | No | Tinder Like Image | Render left element | | renderEmptyComponent | () => JSX.Element | No | No more people text view | Render custom empty list component view | | animationDuration | Number | No | 200 | Swipe animation duration | | centerCards | Boolean | No | true | Center view | | cardsLeftToCallLoadMore | Number | No | 3 | Number of cards left to call onEndReached function for pagination | | onEndReached | () => void | No | - | On end reached function (Pagination support) | | onListIsEmpty | () => void | No | - | An optional function fired when no more cards to show |

Style props

| Props | Params | isRequired | Default | Description | |--------------------|--------------------------------|-----------|---------|------------------------------------------------------------| | containerStyle | ViewStyle | No | {} | An optional param to set Container custom style | | emptyViewContainerStyle | ViewStyle | No | {} | An optional param to set Empty view Container custom style | | cardViewStyle | ViewStyle | No | {} | An optional param to set Card view custom style | | rightElementStyle | ViewStyle | No | {} | An optional param to set right element style | | leftElementStyle | ViewStyle | No | {} | An optional param to set left element style |

Methods

You can use Reference to swipe cards programmatically.

  • [x] swipeCardRight
  • [x] swipeCardLeft

Swipe Card Right

Swipe current card to the right programmatically using reference:

swiperRef.current?.swipeCardRight();

Swipe Card Left

Swipe current card to the left programmatically using reference:

swiperRef.current?.swipeCardLeft();

Example

import React, {useRef, useState} from 'react';
import {Button, SafeAreaView, Text, View} from 'react-native';
import {AnimatedSwiper, AnimatedSwiperRef} from 'react-native-tinder-cards-view';
import {staticData} from './static/data';

const App = () => {
    /**
     * Swiper reference to make swipe programmatically.
     */
    const swiperRef = useRef<AnimatedSwiperRef>(null);
    const [data, setData] = useState(staticData);

    /**
     * Load more data.
     */
    const loadMore = () => {
        setData(prev => [...prev, ...staticData]);
    }

    return (
        <SafeAreaView>
            <AnimatedSwiper
                ref={swiperRef}
                actionOffset={50}
                renderEmptyComponent={() => (
                    <View style={{height: '100%', justifyContent: 'center', alignItems: 'center'}}>
                        <Text style={{color: 'red'}}>Test empty</Text>
                    </View>
                )}
                data={dataList}
                renderItem={({item}) => (
                    <CardItem image={item.image} name={item.name}/>
                )}
                cardsLeftToCallLoadMore={2}
                onEndReached={() => loadMore()}
                onSwipeRight={item => console.log('swipe right', item)}
                onSwipeLeft={item => console.log('swipe left', item)}
            />
            <Button
                title={'Swipe right programmatically'}
                onPress={() => swiperRef.current?.swipeCardRight()}
            />
            <Button
                title={'Swipe left programmatically'}
                onPress={() => swiperRef.current?.swipeCardLeft()}
            />
        </SafeAreaView>
    )
}

Card Item template:

import React from 'react';
import {Text, View} from 'react-native';
import FastImage from 'react-native-fast-image';
import {styles} from './styles';

const CardItem = ({image, name}: {image: string; name: string}) => {
  return (
    <View style={styles.card}>
      <FastImage style={styles.image} source={{uri: image, priority: FastImage.priority.high}} />
      <Text style={styles.text}>{name}</Text>
    </View>
  );
};

export default CardItem;

Demo App

For full working example you can check it on github from here.

Credit

This package created by Louay Sleman.