-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
95 lines (85 loc) · 2.36 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
94
95
import React from 'react';
import { View , Text, StyleSheet, TextInput, SafeAreaView, TouchableOpacity, ScrollView} from 'react-native';
import Navbar from './navbar';
import Tarefas from './tarefas';
import Selecionar from './picker';
class App extends React.Component{
constructor(props){
super(props);
this.state = {
noteArray: [],
noteText: '',
};
}
addTask(){
if (this.state.noteText){
var date = new Date();
this.state.noteArray.push({
'date' : date.getUTCDate() +
'/' + (date.getMonth() + 1) +
'/' + date.getFullYear(),
'note': this.state.noteText
});
this.setState({noteArray: this.state.noteArray});
this.setState({noteText: this.state.noteText});
this.textInput.clear()
}
}
deleteNote (key){
this.state.noteArray.splice(key,1);
this.setState({noteArray:this.state.noteArray});
}
render() {
let notes = this.state.noteArray.map ((val,key)=> {
return <Tarefas key = {key} keyval={key} val={val}
deleteMethod = {()=> this.deleteNote(key)}
/>
})
return(
<SafeAreaView>
<View>
<Navbar>
<Text>this.props.Text</Text>
</Navbar>
<View style={{padding: 20,flexDirection: 'row' }}>
<TextInput
style={styles.TextInput}
ref={noteText => { this.textInput = noteText }}
placeholder = 'Adicionar Atividade'
onChangeText = {(noteText) => this.setState({noteText})}
value = {this.state.noteText}
>
</TextInput>
<View>
<TouchableOpacity onPress = {this.addTask.bind(this)} style = {styles.button}>
<Text>+</Text>
</TouchableOpacity>
</View>
</View>
<Selecionar></Selecionar>
<ScrollView style= {styles.scrollContainer}>
{notes}
</ScrollView>
</View>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
TextInput: {
borderRadius: 5,
flex: 1,
right: 10,
borderColor: 'gray',
borderWidth: 0.5,
},
button: {
top: 20,
width: 35,
left: 10,
},
scrollContainer: {
marginBottom: 100,
},
});
export default App;