Commit 7451ff69 by Tonk

add hide/show password

parent 0fe96d16
...@@ -12,10 +12,12 @@ const InputField = ({ ...@@ -12,10 +12,12 @@ const InputField = ({
placeholder, placeholder,
errors, // this array prop is automatically passed down to this component from <Form /> errors, // this array prop is automatically passed down to this component from <Form />
isPass, isPass,
passVisible,
onPressEye,
}) => { }) => {
return ( return (
<View> <View>
<View> <View style={theme.inputContainer}>
<TextInput <TextInput
value={value && value} value={value && value}
onChangeText={onChangeText ? val => onChangeText(val) : null} onChangeText={onChangeText ? val => onChangeText(val) : null}
...@@ -23,8 +25,16 @@ const InputField = ({ ...@@ -23,8 +25,16 @@ const InputField = ({
placeholderTextColor={color.grey2} placeholderTextColor={color.grey2}
disabled={disabled} disabled={disabled}
style={customStyle ? customStyle : {}} style={customStyle ? customStyle : {}}
secureTextEntry={isPass} secureTextEntry={!passVisible}
/>
<View style={{ flexDirection: 'row', alignItems: 'flex-end' }}>
{isPass && (
<Icon
onPress={onPressEye}
name={passVisible ? 'eye' : 'eye-off'}
style={[theme.inputPassVisible]}
/> />
)}
{errors && {errors &&
errors.length > 0 && errors.length > 0 &&
...@@ -34,6 +44,7 @@ const InputField = ({ ...@@ -34,6 +44,7 @@ const InputField = ({
) : null ) : null
)} )}
</View> </View>
</View>
{errors && {errors &&
errors.length > 0 && errors.length > 0 &&
errors.map((item, index) => errors.map((item, index) =>
......
...@@ -26,10 +26,10 @@ export const theme = StyleSheet.create({ ...@@ -26,10 +26,10 @@ export const theme = StyleSheet.create({
marginBottom: 10, marginBottom: 10,
}, },
inputContainer: { inputContainer: {
flex: 1, borderBottomWidth: 1,
flexDirection: 'row', flexDirection: 'row',
alignItems: 'flex-end', justifyContent: 'space-between',
justifyContent: 'center', borderBottomColor: color.inputBorder,
}, },
container: { container: {
flex: 1, flex: 1,
...@@ -49,9 +49,9 @@ export const theme = StyleSheet.create({ ...@@ -49,9 +49,9 @@ export const theme = StyleSheet.create({
marginTop: 25, marginTop: 25,
paddingBottom: 5, paddingBottom: 5,
color: color.grey1, color: color.grey1,
borderBottomWidth: 1, // borderBottomWidth: 1,
fontFamily: 'Avenir-Roman', fontFamily: 'Avenir-Roman',
borderBottomColor: color.inputBorder, // borderBottomColor: color.inputBorder,
}, },
inputErrText: { inputErrText: {
bottom: -15, bottom: -15,
...@@ -76,10 +76,14 @@ export const theme = StyleSheet.create({ ...@@ -76,10 +76,14 @@ export const theme = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
}, },
inputErrIcon: { inputErrIcon: {
right: 5, marginBottom: 5,
bottom: 0, marginLeft: 10,
fontSize: 20, fontSize: 20,
color: color.red1, color: color.red1,
position: 'absolute', },
inputPassVisible: {
marginBottom: 5,
fontSize: 20,
color: '#d8d8d8',
}, },
}); });
...@@ -29,6 +29,8 @@ const styles = StyleSheet.create({ ...@@ -29,6 +29,8 @@ const styles = StyleSheet.create({
export default class LoginScreen extends Component { export default class LoginScreen extends Component {
state = { state = {
isCheck: false, isCheck: false,
pass: '',
passVisible: false,
}; };
submitForm() { submitForm() {
...@@ -90,6 +92,8 @@ export default class LoginScreen extends Component { ...@@ -90,6 +92,8 @@ export default class LoginScreen extends Component {
customStyle={theme.input} customStyle={theme.input}
placeholder="Password" placeholder="Password"
isPass={true} isPass={true}
passVisible={this.state.passVisible}
onPressEye={() => this.setState({ passVisible: !this.state.passVisible })}
/> />
</Form> </Form>
<Row style={{ marginTop: 30 }}> <Row style={{ marginTop: 30 }}>
......
...@@ -26,6 +26,8 @@ export default class RegisterScreen extends Component { ...@@ -26,6 +26,8 @@ export default class RegisterScreen extends Component {
password: '', password: '',
cfPassword: '', cfPassword: '',
phoneNum: '', phoneNum: '',
passVisible: false,
cfPassVisible: false,
}; };
submitForm() { submitForm() {
...@@ -117,6 +119,8 @@ export default class RegisterScreen extends Component { ...@@ -117,6 +119,8 @@ export default class RegisterScreen extends Component {
customStyle={theme.input} customStyle={theme.input}
placeholder="Password" placeholder="Password"
isPass={true} isPass={true}
passVisible={this.state.passVisible}
onPressEye={() => this.setState({ passVisible: !this.state.passVisible })}
/> />
{/* ---cf password--- */} {/* ---cf password--- */}
<Field <Field
...@@ -129,6 +133,8 @@ export default class RegisterScreen extends Component { ...@@ -129,6 +133,8 @@ export default class RegisterScreen extends Component {
customStyle={theme.input} customStyle={theme.input}
placeholder="Confirm password" placeholder="Confirm password"
isPass={true} isPass={true}
passVisible={this.state.cfPassVisible}
onPressEye={() => this.setState({ cfPassVisible: !this.state.cfPassVisible })}
/> />
{/* ---phone no--- */} {/* ---phone no--- */}
<Field <Field
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment