时间轴组件react-native-step-indicator使用

栏目: 服务器 · 发布时间: 5年前

内容简介:最近在写公司的项目,因产品设计需求,需要类似如下的效果,像是一个时间轴本着不重复造轮子的目标,在最喜欢的github上找寻合适的组件,终于发现了一个非常棒的组件:

最近在写公司的项目,因产品设计需求,需要类似如下的效果,像是一个时间轴

时间轴组件react-native-step-indicator使用

本着不重复造轮子的目标,在最喜欢的github上找寻合适的组件,终于发现了一个非常棒的组件: react-native-step-indicator

使用就非常简单了

第一步,添加组件依赖,这里墙裂建议大家使用yarn管理项目依赖

yarn add react-native-step-indicator

第二步,在需要的页面导入react-native-step-indicator

import StepIndicator from 'react-native-step-indicator';

第三步,就是定义需要的数据及样式

const labels = ["填写认证信息","资料审核","认证完成"];
const customStyles = {
    stepIndicatorSize: 35,
    currentStepIndicatorSize:40,
    separatorStrokeWidth: 2,
    currentStepStrokeWidth: 3,
    stepStrokeCurrentColor: '#fe7013',
    stepStrokeWidth: 3,
    stepStrokeFinishedColor: '#fe7013',
    stepStrokeUnFinishedColor: '#aaaaaa',
    separatorFinishedColor: '#fe7013',
    separatorUnFinishedColor: '#aaaaaa',
    stepIndicatorFinishedColor: '#fe7013',
    stepIndicatorUnFinishedColor: '#ffffff',
    stepIndicatorCurrentColor: '#ffffff',
    stepIndicatorLabelFontSize: 13,
    currentStepIndicatorLabelFontSize: 13,
    stepIndicatorLabelCurrentColor: '#fe7013',
    stepIndicatorLabelFinishedColor: '#ffffff',
    stepIndicatorLabelUnFinishedColor: '#aaaaaa',
    labelColor: '#999999',
    labelSize: 13,
    currentStepLabelColor: '#fe7013'
}

时间轴组件react-native-step-indicator使用

labels数组定义的是时间轴上的节点值

第四步,在render函数中添加组件就完事了

<StepIndicator
                        stepCount={3}
                        customStyles={customStyles}
                        currentPosition={this.state.currentPosition}
                        labels={labels}
                    />

时间轴组件react-native-step-indicator使用

currentPosition设置当前时间轴的节点位置,over,来看一下最终的效果

时间轴组件react-native-step-indicator使用


以上所述就是小编给大家介绍的《时间轴组件react-native-step-indicator使用》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

联盟

联盟

里德•霍夫曼、本•卡斯诺查、克里斯•叶 / 路蒙佳 / 中信出版社 / 2015-2-5 / 39.00元

在充满变化的世界,联盟潜在的合伙人 将不确定的行业转变为可掌控的职业生涯 与世界紧密连接,开创精彩的事业与未来 终生效忠于一家公司已经成为历史,我们正在经历的自由雇佣制——将员工看作自由人——无法建立创新所需的高度信任与合作的关系。 互联网时代,企业如何用全新的人才策略定义员工的忠诚?未来职业成功的秘诀是什么? 《联盟》提供了一种使雇主与员工之间从商业交易转变为互惠关......一起来看看 《联盟》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具