Numbers.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React, { useState } from 'react';
  2. import {View , Text, TextInput, Button,StyleSheet} from 'react-native';
  3. import { Icon } from 'react-native-elements'
  4. export default function Numbers(props) {
  5. let [number , setNumber] = useState(props.number || '')
  6. let title = props.title || "Input";
  7. return(
  8. <View style={styles.container}>
  9. <Text style={[styles.title, styles.capFirst]}>{title}</Text>
  10. <TextInput
  11. onChangeText={(number) => {
  12. try{
  13. number = parseInt(number);
  14. } catch(e) {
  15. return;
  16. }
  17. props.onChange && props.onChange(number);
  18. setNumber(number);
  19. }}
  20. keyboardType={'numeric'}
  21. value={number.toString()}
  22. style={[styles.defaultInput]}
  23. />
  24. </View>
  25. )
  26. }
  27. const styles = StyleSheet.create({
  28. container:{
  29. padding:24,
  30. paddingTop: 0,
  31. flex:1,
  32. flexDirection: 'row',
  33. justifyContent:'space-between',
  34. opacity:1,
  35. alignItems: 'baseline'
  36. },
  37. capFirst: {
  38. fontSize: 14,
  39. fontFamily: 'roboto-light',
  40. textTransform: 'capitalize'
  41. },
  42. defaultInput: {
  43. width:62,
  44. height:21,
  45. borderWidth:1,
  46. backgroundColor: 'white',
  47. borderColor: '#00000030',
  48. borderRadius:14,
  49. paddingLeft: 10,
  50. paddingRight: 10
  51. }
  52. })