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-pairs-swipeable-cards

v1.0.0-alpha.0

Published

This is the simplest sticky header component made for ReactNative.

Downloads

4

Readme

react-native-pairs-swipeable-cards

code style: prettier Github Actions License: MIT NPM version NPM downloads

This is the simplest swipeable cards component made for React Native.

Installation

# npm
npm instal react-native-pairs-swipeable-cards

# yarn
yarn add react-native-pairs-swipeable-cards

Usage

Here is a quick example.

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { ImageBackground, StyleSheet, Text, View } from 'react-native';
import { SwipeableCards, BORDER_RADIUS } from 'react-native-pairs-swipeable-cards';

export default function App() {
  const data: {
    id: string;
    isActive: boolean;
    name: string;
    age: number;
    place: string;
    rate: number;
    tags: string[];
    imageUri: string;
  }[] = [
    {
      id: 'misono',
      isActive: true,
      name: '高村美園',
      age: 25,
      place: '神奈川県',
      rate: 64,
      tags: ['読書好き', '友達みたいな恋人が・・・', '気ままにドライブに行きたい!'],
        'https://image.png',
    },
    {
      id: 'arisa',
      isActive: false,
      name: '須藤亜里沙',
      age: 24,
      place: '福岡県',
      rate: 64,
      tags: ['読書好き', '友達みたいな恋人が・・・', '気ままにドライブに行きたい!'],
        'https://image.png',
    },
    {
      id: 'sasaki',
      isActive: false,
      name: '佐々木涼平',
      age: 24,
      place: '東京都',
      rate: 64,
      tags: ['読書好き', '友達みたいな恋人が・・・', '気ままにドライブに行きたい!'],
      imageUri:
        'https://image.png',
    },
    {
      id: 'tsugumi',
      isActive: true,
      name: '川本つぐみ',
      age: 24,
      place: '東京都',
      rate: 64,
      tags: ['読書好き', '友達みたいな恋人が・・・', '気ままにドライブに行きたい!'],
      imageUri:
        'https://image.png',
    },
  ];
  return (
    <View style={styles.container}>
      <SwipeableCards
        data={data}
        onLike={() => console.log('いいね')}
        onSkip={() => console.log('スキップ!')}
        renderItem={(item, index) => (
          <ImageBackground
            key={`render_item_key_${index}`}
            source={{
              uri: item.imageUri,
            }}
            resizeMode="cover"
            style={{
              flex: 1,
              justifyContent: 'flex-end',
              paddingVertical: 16,
            }}
            imageStyle={{
              borderRadius: BORDER_RADIUS,
            }}
          >
            <View
              style={{
                flexDirection: 'row',
                alignItems: 'center',
                paddingHorizontal: 16,
                marginBottom: 8,
              }}
            >
              <View
                style={{
                  width: 16,
                  height: 16,
                  borderRadius: 25,
                  backgroundColor: item.isActive ? '#2cd26b' : '#cc0033',
                  marginRight: 8,
                }}
              />
              <Text
                style={{
                  color: '#ffffff',
                  fontWeight: 'bold',
                  fontSize: 32,
                }}
              >
                {item.name}
              </Text>
            </View>
            <View
              style={{
                flexDirection: 'row',
                alignItems: 'center',
                paddingHorizontal: 16,
                marginBottom: 8,
              }}
            >
              <Text
                style={{
                  color: '#ffffff',
                  fontWeight: 'bold',
                  fontSize: 16,
                  marginRight: 10,
                }}
              >
                {`${item.age}歳`}
              </Text>
              <Text
                style={{
                  color: '#ffffff',
                  fontWeight: 'bold',
                  fontSize: 16,
                  marginRight: 10,
                }}
              >
                {`${item.place}`}
              </Text>
              <Text
                style={{
                  color: '#ffffff',
                  fontWeight: 'bold',
                  fontSize: 16,
                }}
              >
                {`♡${item.rate}%`}
              </Text>
            </View>
            <View
              style={{
                flexDirection: 'row',
                alignItems: 'center',
                paddingHorizontal: 16,
              }}
            >
              {item.tags.map(tag => (
                <View
                  key={`tag_${tag}`}
                  style={{
                    paddingVertical: 8,
                    paddingHorizontal: 10,
                    borderRadius: 6,
                    marginRight: 6,
                    backgroundColor: '#ffffff',
                  }}
                >
                  <Text
                    style={{
                      color: '#000000',
                      fontSize: 8,
                      fontWeight: 'bold',
                    }}
                  >
                    {tag}
                  </Text>
                </View>
              ))}
            </View>
          </ImageBackground>
        )}
      />
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Props and methods

Props

data (Required)

Type: array of Object which has id: string property

For simplicity, data is a plain array.

renderItem (Required)

Type: (item: T, index: number) => React.ReactElement

Method which return contents to be displayed on the screen.

onSkip

Type: (item: Object) => void

Method called when a card is swiped to the left or when the skip button is pressed.

onLike

Type: (item: Object) => void

Method called when a card is swiped to the right or when the like button is pressed.

onLikeWithMessage

Type: (item: Object) => void

Method called when the middle button is pressed.