-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
152 lines (145 loc) · 3.66 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import React from 'react';
import {StyleSheet, Text, View, Image, FlatList,Array, ImageBackground, TextInput} from 'react-native';
class FoodCategory {
id: String
category: String
image: String
constructor (id: String, category: String, image: String) {
this.id = id
this.category = category
this.image = image
}
}
const restaurants: Array<FoodCategory> = [
new FoodCategory('1', 'Pizza', require('./assets/pizza.jpg')),
new FoodCategory('2', 'Sushi', require('./assets/sushi.jpg')),
new FoodCategory('3', 'Veggie', require('./assets/veggie.jpg')),
new FoodCategory('4', 'Pasta', require('./assets/pasta.jpg')),
new FoodCategory('5', 'Parrilla', require('./assets/parrilla.jpg')),
new FoodCategory('6', 'Panificados', require('./assets/panificados.jpg')),
new FoodCategory('7', 'Milanesas', require('./assets/milanesa.jpg')),
new FoodCategory('8', 'Hamburguesas', require('./assets/hamburguesa.jpg')),
new FoodCategory('9', 'Fiambres', require('./assets/fiambres.jpg')),
new FoodCategory('10', 'Dulces', require('./assets/dulces.jpg')),
new FoodCategory('11', 'Cafetería', require('./assets/cafeteria.jpg')),
new FoodCategory('12', 'Bebidas', require('./assets/bebidas.jpg'))
]
const renderRestaurants = ({ item } : { item: FoodCategory}) => {
return (
<View style={styles.cards}>
<ImageBackground
style={styles.imagen}
source={item.image}
imageStyle={{ borderRadius: 20}}
>
<Text style={styles.titulo}>{item.category}</Text>
</ImageBackground>
</View>
)
}
function App() {
return (
<View style={styles.container}>
<View style={styles.header}>
<ImageBackground
style={styles.headerImg}
source={require('./assets/fondo.jpg')}>
<Text style={styles.headerTitle}>Restaurants</Text>
</ImageBackground>
</View>
<View style={styles.search}>
<Image
style={styles.icon}
source={require('./assets/search.png')}/>
<TextInput
style={styles.input}
defaultValue="Buscar"
/>
</View>
<View style={styles.subContainer}>
<Text style={styles.subtitle}>Categorías principales</Text>
</View>
<FlatList
keyExtractor={item => item.id}
style={styles.list}
data={restaurants}
renderItem={renderRestaurants}
/>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
justifyContent: 'center',
alignItems: 'center'
},
header : {
width: '100%',
height: 200
},
headerImg: {
width: '100%',
height: '100%'
},
headerTitle: {
color: 'white',
fontSize: 50,
fontWeight: 'bold',
textAlign: 'left',
textAlignVertical: 'bottom',
paddingHorizontal: 10,
paddingVertical: 40,
},
search:{
flexDirection: 'row',
width: '100%',
alignItems: 'flex-start',
marginTop: 15,
marginLeft: 20
},
icon: {
width: 30,
height: 30,
marginRight: 10
},
input: {
height: 50,
width: '50%',
borderColor: 'white',
borderWidth: 1,
fontSize: 30
},
subContainer: {
alignSelf: 'flex-start',
marginLeft: 10
},
subtitle: {
fontSize: 15,
fontWeight: 'bold'
},
imagen : {
width: '100%',
height: 200,
},
titulo: {
borderRadius: 20,
width: '100%',
height: '100%',
backgroundColor: 'rgba(0,0,0,0.6)',
fontSize: 30,
fontWeight: 'bold',
color: 'white',
textAlign: 'center',
textAlignVertical: 'center'
},
cards : {
padding: 20,
width: '100%'
},
list : {
width: '100%'
}
})
export default App;