-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
49 lines (46 loc) · 1.4 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React, { Component } from 'react';
import {StyleSheet,Text,View,TextInput,TouchableOpacity} from 'react-native';
export default class App extends Component {
state = {
password: '',
isPasswordVisible: true,
toggleText: 'Show',
};
handled = () => {
const { isPasswordVisible } = this.state;
if (isPasswordVisible) {
this.setState({ isPasswordVisible: false });
this.setState({ toggleText: 'Hide' });
} else {
this.setState({ isPasswordVisible: true });
this.setState({ toggleText: 'Show' });
}
};
render() {
return (
<View style={styles.container}>
<TextInput
secureTextEntry={this.state.isPasswordVisible}
style={styles.textInputStyle}
/>
<TouchableOpacity onPress={this.handled}>
<Text style={{fontSize: 20}}>{this.state.toggleText}</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
textInputStyle:{
width: 400,
height: 50,
backgroundColor: '#a7a6a9',
color: 'white',
fontSize: 20
},
});