Numbers.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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}>{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:10,
  30. flex:1,
  31. flexDirection: 'row',
  32. justifyContent:'space-between',
  33. opacity:1
  34. },
  35. defaultInput: {
  36. width:62,
  37. height:21,
  38. borderWidth:1,
  39. borderColor: '#00000030',
  40. borderRadius:14,
  41. paddingLeft: 10,
  42. paddingRight: 10
  43. }
  44. })