-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
59 lines (53 loc) · 1.26 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
import React, { Component } from "react";
import { StyleSheet, Text, View, TextInput } from "react-native";
import TodoTask from "./TodoTask";
export default class App extends Component {
state = { tasks: [] };
onAddTask(event) {
const taskDescription = event.nativeEvent.text;
this.setState({
tasks: [...this.state.tasks, { description: taskDescription }]
});
}
render() {
return (
<View style={styles.container}>
<Text style={styles.heading}>Todo List</Text>
<TextInput
style={styles.textBox}
placeholder="Add task"
clearButtonMode={"always"}
onSubmitEditing={event => this.onAddTask(event)}
></TextInput>
{this.state.tasks.map((task, index) => (
<TodoTask key={index} description={task.description} />
))}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
top: "10%",
flex: 1,
margin: 5,
backgroundColor: "#fff"
},
heading: {
fontSize: 34,
justifyContent: "flex-start"
},
textBox: {
borderColor: "#69e4ff",
borderWidth: 1.5,
margin: 5,
padding: 5,
width: "95%",
borderRadius: 15,
justifyContent: "center"
},
textBoxText: {
padding: 5,
color: "#69e4ff"
}
});