88} from "react-native" ;
99import PropTypes from "prop-types" ;
1010import { Style , defaultColor } from "./Style" ;
11- import { debounce , isNumeric , isEmpty } from "./Utils" ;
11+ import { debounce , isNumeric , isEmpty , isCallable } from "./Utils" ;
1212
1313/**
1414 * Default constants
@@ -197,7 +197,7 @@ class InputSpinner extends Component {
197197 * @param number
198198 */
199199 onIncrease ( number ) {
200- if ( this . _isCallable ( this . props . onIncrease ) ) {
200+ if ( isCallable ( this . props . onIncrease ) ) {
201201 return this . props . onIncrease ( number ) ;
202202 }
203203 return true ;
@@ -208,7 +208,7 @@ class InputSpinner extends Component {
208208 * @param number
209209 */
210210 onDecrease ( number ) {
211- if ( this . _isCallable ( this . props . onDecrease ) ) {
211+ if ( isCallable ( this . props . onDecrease ) ) {
212212 return this . props . onDecrease ( number ) ;
213213 }
214214 return true ;
@@ -219,7 +219,7 @@ class InputSpinner extends Component {
219219 * @param number
220220 */
221221 onMax ( number ) {
222- if ( this . _isCallable ( this . props . onMax ) ) {
222+ if ( isCallable ( this . props . onMax ) ) {
223223 this . props . onMax ( number ) ;
224224 }
225225 this . _resetHoldTime ( ) ;
@@ -230,7 +230,7 @@ class InputSpinner extends Component {
230230 * @param number
231231 */
232232 onMin ( number ) {
233- if ( this . _isCallable ( this . props . onMin ) ) {
233+ if ( isCallable ( this . props . onMin ) ) {
234234 this . props . onMin ( number ) ;
235235 }
236236 this . _resetHoldTime ( ) ;
@@ -241,7 +241,7 @@ class InputSpinner extends Component {
241241 * @param number
242242 */
243243 onLongPress ( number ) {
244- if ( this . _isCallable ( this . props . onLongPress ) ) {
244+ if ( isCallable ( this . props . onLongPress ) ) {
245245 this . props . onLongPress ( number ) ;
246246 }
247247 }
@@ -301,7 +301,7 @@ class InputSpinner extends Component {
301301 num = parsedNum = null ;
302302 }
303303
304- if ( this . state . value !== num && this . _isCallable ( this . props . onChange ) ) {
304+ if ( this . state . value !== num && isCallable ( this . props . onChange ) ) {
305305 const res = await this . props . onChange ( parsedNum ) ;
306306 if ( ! isEmptyValue ) {
307307 if ( res === false ) {
@@ -348,7 +348,7 @@ class InputSpinner extends Component {
348348 * @param e
349349 */
350350 onSubmit ( e ) {
351- if ( this . _isCallable ( this . props . onSubmit ) ) {
351+ if ( isCallable ( this . props . onSubmit ) ) {
352352 this . props . onSubmit ( this . _parseNum ( e . nativeEvent . text ) ) ;
353353 }
354354 }
@@ -748,19 +748,6 @@ class InputSpinner extends Component {
748748 this . textInput . clear ( ) ;
749749 }
750750
751- /**
752- * Is variable callable
753- * @private
754- * @param callback
755- * @returns {boolean }
756- */
757- _isCallable ( callback ) {
758- return (
759- callback != null &&
760- ( callback instanceof Function || typeof callback === "function" )
761- ) ;
762- }
763-
764751 /**
765752 * Is text input editable
766753 * @returns {boolean|Boolean }
@@ -945,12 +932,13 @@ class InputSpinner extends Component {
945932 * @private
946933 */
947934 _getContainerStyle ( ) {
935+ const backgroundColor = this . props . colorAsBackground ? this . _getColor ( ) : this . props . background ;
948936 return [
949937 Style . container ,
950938 {
951939 minHeight : this . props . height ,
952940 width : this . props . width ,
953- backgroundColor : this . props . background ,
941+ backgroundColor : backgroundColor ,
954942 } ,
955943 this . props . showBorder
956944 ? { borderWidth : 0.5 , borderColor : this . _getColor ( ) }
@@ -1239,6 +1227,7 @@ InputSpinner.propTypes = {
12391227 colorLeft : PropTypes . string ,
12401228 colorMax : PropTypes . string ,
12411229 colorMin : PropTypes . string ,
1230+ colorAsBackground : PropTypes . bool ,
12421231 background : PropTypes . string ,
12431232 textColor : PropTypes . string ,
12441233 arrows : PropTypes . bool ,
@@ -1333,6 +1322,7 @@ InputSpinner.defaultProps = {
13331322 colorPress : defaultColor ,
13341323 colorRight : defaultColor ,
13351324 colorLeft : defaultColor ,
1325+ colorAsBackground : false ,
13361326 background : "transparent" ,
13371327 textColor : "#000000" ,
13381328 arrows : false ,
0 commit comments