-
Notifications
You must be signed in to change notification settings - Fork 1
/
Apptwo.js
88 lines (83 loc) · 1.75 KB
/
Apptwo.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
import React, { Component } from 'react';
import { Text, View, StyleSheet, TextInput, TouchableOpacity } from 'react-native';
export default class Apptwo extends Component {
constructor() {
super();
this.state = {
text: '',
data:[],
}
}
handleSave = () => {
const { text, data } = this.state;
data.push({text})
this.setState({data, text:''})
}
render(){
const { text, data } = this.state;
return (
<View style={{flex:1, paddingTop: 30}}>
<View style={styles.title}>
<Text style={styles.title_text}>To-Do Application @marijuabakunin</Text>
</View>
<View style={styles.header}>
<TextInput
style={styles.input}
value={text}
onChangeText={(text) => {this.setState({text})}}
/>
<TouchableOpacity onPress={this.handleSave} style={styles.touchable}>
<Text style={styles.input_text}>Add</Text>
</TouchableOpacity>
</View>
<View>
{ data.map((item) => {
return (<Text style={styles.card}> {item.text} </Text>)
}) }
</View>
</View>
);
}
}
const styles = StyleSheet.create({
title: {
padding: 10,
backgroundColor: 'blue',
},
title_text: {
fontSize: 16,
fontWeight: 'bold',
color: 'white',
textAlign: 'center'
},
header: {
backgroundColor: '#ccc',
padding: 10,
flexDirection: 'row',
margin: 5
},
input : {
backgroundColor: 'white',
padding: 10,
flex: 1,
},
touchable: {
padding: 10,
backgroundColor: 'blue',
borderRadius: 5,
marginLeft: 5
},
input_text : {
fontSize: 16,
fontWeight: 'bold',
color: 'white',
textAlign: 'center'
},
card: {
backgroundColor: '#ddd',
margin: 5,
padding: 10,
textAlign: 'center',
fontSize: 16,
}
})