react-native-card-stack
Tinder really changed the game with it's card swiping interface. It's simple, visually appealing, and just plain fun.
Perhaps that's why it's taken the mobile UI world by storm. These days there is a "Tinder of..." just about everything from Music to Pet Adoption.
This component will make it easier to make your own "Tinder of..." by adding a stack of swipeable cards to your application. Based on the component built in our Platypost.
Quick Start
npm install --save react-native-card-stack
- Import it
import CardStack from 'react-native-card-stack'
- Render it
<CardStack/>
Example
'use strict';;;;; { superprops; thisstate = allCards: displayedCards: ; } { this; } async { try let response = await ; let result = await response; let resultKeyed = for var i = 0; i < resultresultslength; i++ resultresultsikey = resultresultsiloginusername; resultKeyed; this; let selection = for var i = 0; i < 3; i++ selection this; catch err ; } { if thisstateallCardslength > 0 let newCard = thisstateallCards this; }; { thisstatedisplayedCards; this; this; }; { return <View style=Stylescard> <View style=StylescardTop/> <View style=StylescardImageBorder/> <Image source=uri: cardObjectpicturelarge style=StylescardImage/> <View style=StylescardText> <Text style=StylescardTextMain>cardObjectnamefirst cardObjectnamelast</Text> <Text style=StylescardTextSecondary>cardObjectlocationcity </Text> <Text style=StylescardTextSecondary>cardObjectlocationstate</Text> <Text style=StylescardTextTerciary>cardObjectemail</Text> </View> </View> } { return <CardStack cardList=thisstatedisplayedCards renderCard=thisrenderCard cardHeight=height cardWidth=width cardRotation=20 cardOpacity=05 onSwipeRight=thishandleRemove onSwipeLeft=thishandleRemove onSwipeUp=thishandleRemove onSwipeDown=thishandleRemove leftSwipeThreshold=-150 rightSwipeThreshold=150 upSwipeThreshold=-150 downSwipeThreshold=150 /> ; } const Styles = StyleSheet;
Props
Name | Type | Description | Default |
---|---|---|---|
cardList | Array | Data provided for each card | |
renderCard | Function | Renders a card with the data provided | |
cardHeight | Number | Height of the card in density-independent pixels | |
cardWidth | Number | Width of the card in density-independent pixels | |
cardRotation | Number | Maximum rotation of card in degrees when dragged | |
cardOpacity | Number | Minimum opacity of card when dragged (0-1) | |
onSwipeRight | Function | Function to execute when card is past rightSwipeThreshold | |
onSwipeLeft | Function | Function to execute when card is past leftSwipeThreshold | |
onSwipeUp | Function | Function to execute when card is past upSwipeThreshold | |
onSwipeDown | Function | Function to execute when card is past downSwipeThreshold | |
leftSwipeThreshold | Number | Maximum card can be moved left before triggering onSwipeLeft function | |
rightSwipeThreshold | Number | Maximum card can be moved right before triggering onSwipeRight function | |
upSwipeThreshold | Number | Maximum card can be moved up before triggering onSwipeUp function | |
downSwipeThreshold | Number | Maximum card can be moved down before triggering onSwipeDown function |