Remove number limit

This commit is contained in:
Adw8 2024-02-21 18:18:01 +05:30
parent 9dbe7574d2
commit 564404af45
2 changed files with 33 additions and 38 deletions

View File

@ -1,9 +1,10 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { ScrollView, View, Text, StyleSheet } from 'react-native'; import { ScrollView, View, Text } from 'react-native';
import { Button, TextInput } from 'react-native-paper'; import { Button, TextInput } from 'react-native-paper';
import { addAccountFromHDPath } from '../utils/Accounts'; import { addAccountFromHDPath } from '../utils/Accounts';
import { Account, PathState } from '../types'; import { Account, PathState } from '../types';
import styles from '../styles/stylesheet';
const HDPath = ({ const HDPath = ({
pathCode, pathCode,
@ -26,7 +27,7 @@ const HDPath = ({
const handleChange = (key: keyof PathState, value: string) => { const handleChange = (key: keyof PathState, value: string) => {
setPath({ setPath({
...path, ...path,
[key]: value.replace(/[^0-9]/g, ''), // Allow only numeric characters [key]: value.replace(/[^0-9]/g, ''),
}); });
}; };
@ -50,37 +51,34 @@ const HDPath = ({
}; };
return ( return (
<ScrollView style={styles.container}> <ScrollView style={styles.HDcontainer}>
<View style={styles.rowContainer}> <View style={styles.HDrowContainer}>
<Text style={styles.text}>{pathCode}</Text> <Text style={styles.HDtext}>{pathCode}</Text>
<TextInput <TextInput
keyboardType="numeric" keyboardType="numeric"
mode="outlined" mode="outlined"
onChangeText={text => handleChange('firstNumber', text)} onChangeText={text => handleChange('firstNumber', text)}
value={path.firstNumber} value={path.firstNumber}
style={styles.textInput} style={styles.HDtextInput}
maxLength={1}
/> />
<Text style={styles.text}>'/</Text> <Text style={styles.HDtext}>'/</Text>
<TextInput <TextInput
keyboardType="numeric" keyboardType="numeric"
mode="outlined" mode="outlined"
onChangeText={text => handleChange('secondNumber', text)} onChangeText={text => handleChange('secondNumber', text)}
value={path.secondNumber} value={path.secondNumber}
style={styles.textInput} style={styles.HDtextInput}
maxLength={1}
/> />
<Text style={styles.text}>/</Text> <Text style={styles.HDtext}>/</Text>
<TextInput <TextInput
keyboardType="numeric" keyboardType="numeric"
mode="outlined" mode="outlined"
onChangeText={text => handleChange('thirdNumber', text)} onChangeText={text => handleChange('thirdNumber', text)}
value={path.thirdNumber} value={path.thirdNumber}
style={styles.textInput} style={styles.HDtextInput}
maxLength={1}
/> />
</View> </View>
<View style={styles.buttonContainer}> <View style={styles.HDbuttonContainer}>
<Button <Button
mode="contained" mode="contained"
onPress={createFromHDPathHandler} onPress={createFromHDPathHandler}
@ -92,28 +90,4 @@ const HDPath = ({
); );
}; };
const styles = StyleSheet.create({
container: {
marginTop: 24,
paddingHorizontal: 8,
},
rowContainer: {
flexDirection: 'row',
alignItems: 'center',
},
text: {
color: 'black',
fontSize: 18,
padding: 10,
},
textInput: {
flex: 1,
},
buttonContainer: {
marginTop: 20,
width: 200,
alignSelf: 'center',
},
});
export default HDPath; export default HDPath;

View File

@ -81,6 +81,27 @@ const styles = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
justifyContent: 'flex-start', justifyContent: 'flex-start',
}, },
HDcontainer: {
marginTop: 24,
paddingHorizontal: 8,
},
HDrowContainer: {
flexDirection: 'row',
alignItems: 'center',
},
HDtext: {
color: 'black',
fontSize: 18,
margin: 4,
},
HDtextInput: {
flex: 1,
},
HDbuttonContainer: {
marginTop: 20,
width: 200,
alignSelf: 'center',
},
}); });
export default styles; export default styles;