1.1.1 • Published 5 years ago

react-native-counter-timer v1.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

React Native Counter Timer

Advance Counter timer for React Native using react-native progress, react-native-background-timer and react-native-linear-gradient

Installation

 

iOS,

Step 1 - Install library

npm i react-native-counter-timer --save 

or

yarn add react-native-counter-timer

Step 2 - Add it to your project

You need to include the ART library in your project on iOS, for android it's already included.

For CocoaPod users:

Add these 2 and and then run pod install in ios directory:

pod 'React-ART', :path => '../node_modules/react-native/Libraries/ART'
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
Or manually:

React ART based components,

BVLinearGradient component, 1. Open your project in XCode, right click on Libraries and click Add Files to "Your Project Name" Look under node_modules/react-native-linear-gradient and add BVLinearGradient.xcodeproj. (Screenshot 1) (Screenshot 2). 2. Add libBVLinearGradient.a to Build Phases -> Link Binary With Libraries (Screenshot 1) (Screenshot 2). 3. Click on BVLinearGradient.xcodeproj in Libraries and go the Build Settings tab. Double click the text to the right of Header Search Paths and verify that it has $(SRCROOT)/../react-native/React - if it isn't, then add it. This is so XCode is able to find the headers that the BVLinearGradient source files are referring to by pointing to the header files installed within the react-native node_modules directory. (Screenshot).

Step 3 - Add background timer

Using CocoaPod:

Add this and and then run pod install in ios directory:

pod 'react-native-background-timer', :path => '../node_modules/react-native-background-timer'

npm.io npm.io

Usage - Basic

import RNTimer from "react-native-counter-timer";

const timer = {
  restTimeHours: 0,
  restTimeMinutes: 0,
  restTimeSeconds: 7,
  activiTimeHours: 0,
  activeTimeMinutes: 0,
  activeTimeSeconds: 8,
  sets: 7,
 };

 <RNTimer 
  timer={timer}
  />

Props

Timer

PropsDescriptionTypeDefault Values
runInBackgroundRun timer in backgroundbooltrue

Controller

PropsDescriptionTypeDefault Values
controllerButtons3 controller buttons and swap the values in the array to change the button orderarray'RESET', 'PRIMARY_ACTION', 'SKIP'
controllerPositioncontroller position at 'TOP'or 'BOTTOM'String'BOTTOM'
controlsWrapperStyleWrapper style of controllerObject{flexDirection: 'row',justifyContent: 'space-around',paddingBottom: 10,paddingTop: 10,}

Controller - Reset Button

PropsDescriptionTypeDefault Values
controllerResetTextReset button textString'RESET'
controllerResetButtonTextStyleReset button text styleObject{color: '#0086C6',fontSize: 16}
controllerResetButtonStyleReset button styleObject{paddingTop: 10,alignItems: 'center',flex: 1}
controllerDisabledResetButtonTextStyleReset button text style when button is disableObjectnull
controllerDisabledResetButtonStyleReset button style when when button is disableObjectnull
controllerResetButtonElementReact native element inside the reset buttonObjectnull

Controller - Skip Button

PropsDescriptionTypeDefault Values
controllerSkipButtonTextSkip Button textString'SKIP'
controllerSkipButtonStyleSkip button text styleObject{paddingTop: 10,alignItems: 'center',flex: 1,}
controllerDisabledSkipButtonTextStyleSkip button text style when button is disabledObjectnull
controllerDisabledSkipButtonStyleSkip button style when button is disabledObjectnull
controllerSkipButtonElementReact native element inside the skip buttonObjectnull

Controller - Action Button (first)

PropsDescriptionTypeDefault Values
controllerMainPrimaryActionButtonStyleStyle of main primary buttonObjectnull
controllerMainPrimaryActionDisabledButtonStyleStyle of main primary button when disableObjectnull
controllerMainPrimaryActionButtonElementReact native element inside primary action buttonObjectnull

Controller - Action Button (Second)

PropsDescriptionTypeDefault Values
controllerSecondPrimaryActionButtonTextStyleStyle of second primary actionObjectnull
controllerSecondPrimaryActionButtonStyleStyle of second primary action button styleObjectnull
controllerSecondPrimaryActionButtonElementReact native element inside second primary action buttonObjectnull

Progress

PropsDescriptionTypeDefault Values
progressAnimationIf the circle should animatebooltrue
progressBorderWidthNumber0
progressDirectionDirection of the circle clockwise or counter-clockwiseString'counter-clockwise'
progressStyleProgress StyleObject{alignItems: 'center',justifyContent: 'center',}
progressThicknessThickness of the circle.Number4
progressVisibleWhether or not to visible progress barbooltrue
progressSizeDiameter of the circleNumber140
progressWrapperOverride the style of progress circle wrapperObject{ paddingTop: 30}
progressPrimaryStatusColorProgress color when timer in primary statusObject'#31708E'
progressSecondaryStatusColorProgress color when timer in secondary statusObject'#E85A4F'

Counter

PropsDescriptionTypeDefault Values
counterTimerDisplay order of hours, minutes and seconds. swap the value to change the order or remove. Ex: 'SECONDS', 'MINUITES'array'HOURS', 'MINUITES', 'SECONDS'
counterTextsDisplay order of max timer, timer and sets. Swap the value in array to change the order or removearray'MAX_TIME', 'TIMER', 'SET' }

Counter - Set

PropsDescriptionTypeDefault Values
counterSetSeperatorTextSymbol to seperate between counter set text and numberString'/'
counterSetTextText of counter setString'Set'
counterSetTextWrapperStyleWrapper style of counter textObject{fontSize: 20, color: 'black'}

Counter - Status

PropsDescriptionTypeDefault Values
counterTimerDefaultStatusTextCounter timer text value before start the timerString'Default'
counterTimerPrimaryStatusTextCounter timer text value when timer in primary statusString'primary'
counterTimerSecondaryStatusTextCounter timer text value when timer in secondary statusString'secondary'

Gradient Color

PropsDescriptionTypeDefault Values
gradientColorsDefaultGradient color of timer container before start the timerObject''rgba(255, 255, 255, 0)', 'rgba(255, 255, 255, 0)''
gradientColorsRepsActiveGradient color of timer container when timer is in primary modeObject''rgba(255, 255, 255, 0)', 'rgba(255, 255, 255, 0)''
gradientColorsRestActiveGradient color of timer container when timer is in Secondary modeObject''rgba(255, 255, 255, 0)', 'rgba(255, 255, 255, 0)''

More info - https://github.com/react-native-community/react-native-linear-gradient

Events

PropsDescriptionDefault Values
onActivityCompletedInvoke after completed the timernull
onSecondaryModeEndInvoke when secondary mode endnull
onPrimaryModeStartPressedInvoke when press start button in primary modenull
onSecondaryModePausePressedInvoke when press pause button in secondary modenull
onPrimaryModePausePressedInvoke when presss pause button in primary modenull
onSecondaryModeStartPressedInvoke when press start button in secondary modenull
onSkipPressedInvoke when press skip buttonnull

Contributor guidelines

  • Fork the repository.
  • Clone the forked repository.
  • Create your own branch.
  • Create a pull request with changes made.

License

MIT

Free Software, Hell Yeah!

1.1.1

5 years ago

1.1.0

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago