-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
102 lines (83 loc) · 2.19 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
96
97
98
99
100
101
102
import { StatusBar } from 'expo-status-bar';
import React, {useState} from 'react';
import AppLoading from 'expo-app-loading';
import {AntDesign} from '@expo/vector-icons';
import {useFonts, Lato_400Regular} from '@expo-google-fonts/lato'
import { StyleSheet, Text, View, ImageBackground, TouchableOpacity, ScrollView } from 'react-native';
export default function App() {
const image = require('./resources/bg.jpg');
console.disableYellowBox = true;
const [tarefas, setarTarefas] = useState([
{
id: 1,
tarefa: 'Minha tarefa 1.'
},
{
id: 2,
tarefa: 'Minha outra tarefa.'
}
]);
let [fontsLoaded] = useFonts({
Lato_400Regular,
});
if (!fontsLoaded){
return <AppLoading />;
}
function deletarTarefa(id){
alert('tarefa com id ' + id + ' foi deletada');
let newTarefas = tarefas.filter(function(val){
return val.id != id;
});
setarTarefas(newTarefas);
}
return (
<ScrollView style={{flex:1}}>
<StatusBar hidden />
<ImageBackground source={image} style={styles.image}>
<View style={styles.coverView}>
<Text style={styles.textHeader}>Lista de Tarefas</Text>
</View>
</ImageBackground>
{
tarefas.map(function(val){
return(<View style={styles.tarefaSingle}>
<View style={{flex:1, width:'100%', padding:5}}>
<Text>{val.tarefa}</Text>
</View>
<View style={{alignItems:'flex-end', flex:1, padding:10}}>
<TouchableOpacity onPress={() => deletarTarefa(val.id)} ><AntDesign name="minuscircleo" size={24} color="black"></AntDesign></TouchableOpacity>
</View>
</View>
);
})
}
</ScrollView>
);
}
const styles = StyleSheet.create({
image: {
resizeMode: "cover",
width:'100%',
height:50
},
coverView:{
width:'100%',
height:50,
backgroundColor:'rgba(0, 0, 0, 0.5)'
},
textHeader:{
textAlign:'center',
color:'white',
fontSize:23,
marginTop:20,
fontFamily:'Lato_400Regular'
},
tarefaSingle:{
marginTop:30,
width:'100%',
borderBottomWidth:1,
borderBottomColor:"black",
flexDirection:'row',
paddingBottom:10
}
});