-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppList.js
64 lines (60 loc) · 1.35 KB
/
AppList.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
import { StatusBar } from "expo-status-bar";
import React, { useState, useEffect } from "react";
import { StyleSheet, View, Text, ScrollView } from "react-native";
import AppItem from "./AppItem";
import Database from "./Database";
export default function AppList({ route, navigation }) {
const [items, setItems] = useState([]);
useEffect(() => {
Database.getItems().then((items) => setItems(items));
}, [route]);
return (
<View style={styles.container}>
<StatusBar style="light" />
<Text style={styles.title}>Lista de Compras</Text>
<ScrollView
style={styles.scrollContainer}
contentContainerStyle={styles.itemsContainer}
>
{items.map((item) => {
return (
<AppItem
key={item.id}
id={item.id}
item={item.quantidade + " de " + item.descricao}
navigation={navigation}
/>
);
})}
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#D93600",
alignItems: "center",
justifyContent: "center",
},
title: {
color: "#fff",
fontSize: 20,
fontWeight: "bold",
marginTop: 50,
marginBottom: 20,
},
scrollContainer: {
flex: 1,
width: "90%",
},
itemsContainer: {
flex: 1,
marginTop: 10,
padding: 20,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
alignItems: "stretch",
backgroundColor: "#fff",
},
});