New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-native-swipeable-card-deck

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-swipeable-card-deck

Swipeable cards deck for board games and stuff.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

Swipeable Cards for React Native

  • swipe-left-for-next;swipe-right-for-previous kind of cards deck/stack similar to the Flutter package ninest/swipeable_card.
  • demonstration
  • Note that this package is just a mod of swaplet/react-native-swipe-cards-deck in the main.

Quick Start

  • npm i react-native-swipeable-card-deck
  • Import it import SwipeCards from "react-native-swipeable-card-deck"
  • Render it <SwipeCards ... />
import React, { useEffect, useState } from "react";
import { StyleSheet, Text, View } from "react-native";
import SwipeCards from "react-native-swipeable-card-deck";

function Card({ data }) {
  return (
    <View style={[styles.card, { backgroundColor: data.backgroundColor }]}>
      <Text>{data.text}</Text>
    </View>
  );
}

function StatusCard({ text }) {
  return (
    <View>
      <Text style={styles.cardsText}>{text}</Text>
    </View>
  );
}

export default function App() {
  const [cards, setCards] = useState();

  // replace with real remote data fetching
  useEffect(() => {
    setTimeout(() => {
      setCards([
        { text: "1st card", backgroundColor: "red" },
        { text: "2nd card", backgroundColor: "purple" },
        { text: "3rd card", backgroundColor: "green" },
        { text: "4th card", backgroundColor: "blue" },
        { text: "5th card", backgroundColor: "cyan" },
        { text: "Last card", backgroundColor: "orange" },
      ]);
    }, 3000);
  }, []);

  function handleLeft() {
    console.log(`Next`);
    return true;
  }
  
  function handleRight() {
    console.log(`Previous`);
    return true; // return false if you wish to cancel the action
  }
  
  function handleUp() {
    console.log(`UP`);
    return true;
  }

  return (
    <View style={styles.container}>
      {cards ? (
        <SwipeCards
          cards={cards}
          renderCard={(cardData) => <Card data={cardData} />}
          keyExtractor={(cardData) => String(cardData.text)}
          renderNoMoreCards={() => <StatusCard text="No more cards..." />}
          actions={{
            left: { /*show:false,*/ onAction: handleLeft },
            right: { /*show:false,*/ onAction: handleRight },
            up: { /*show:false,*/ onAction: handleUp },
          }}
          hasUpAction={true}

          // If you want a stack of cards instead of one-per-one view, activate stack mode
          // stack={true}
          // stackDepth={3}
        />
      ) : (
        <StatusCard text="Loading..." />
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  },
  card: {
    justifyContent: "center",
    alignItems: "center",
    width: 300,
    height: 300,
    userSelect: "none"
  },
  cardsText: {
    fontSize: 22,
  },
});

Keywords

react-native

FAQs

Package last updated on 18 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts