1.0.3 • Published 2 years ago

react-native-progress-timer v1.0.3

Weekly downloads
10
License
ISC
Repository
github
Last release
2 years ago

react-native-progress-timer

React Native Timer component with progress indicator

progress-timer-demo-1 progress-timer-demo-2

Installation

$ npm install --save react-native-progress react-native-svg @react-native-community/art react-native-progress-timer

Usage

import Timer from 'react-native-progress-timer';
<Timer
    remainingTime={10}
    size={350}
    showsText={true}
    animated={true}
    direction={'counter-clockwise'}
    borderColor={'#d9dcdd'}
    borderWidth={3}
    thickness={5}
    color={'#faac02'}
    style={options.style}
    textStyle={options.textStyle}
    options={options}
></Timer>

Properties for Options

PropDescriptionDefault
viewStyle for Container{flexDirection: 'row', justifyContent: 'space-between', margin: 10}
highlightStyle for Touchable Highlight component{backgroundColor: '#ffffff'}
playStyle for Play component{underlayColor: '#ffffff',borderColor: '#d9dcdd',textStyle:{color: '#000000'},style: {backgroundColor: '#ffffff'}}
cancelStyle for Cancel component{underlayColor: '#ffffff',borderColor: '#d9dcdd',textStyle:{color: '#000000'},style: {backgroundColor: '#ffffff'}}

Properties for Timer Component (for more information refer to react-native-progress)

PropDescriptionDefault
animatedWhether or not to animate changes to progress.true
indeterminateIf set to true, the indicator will spin and progress prop will be ignored.false
indeterminateAnimationDurationSets animation duration in milliseconds when indeterminate is set.1000
colorFill color of the indicator.rgba(0, 122, 255, 1)
unfilledColorColor of the remaining progress.None
borderWidthWidth of outer border, set to 0 to remove.1
borderColorColor of outer border.color
sizeDiameter of the circle.350
endAngleDetermines the endAngle of the circle. A number between 0 and 1. The final endAngle would be the number multiplied by 2π0.9
thicknessThickness of the inner circle.3
showsTextWhether or not to show a text representation of current progress.true
textStyleStyles for progress text, defaults to a same color as circle and fontSize proportional to size prop.{ color: '#000000'}
allowFontScalingWhether or not to respect device font scale setting.true
directionDirection of the circle clockwise or counter-clockwise.clockwise
strokeCapStroke Cap style for the circle butt, square or round.butt
fillFill color of the inner circle.None (transparent)
remainingTimeTimer countdown - Mandatory0
hideCancelCircleHide cancel circlefalse
textCancelCircleCancel circle textCancel
sizeCancelCircleCancel circle size100
underlayColorCancelCircleCancel circle underlay color Mandatory#ffffff
hideStartCircleHide start circlefalse
textStartCircleStart circle textStart
sizeStartCircleStart circle size100
underlayStartCancelCircleCancel circle underlay color#ffffff

Example

import React from 'react'
import { SafeAreaView, StyleSheet, View } from 'react-native'
import Timer from 'react-native-progress-timer'

const App: () => React$Node = () => {
    return (
        <>
            <SafeAreaView>
                <View style={styles.body}>
                    <Timer
                        remainingTime={10}
                        size={350}
                        showsText={true}
                        animated={true}
                        direction={'counter-clockwise'}
                        borderColor={'#d9dcdd'}
                        borderWidth={3}
                        thickness={5}
                        color={'#faac02'}
                        style={options.style}
                        textStyle={options.textStyle}
                    ></Timer>
                </View>
            </SafeAreaView>
        </>
    )
}

const options = {
    style: {
        margin: 'auto',
    },
    textStyle: {
        color: '#000000',
    },
    view: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        margin: 10,
    },
    highlight: {
        backgroundColor: '#ffffff',
    },
    play: {
        underlayColor: '#ffffff',
        borderColor: '#d9dcdd',
        textStyle: {
            color: '#000000',
        },
        style: {
            backgroundColor: '#ffffff',
        },
    },
    cancel: {
        underlayColor: '#ffffff',
        borderColor: '#d9dcdd',
        textStyle: {
            color: '#000000',
        },
        style: {
            backgroundColor: '#ffffff',
        },
    },
}

const styles = StyleSheet.create({
    scrollView: {
        backgroundColor: Colors.lighter,
    },
    body: {
        backgroundColor: Colors.white,
        alignItems: 'center',
        alignContent: 'center',
    },
})