-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
110 lines (96 loc) · 2.63 KB
/
App.js
File metadata and controls
110 lines (96 loc) · 2.63 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import React, { Component } from 'react'
import { View, ScrollView, Text, TextInput, StyleSheet, TouchableOpacity } from 'react-native'
import Database from './src/Database/Database'
import ListaAlunos from './src/Componentes/ListaAlunos'
import Aluno from './src/Models/Aluno'
export default class App extends Component
{
constructor(props) {
super(props);
this.state = {
nome: "",
nota: 0,
listaAlunos: []
}
this.ListarAlunos()
}
ListarAlunos = () => {
const banco = new Database();
banco.Listar().then( lista => { this.setState({listaAlunos : lista}) } )
}
CadastrarAluno = (nome, nota) => {
const novoAluno = new Aluno(nome, nota, "???")
const banco = new Database();
banco.Inserir(novoAluno);
this.ListarAlunos()
}
AprovarAluno = (id) => {
const banco = new Database();
banco.Aprovar(id);
this.ListarAlunos()
//DevSettings.reload();
}
ReprovarAluno = (id) => {
const banco = new Database();
banco.Reprovar(id);
this.ListarAlunos()
}
DeletarAluno = (id) => {
const banco = new Database();
banco.Deletar(id);
this.ListarAlunos()
}
render()
{
return(
<ScrollView>
<View>
<Text style={estilo.titulo}>Cadastro de alunos </Text>
<TextInput placeholder='Digite o nome do aluno...' onChangeText={(valor) => {this.setState({ nome : valor })}} />
<TextInput placeholder='Digite a nota do aluno... ' onChangeText={(valor) => {this.setState({ nota : valor })}} />
<TouchableOpacity style={estilo.botao} onPress={ ()=> { this.CadastrarAluno(this.state.nome, this.state.nota) }}>
<Text style={{color: 'white', fontWeight: 'bold'}}>Salvar</Text>
</TouchableOpacity>
</View>
<Text style={estilo.titulo}>Lista de Alunos</Text>
<Text></Text>
{
this.state.listaAlunos.map( item => (
<ListaAlunos
key={item.id}
id={item.id}
nome={item.nome}
nota={item.nota}
aprovado={item.aprovado}
aprovar={this.AprovarAluno}
reprovar={this.ReprovarAluno}
deletar={this.DeletarAluno}
/>))
}
</ScrollView>
)
}
}
const estilo = StyleSheet.create({
titulo: {
fontSize: 18,
margin: 5,
color: 'black'
},
botao: {
width: 150,
backgroundColor: '#39bf00',
alignItems: 'center',
justifyContent: "center",
padding: 10,
margin: 5,
color: 'white'
},
areaBotao: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: "center"
},
linha1: {
}
})