Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

12 Commits

Repository files navigation

rn-timer

Description

通用定时器组件,子控件可以自定义,由`Timer`来控制计时器的相关功能

本组件**不提供** 任何 UI 样式,只提供定时器功能。

Install

$ npm install rn-timer --save

Props

PropsTypeOptionaldefaultDescription
timestampnumber未来的某个时间戳(计时结束时间戳)
timerStepnumber时间跨度,1000则为1s
timerUnitnumberms(未启用)
bindersobject值映射对
timerFinishedListenerfunc计时器计时结束的回调

Usage

Class TimerExample

exportdefaultclassTimerExampleextendsComponent{render(){constbinder={// 值-func 映射hour: (date: Date)=>date.getUTCHours(),min: (date: Date)=>date.getMinutes(),second: (date: Date)=>date.getSeconds(),};return(<TimertimerStep={10}binders={binder}timestamp={newDate().getTime()+50000}timerFinishedListener={()=>{alert('end')}}>
// your cusotmer Timer Component
<TimerUI/></Timer>);}}

class TimerUI (Your customer component)

importReact,{Component}from'react';import{StyleSheet,Text,View}from'react-native';exportdefaultclassTimerUIextendsComponent{staticpropTypes: {
hour: React.PropTypes.number,min: React.PropTypes.number,second: React.PropTypes.number,}render(){const{hour, min, second}=this.propsreturn(<Viewstyle={{marginTop: 20,flexDirection: 'column'}}><Text>{`hour: ${hour}`}</Text><Text>{`min: ${min}`}</Text><Text>{`second: ${second}`}</Text></View>);}}

图片

About

A rn timer container

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages