import _ from 'lodash'; import React, {Component} from 'react'; import {ScrollView, StyleSheet} from 'react-native'; import {Typography, View, Text, MaskedInput, Button, Colors} from 'react-native-ui-lib'; //eslint-disable-line export default class MaskedInputScreen extends Component { minInput = React.createRef(); priceInput = React.createRef(); pinCodeInput = React.createRef(); state = { error: '', timeValue: '15' }; componentDidMount() { setTimeout(() => { this.minInput.current.focus(); }, 500); } clearInputs = () => { this.minInput.current.clear(); this.priceInput.current.clear(); this.pinCodeInput.current.clear(); }; renderTimeText(value: string) { const paddedValue = _.padStart(value, 4, '0'); const hours = paddedValue.substr(0, 2); const minutes = paddedValue.substr(2, 2); return ( {hours} h {minutes} m ); } renderPrice(value: string) { const hasValue = Boolean(value && value.length > 0); return ( - {hasValue ? value : '00'} $ ); } renderPINCode = (value = '') => { return ( {_.times(4, i => { return ( {value[i]} ); })} ); }; render() { const {timeValue} = this.state; return ( Masked Inputs Time Format value?.replace(/\D/g, '')} keyboardType={'numeric'} maxLength={4} initialValue={timeValue} // onChangeText={value => this.setState({timeValue: value})} /> Price/Discount value?.replace(/\D/g, '')} keyboardType={'numeric'} /> PIN Code value?.replace(/\D/g, '')} keyboardType={'numeric'} />