-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
93 lines (71 loc) · 1.7 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React, {Component} from 'react';
import { StyleSheet, Text, View,TextInput,TouchableOpacity } from 'react-native';
import {constants} from 'expo';
export default class App extends React.Component {
constructor(props){
super(props)
this.state= {
text:"",
todo : []
}
};
addTodo (){
let todo = this.state.todo;
todo.push(this.state.text)
this.setState({
todo: todo,
text: ''
})
}
render() {
return (
<View style={styles.container}>
<View style={styles.view1}>
<TextInput style = {styles.inputText} onChangeText={(text) => {this.setState({text: text})}}
value = {this.state.text} />
<TouchableOpacity onPress={this.addTodo.bind(this)}>
<Text style= {styles.addButton} >+
</Text>
</TouchableOpacity>
</View>
<View>
{this.state.todo.map((text, index) => {
return (
<Text style={styles.todoView} key={index.toString()}>
{text}
</Text>
)
})}
</View>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#124',
padding: 10
},
inputText:
{
flex:1,
},
addButton:{
fontSize:30,
fontWeight: "bold",
},
view1: {
flexDirection : 'row',
backgroundColor : 'white',
alignItems :'center',
padding : 5,
paddingLeft:10,
borderWidth : 1,
borderRadius : 100
},
todoView:{
fontSize:30,
fontWeight: "bold",
color:"#ffffff",}
});