Cocina

Cocina

  • 文档
  • UI组件
  • API
  • 帮助
  • 博客

›组件

起步

  • 集合

组件

  • 结构
  • 手风琴
  • 浮动弹层
  • 角标
  • 按钮
  • 卡片
  • 复选框
  • 日期选择
  • 滑动的卡片
  • 浮动按钮
  • 底部选项卡
  • 表单
  • 顶部栏
  • 图标
  • 列表
  • 选择器
  • 单选
  • 搜索栏
  • 分段器
  • 加载器
  • 缩略图
  • 吐司
  • 标题大小
  • 抽屉滑动
  • 关联组件

滑动的卡片

DeckSwiper 滑动的卡片

句法

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 (
      <Container>
        <Header />
        <View>
          <DeckSwiper
            dataSource={cards}
            renderItem={item =>
              <Card style={{ elevation: 3 }}>
                <CardItem>
                  <Left>
                    <Thumbnail source={item.image} />
                    <Body>
                      <Text>{item.text}</Text>
                      <Text note>NativeBase</Text>
                    </Body>
                  </Left>
                </CardItem>
                <CardItem cardBody>
                  <Image style={{ height: 300, flex: 1 }} source={item.image} />
                </CardItem>
                <CardItem>
                  <Icon name="heart" style={{ color: '#ED4A6A' }} />
                  <Text>{item.name}</Text>
                </CardItem>
              </Card>
            }
          />
        </View>
      </Container>
    );
  }
}

属性:

属性默认值选项描述
dataSource-Userdefined object Chunk of data(object)
renderEmptyFunction-Callback that is called when all the cards are swiped and dataSource is empty and returns a component.
renderItemFunction-Callback which takes a chunk of data and returns a component.
renderTopFunction-Callback which takes a chunk of data and returns top layer component.
renderBottomFunction-Callback which takes a chunk of data and returns bottom layer component.
looping truebooleanLoopthrough the data
onSwipeRightFunction-Callback that is called when the Card is swiped Right
onSwipeLeftFunction-Callback that is called when the Card is swiped Left

Advanced Deck Swiper 高级滑动的卡片

用法:

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 (
      <Container>
        <Header />
        <View>
          <DeckSwiper
            ref={(c) => this._deckSwiper = c}
            dataSource={cards}
            renderEmpty={() =>
              <View style={{ alignSelf: "center" }}>
                <Text>Over</Text>
              </View>
            renderItem={item =>
              <Card style={{ elevation: 3 }}>
                <CardItem>
                  <Left>
                    <Thumbnail source={item.image} />
                    <Body>
                      <Text>{item.text}</Text>
                      <Text note>NativeBase</Text>
                    </Body>
                  </Left>
                </CardItem>
                <CardItem cardBody>
                  <Image style={{ height: 300, flex: 1 }} source={item.image} />
                </CardItem>
                <CardItem>
                  <Icon name="heart" style={{ color: '#ED4A6A' }} />
                  <Text>{item.name}</Text>
                </CardItem>
              </Card>
            }
          />
        </View>
        <View style={{ flexDirection: "row", flex: 1, position: "absolute", bottom: 50, left: 0, right: 0, justifyContent: 'space-between', padding: 15 }}>
          <Button iconLeft onPress={() => this._deckSwiper._root.swipeLeft()}>
            <Icon name="arrow-back" />
            <Text>Swipe Left</Text>
          </Button>
          <Button iconRight onPress={() => this._deckSwiper._root.swipeRight()}>
            <Icon name="arrow-forward" />
            <Text>Swipe Right</Text>
          </Button>
        </View>
      </Container>
    );
  }
}
← PreviousNext →
  • DeckSwiper 滑动的卡片
  • Advanced Deck Swiper 高级滑动的卡片
Cocina
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2019 Your Name or Your Company Name