-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppItem.js
99 lines (95 loc) · 2.09 KB
/
AppItem.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
import React from "react";
import { StyleSheet, Text, View, TouchableOpacity, Alert } from "react-native";
import { Feather as Icon } from "@expo/vector-icons";
import Database from "./Database";
export default function AppItem(props) {
async function handleEditPress() {
const item = await Database.getItem(props.id);
props.navigation.navigate("AppForm", item);
}
function handleDeletePress() {
Alert.alert(
"Atenção",
"Você tem certeza que deseja excluir este item?",
[
{
text: "Não",
onPress: () => console.log("Cancel Pressed"),
style: "cancel",
},
{
text: "Sim",
onPress: () => {
Database.deleteItem(props.id).then((response) =>
props.navigation.navigate("AppList", { id: props.id })
);
},
},
],
{ cancelable: false }
);
}
return (
<View style={styles.container}>
<Text style={styles.textItem}>{props.item}</Text>
<View style={styles.buttonsContainer}>
<TouchableOpacity
style={styles.deleteButton}
onPress={handleDeletePress}
>
<Icon name="trash" color="white" size={18} />
</TouchableOpacity>
<TouchableOpacity style={styles.editButton} onPress={handleEditPress}>
<Icon name="edit" color="white" size={18} />
</TouchableOpacity>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: "#fff",
marginTop: 20,
width: "100%",
},
buttonsContainer: {
flexDirection: "row-reverse",
alignItems: "flex-end",
borderBottomWidth: 1,
borderBottomColor: "#CCC",
paddingBottom: 10,
marginTop: 10,
},
editButton: {
marginLeft: 10,
height: 40,
backgroundColor: "blue",
borderRadius: 10,
padding: 10,
fontSize: 12,
elevation: 10,
shadowOpacity: 10,
shadowColor: "#ccc",
alignItems: "center",
},
deleteButton: {
marginLeft: 10,
height: 40,
width: 40,
backgroundColor: "red",
borderRadius: 10,
padding: 10,
fontSize: 12,
elevation: 10,
shadowOpacity: 10,
shadowColor: "#ccc",
alignItems: "center",
},
buttonText: {
color: "#fff",
fontWeight: "bold",
},
textItem: {
fontSize: 20,
},
});