1.1.0 • Published 4 years ago

react-native-popcountdown v1.1.0

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

react-native-popcountdown

React Native PopCountDown

Installation

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

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-popcountdown';

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

Custom Styling Example

Code

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

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-popcountdown';

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-popcountdown';
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}
/>

Change Log

removed showSeparator variable
------ indivisualy it will show time tag (h m s) after the digit
added showLeftKeyword variable
------ leftKeywordStyle

in future we will add new separator style

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

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago