Troila Mobile Ui

Troila Mobile Ui

  • Docs
  • API
  • Help
  • Blog

›Components

Troila Mobile Ui

  • Getting Started

Components

  • Text
  • ListView
  • List
  • TextInput
  • InputItem
  • Step
  • SpringAnimatedView

卓朗云桌面-内部组件

  • request (请求类)
  • BackgroundButton
  • ExtendsBackButton
  • HeaderTitleButton
  • HeaderImageButton
  • 注意事项
  • 不同平台和设备的入口

ListView

基于react-native的FlatList的封装

注:暂时不要声明自troila-mobile-ui,优先声明自本地的components/theme中

规则

  • 支持mock来处理渲染
  • 统一添加了RefreshControl用来刷新效果
  • 支持上拉加载,下拉刷新
  • api简洁高效
  • 注:请求封装已完成,使用中有问题请随时沟通

Example

iOS Android

Code

import React, { Component } from 'react';
import { Text } from 'react-native';
import { ListView } from 'troila-mobile-ui';



class ListViewInANest extends Component {
  render() {
    if(mock){
      return (
        <ListView
          mockData={[
              {
                  id:1,
                  text: 1,
              }, {
                  id: 2,
                  text: 2,
              }, {
                  id: 3,
                  text: 3,
              }
          ]}
          keyExtractor={(e)=>`${e.id}`}
          renderItem={({ item})=>{
              return <Text>{item.text} testData</Text>
          }}
        />
      )
    }else{
      return (
        <ListView
          apiName={'LISTGETALIVEMACHLISTWITHPAGEANDINTEGRATE'}
          fetchParams={{realName:'xxx'}}
          numColumns={2}
          keyExtractor={(e) => `${e.funcId}`}
          renderItem={this.renderItem}
          ref={(e)=>this.ListView=e}
        />
      )
    }
  }
  testFunc = ()=>{
    this.ListView.setFetchParams({
        id: 1
    })
  }
}


Props

属性说明类型默认值
apiName请求接口的标识,同request的apiName一致Stringnull
fetchParams请求参数(注:默认配置分页参数,不需要手动添加)Object{}
listEmptyComponent空数据的展示组件ElementView
getNativeData获取请求返回的数据Function()=>{}
onRefresh下拉刷新触发Function()=>{}
onEndReached上拉加载触发Function()=>{}
contentContainerStyle容器样式Style{}
style最外层样式Style{}
changeDataStructurese改变数据源Functon()=>{}
mockDatamock数据Arraynull
renderItem渲染cellFunctionnull
keyExtractor指定keyFunctionnull
closeRefreshing关闭下拉刷新Booleanfalse
other propsFlatList props

Methods

setFetchParams()

this.ListView.setFetchParams({
  id: 1
})

设置参数重新请求


manuallyRefresh()

this.ListView.manuallyRefresh()

主动刷新

更多 react-native FlatList 属性请参考 react-native FlatList (http://facebook.github.io/react-native/docs/flatlist.html)

← TextList →
  • 规则
  • Example
  • Code
  • Props
  • Methods
    • setFetchParams()
    • manuallyRefresh()
Troila Mobile Ui
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 © 2018 Your Name or Your Company Name