Numbers.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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={[{outline:'none',background:"#FFFFFF"},styles.defaultInput]}
  23. />
  24. </View>
  25. )
  26. }
  27. /*
  28. width: 62px;
  29. height: 21px;
  30. background: #FFFFFF 0% 0% no-repeat padding-box;
  31. border-radius: 14px;
  32. opacity: 1;
  33. */
  34. const styles = StyleSheet.create({
  35. container:{
  36. padding:10,
  37. flex:1,
  38. opacity:1
  39. },
  40. defaultInput: {
  41. width:62,
  42. height:21,
  43. borderWidth:1,
  44. borderRadius:14,
  45. }
  46. })