Skip to content

Latest commit

 

History

History
executable file
·
399 lines (383 loc) · 11.4 KB

DeckSwiper.md

File metadata and controls

executable file
·
399 lines (383 loc) · 11.4 KB

deckswiper-def-headref

Deck Swiper

Looking at data one piece at a time is more efficient when you consider people you might want to date, restaurants, streaming music, or local events you might want to check out.
NativeBase Deck Swiper helps you evaluate one option at a time, instead of selecting from a set of options.
Replacing Component: React Native View

Preview ios deckswiper-def-headref Preview android deckswiper-def-headref

Syntax

{% codetabs name="React Native", type="js" -%} import React, { Component } from 'react'; import { Image } from 'react-native'; import { Container, Header, View, DeckSwiper, Card, CardItem, Thumbnail, Text, Left, Body, Icon } from 'native-base'; const cards = [ { text: 'Card One', name: 'One', image: require('./img/swiper-1.png'), }, . . . ]; export default class DeckSwiperExample extends Component { render() { return (

<DeckSwiper dataSource={cards} renderItem={item => {% raw %}<Card style={{ elevation: 3 }}>{% endraw %} {item.text} NativeBase {% raw %}<Image style={{ height: 300, flex: 1 }} source={item.image} />{% endraw %} {% raw %}<Icon name="heart" style={{ color: '#ED4A6A' }} />{% endraw %} {item.name} } /> ); } } {%- language name="Vue Native", type="vue" -%}

<script> import React from "react"; import { View, Text } from "react-native"; import cardOne from "swiper-1.png"; import CardComponent from "../common/card"; export default { data: function() { return { cardItemsArr: [ { text: "Card One", name: "One", image: cardOne }, . . . ], isLoopingRequired: false }; }, methods: { handleCardRendering: function(item) { return ; } } }; </script>

// Card Component {{item.text}} NativeBase {{item.name}}

<script> export default { props: { item: { type: Object } } }; </script>

{%- endcodetabs %}

Configuration

Property Default Option Description
dataSource - User defined object Chunk of data(object)
renderEmpty Function - Callback that is called when all the cards are swiped and dataSource is empty and returns a component.
renderItem Function - Callback which takes a chunk of data and returns a component.
renderTop Function - Callback which takes a chunk of data and returns top layer component.
renderBottom Function - Callback which takes a chunk of data and returns bottom layer component.
looping true boolean Loop through the data
onSwipeRight Function - Callback that is called when the Card is swiped Right
onSwipeLeft Function - Callback that is called when the Card is swiped Left

deckswiper-adv-headref

Advanced Deck Swiper

Swipe Deck with callback function.

Preview ios deckswiper-adv-headref Preview android deckswiper-adv-headref

Syntax

{% codetabs name="React Native", type="js" -%} import React, { Component } from 'react'; import { Image } from 'react-native'; import { Container, Header, View, DeckSwiper, Card, CardItem, Thumbnail, Text, Left, Body, Icon } from 'native-base'; const cards = [ { text: 'Card One', name: 'One', image: require('./img/swiper-1.png'), }, . . . ]; export default class DeckSwiperAdvancedExample extends Component { render() { return (

<DeckSwiper ref={(c) => this._deckSwiper = c} dataSource={cards} renderEmpty={() => {% raw %}<View style={{ alignSelf: "center" }}>{% endraw %} Over } renderItem={item => {% raw %}<Card style={{ elevation: 3 }}>{% endraw %} {item.text} NativeBase {% raw %}<Image style={{ height: 300, flex: 1 }} source={item.image} />{% endraw %} {% raw %}<Icon name="heart" style={{ color: '#ED4A6A' }} />{% endraw %} {item.name} } /> {% raw %}<View style={{ flexDirection: "row", flex: 1, position: "absolute", bottom: 50, left: 0, right: 0, justifyContent: 'space-between', padding: 15 }}>{% endraw %} <Button iconLeft onPress={() => this._deckSwiper._root.swipeLeft()}> Swipe Left <Button iconRight onPress={() => this._deckSwiper._root.swipeRight()}> Swipe Right ); } } {%- language name="Vue Native", type="vue" -%} Swipe Left Swipe Right

<script> import React from "react"; import { View, Text } from "react-native"; import cardOne from "../../../../assets/swiper-1.png"; import CardComponent from "../common/card"; export default { data: function() { return { cardItemsArr: [ { text: "Card One", name: "One", image: cardOne }, . . . ], isLoopingRequired: false, stylesObj: { bottomBtnContainer: { flexDirection: "row", flex: 1, position: "absolute", bottom: 50, left: 0, right: 0, justifyContent: "space-between", padding: 15 } } }; }, methods: { handleCardEmpty: function() { return ( Over ); }, handleCardRendering: function(item) { return ; }, handleDeckSwiperBackBtn: function() { this.$refs._deckSwiper._root.swipeLeft(); }, handleDeckSwiperForwardBtn: function() { this.$refs._deckSwiper._root.swipeRight(); } } }; </script>

// Card Component {{item.text}} NativeBase {{item.name}}

<script> export default { props: { item: { type: Object } } }; </script>

{%- endcodetabs %}