-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTelaInicial.js
132 lines (118 loc) · 3.49 KB
/
TelaInicial.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { React, useEffect } from 'react';
import { View, Text, FlatList, Image, TouchableOpacity, BackHandler, Button, Alert } from 'react-native';
import styles from './Estilo';
export default function TelaInicial({ navigation }) {
useEffect(() => {
const handleBackButton = () => {
if (navigation.isFocused()) {
return true;
} else {
return false;
}
};
BackHandler.addEventListener('hardwareBackPress', handleBackButton);
return () => {
BackHandler.removeEventListener('hardwareBackPress', handleBackButton);
};
}, [navigation]);
const data = [
{
title: 'Alfafa',
name: 'Alfafa',
estacao: '',
image: require('./assets/alfafa.jpeg'),
},
{
title: 'Gramíneas de estação fria',
name: 'Gramíneas',
estacao: 'fria',
image: require('./assets/gramineas_fria.jpeg'),
},
{
title: 'Gramíneas de estação quente',
name: 'Gramíneas',
estacao: 'quente',
image: require('./assets/gramineas_quente.jpeg'),
},
{
title: 'Leguminosas de estação fria',
name: 'Leguminosas',
estacao: 'fria',
image: require('./assets/leguminosas_fria.jpeg'),
},
{
title: 'Leguminosas de estação quente',
name: 'Leguminosas',
estacao: 'quente',
image: require('./assets/leguminosas_quante.jpeg'),
},
{
title: 'Consorciações de gramíneas e de leguminosas de estação quente',
name: 'Consórcios',
estacao: 'quente',
image: require('./assets/consorciacoes.jpeg'),
},
{
title: 'Milho e sorgo para silagem',
name: 'Espécies perenes',
estacao: '',
image: require('./assets/milho_sorgo.jpeg'),
},
{
title: 'Pastagens naturais (nativas ou naturalizadas)',
name: 'Campo natural',
estacao: '',
image: require('./assets/pastagem_natural.jpeg'),
},
{
title: 'Pastagens naturais com introdução de gramíneas e leguminosas',
name: 'Campo natural',
estacao: '',
image: require('./assets/pastagem_leguminosa_graminea.jpeg'),
},
];
const logout = () => {
Alert.alert('Sucesso', 'Logout realizado com sucesso.');
navigation.navigate('Login');
}
const historico = () => {
navigation.navigate('Historico');
}
return (
<View>
<Text style={styles.titulo}>Escolha o tipo de forrageira:</Text>
<FlatList
data={data}
renderItem={({ item }) => (
<TouchableOpacity onPress={() => { navigation.navigate('Formulario', {tipo: item.name, estacao:item.estacao})}
}>
<View style={{ flexDirection: 'row' , marginBottom: 10, marginTop: 10}}>
<Image
source={item.image}
style={styles.image}
/>
<Text style={{flexWrap: 'wrap', fontWeight: 'bold'}}>{item.title}</Text>
</View>
</TouchableOpacity>)}
ItemSeparatorComponent={() => (
<View style={{ height: 1, backgroundColor: 'gray' }} />
)}
keyExtractor={(item) => item.title}
/>
<View style={styles.logoutButton}>
<Button
title="Sair"
onPress={logout}
color="forestgreen"
/>
</View>
<View style={styles.HistButton}>
<Button
title="Histórico"
onPress={historico}
color="forestgreen"
/>
</View>
</View>
);
}