diff --git a/package.json b/package.json index 368f10f..7b9c506 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "react-native-flip-countdown-timer", - "version": "0.0.3", - "description": "A Flip countdown timer implementation in React Native", + "name": "react-native-flip-countdown-timer-tl43", + "version": "0.0.4", + "description": "A Flip countdown timer implementation in React Native, modified by TL43", "main": "dist/react-native-flip-countdown-timer.cjs.js", "jsnext:main": "dist/react-native-flip-countdown-timer.esm.js", "module": "dist/react-native-flip-countdown-timer.esm.js", diff --git a/src/components/countdown-timer.js b/src/components/countdown-timer.js index dbc214a..cab37a6 100644 --- a/src/components/countdown-timer.js +++ b/src/components/countdown-timer.js @@ -3,7 +3,6 @@ import { View } from 'react-native'; import PropTypes from 'prop-types'; import FlipNumber from './flip-number'; -import Separator from './flip-number/separator'; import TransformUtils from '../utils'; @@ -60,11 +59,11 @@ class CountdownTimer extends React.Component { const { hours, minutes, seconds } = this.state; return ( - {!!hours && } - - {!!minutes && } - - {!!seconds && } + {!!hours && } + {/* */} + {!!minutes && } + {/* */} + {!!seconds && } ); } diff --git a/src/components/flip-number/index.js b/src/components/flip-number/index.js index 0a47225..bd10abf 100644 --- a/src/components/flip-number/index.js +++ b/src/components/flip-number/index.js @@ -9,13 +9,30 @@ import style from '../style'; function FlipNumber({ number, unit, size, perspective, numberWrapperStyle, cardStyle, flipCardStyle, numberStyle, + min, sec, }) { number = parseInt(number); - let previousNumber = number - 1; - if (unit !== 'hours') { - previousNumber = previousNumber === -1 ? 59 : previousNumber; - } else { - previousNumber = previousNumber === -1 ? 23 : previousNumber; + min = parseInt(min); + sec = parseInt(sec); + + let previousNumber = number; + if (unit === 'seconds') { + if (min === 0 && sec === 0) { + previousNumber = 0; + } else if (previousNumber === 0) { + previousNumber = 59; + } else { + previousNumber -= 1; + } + } else if (unit === 'minutes') { + if (sec === 0) { + previousNumber = 59; + } + } else { // hour + // eslint-disable-next-line no-lonely-if + if (min === 0 && number > 0) { + previousNumber -= 1; + } } number = number < 10 ? `0${number}` : number; previousNumber = previousNumber < 10 ? `0${previousNumber}` : previousNumber; @@ -64,6 +81,8 @@ FlipNumber.propTypes = { cardStyle: PropTypes.object, flipCardStyle: PropTypes.object, numberStyle: PropTypes.object, + min: PropTypes.string, + sec: PropTypes.string, }; export default FlipNumber;