1.0.2 • Published 3 years ago

react-native-reverse v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-native-reverse

React Native Time Reveres countdown

Installation

Run npm i react-native-reverse --save OR yarn add react-native-reverse

Props

NameDescriptionTypeDefault Value
idCounter id, to determine whether to reset the counter or notstringnull
styleOverride the component styleobject{}
digitStyleDigit styleobject{backgroundColor: #FAB913 '#FAB913'}
digitTxtStyleDigit Text styleobject{color: #FAB913 '#000'}
timeLabelStyleTime Label styleobject{color: #FAB913 '#000'}
sizeSize of the countdown componentnumber15
untilNumber of seconds to countdownnumber0
onFinishWhat function should be invoked when the time is 0funcnull
onChangeWhat function should be invoked when the timer is changingfuncnull
onPressWhat function should be invoked when clicking on the timerfuncnull
timeToShowWhat Digits to showarray'D', 'H', 'M', 'S'
timeLabelsText to show in time labelobject{d: 'Days', h: 'Hours', m: 'Minutes', s: 'Seconds'}
runninga boolean to pause and resume the componentbooltrue
showLeftKeyworda boolean to show Left Textbooltrue

Code

import {Countdown} from 'react-native-reverse';

render() {
    return (
      <Countdown
        until={10}
        onFinish={() => alert('finished')}
        onPress={() => alert('Pressed')}
        size={18}
      />
    )
}

Custom Styling Example

Code

import {Countdown} from 'react-native-reverse';

render() {
    return (
      <Countdown
        until={60 * 10 + 30}
        size={30}
        onFinish={() => alert('Finished')}
        digitStyle={{backgroundColor: '#FFF'}}
        digitTxtStyle={{color: '#333333'}}
        timeToShow={['M', 'S']}
        timeLabels={{m: 'MM', s: 'SS'}}
      />
    )
}

Separator Example

Code

import {Countdown} from 'react-native-reverse';

render() {
    return (
      <Countdown
        size={30}
        until={1000}
        onFinish={() => alert('Finished')}
        digitStyle={{backgroundColor: '#FFF'}}
        digitTxtStyle={{color: '#211111'}}
        timeLabelStyle={{color: 'red', fontWeight: 'bold'}}
        timeToShow={['H', 'M', 'S']}
        timeLabels={{h:null, m: null, s: null}}
      />
    )
}

You can use moment library to convert time.

install that library first.

Example

for Reverse Time countdown

import {Countdown} from 'react-native-reverse';
import Moment from 'moment'

Moment("2020-04-05T20:00:00Z").unix() - Moment().unix()

<Countdown
   until={Moment("2020-04-05T20:00:00Z").unix() - Moment().unix()}
   onFinish={() => <Text>Live</Text>}
   digitStyle={{}}
   digitTxtStyle={{ color: '#444' }}
   timeToShow={['D', 'H', 'M', 'S']}
   size={12}
   showLeftKeyword={true}
   LeftStyle={{color:'#c22222'}}
   running={true}
/>

Thank you for support Please share if you like this project.