-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeScreen.js
More file actions
177 lines (168 loc) · 6.27 KB
/
HomeScreen.js
File metadata and controls
177 lines (168 loc) · 6.27 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// HomeScreen.js
import React, { useState, useEffect } from 'react';
import { View, Text, FlatList, TouchableOpacity, Image, TextInput, StyleSheet } from 'react-native';
import { Ionicons, AntDesign } from '@expo/vector-icons';
const HomeScreen = ({ navigation }) => {
const [wallpapers, setWallpapers] = useState([]);
const [searchQuery, setSearchQuery] = useState('');
// Exemplo de dados de wallpaper (substitua isso pelos seus dados reais)
const dummyWallpapers = [
{ id: '1', imageUri: 'https://img.freepik.com/fotos-premium/arvore-sentada-no-topo-de-uma-montanha-ao-lado-de-um-corpo-de-agua-generativa-ai_900370-195.jpg' },
{ id: '2', imageUri: 'https://img.freepik.com/fotos-gratis/pico-de-montanha-majestoso-em-paisagem-tranquila-de-inverno-gerada-por-ia_188544-15662.jpg' },
{ id: '3', imageUri: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQNj8LNczSOM7P3rNmVmWFEqIkjv2Wnki-RqCNi3v_VIkcY2kRMIfZ8IpBVm-Yugzyun8c&usqp=CAU' },
{ id: '4', imageUri: 'https://www.pixground.com/wp-content/uploads/2023/10/Anime-Sunset-Sky-AI-Generated-4K-Wallpaper.jpg' },
{ id: '5', imageUri: 'https://i2.wp.com/wallpapercave.com/wp/wp6343813.jpg' },
{ id: '6', imageUri: 'https://img.freepik.com/premium-photo/abstract-bright-landscape-exotic-scene-digital-generated-tourism-travel-theme-illustration_840789-2233.jpg'},
{ id: '7', imageUri: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR0dXA2tjUjH8IlCv6JOjcUXE9ZzP3xhazA5vp5sNP2uTZT5u3_XOfhmJ7a3lHpqo7_EMU&usqp=CAU'},
{ id: '8', imageUri: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSS_z61u6nznLIa1fnRBYVug_2vlx-buZrXrc0SS7o97cFFkhwTBh6h7D2SaU_WWenjseE&usqp=CAU'},
{ id: '9', imageUri: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTxZZ4zf7t1YlleIBfx-ONfq2gQG-XmDV1NbZ2mErzmI2PtnN5xh5-jdJMPg8fp_IGkQcg&usqp=CAU'},
{ id: '10', imageUri: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSJMRZsTqnUyqfb2h-8LI0zqYoZ4OmwNwv9OxfSQ4gwDmITAvLGcXcizTsFTW9XxcKVfSs&usqp=CAU'},
];
useEffect(() => {
// Carregar wallpapers (pode ser uma chamada de API)
setWallpapers(dummyWallpapers);
}, []);
const handleWallpaperPress = (wallpaper) => {
// Navegar para a tela de visualização em tela cheia ou detalhes do wallpaper
alert(`Abrir tela de detalhes para o wallpaper ${wallpaper.id}`);
// navigation.navigate('WallpaperDetails', { wallpaper });
};
const handleSearch = () => {
// Lógica de pesquisa aqui
alert(`Pesquisar por: ${searchQuery}`);
};
return (
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.title}>Wallpapers</Text>
<View style={styles.searchContainer}>
<TextInput
style={styles.searchInput}
placeholder="Pesquisar"
placeholderTextColor="#ccc"
value={searchQuery}
onChangeText={(text) => setSearchQuery(text)}
onSubmitEditing={handleSearch}
/>
<TouchableOpacity style={styles.searchButton} onPress={handleSearch}>
<Ionicons name="search" size={24} color="#fff" />
</TouchableOpacity>
</View>
</View>
<FlatList
data={wallpapers}
keyExtractor={(item) => item.id}
numColumns={2}
renderItem={({ item }) => (
<TouchableOpacity
style={styles.wallpaperItem}
onPress={() => handleWallpaperPress(item)}
>
<Image source={{ uri: item.imageUri }} style={styles.wallpaperImage} />
<View style={styles.overlay}>
<Text style={styles.overlayText}>Detalhes</Text>
</View>
</TouchableOpacity>
)}
/>
<View style={styles.bottomBar}>
<TouchableOpacity style={styles.bottomBarButton} onPress={() => navigation.navigate('Home')}>
<AntDesign name="home" size={24} color="#fff" />
<Text style={styles.bottomBarText}>Home</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.bottomBarButton} onPress={() => navigation.navigate('Add')}>
<AntDesign name="pluscircleo" size={24} color="#fff" />
<Text style={styles.bottomBarText}>Adicionar</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.bottomBarButton} onPress={() => navigation.navigate('Profile')}>
<AntDesign name="user" size={24} color="#fff" />
<Text style={styles.bottomBarText}>Perfil</Text>
</TouchableOpacity>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f0f0f0',
},
header: {
paddingVertical: 20,
borderBottomWidth: 1,
borderBottomColor: '#ddd',
alignItems: 'center',
},
title: {
fontSize: 24,
fontWeight: 'bold',
color: '#333',
},
searchContainer: {
flexDirection: 'row',
alignItems: 'center',
marginTop: 10,
},
searchInput: {
flex: 1,
height: 40,
borderColor: '#ccc',
borderWidth: 1,
borderRadius: 15,
paddingHorizontal: 10,
backgroundColor: '#fff',
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
},
searchButton: {
padding: 10,
backgroundColor: '#3498db',
borderTopRightRadius: 5,
borderBottomRightRadius: 5,
alignItems: 'center',
justifyContent: 'center',
},
wallpaperItem: {
flex: 1,
margin: 5,
borderRadius: 10,
overflow: 'hidden',
elevation: 2,
backgroundColor: '#fff',
position: 'relative',
},
wallpaperImage: {
width: '100%',
height: 150,
borderRadius: 10,
resizeMode: 'cover',
},
overlay: {
...StyleSheet.absoluteFillObject,
backgroundColor: 'rgba(0,0,0,0.5)',
borderRadius: 10,
justifyContent: 'center',
alignItems: 'center',
opacity: 0,
},
overlayText: {
color: '#fff',
fontWeight: 'bold',
},
bottomBar: {
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'center',
paddingVertical: 10,
backgroundColor: '#3498db',
borderTopWidth: 1,
borderTopColor: '#2980b9',
},
bottomBarButton: {
alignItems: 'center',
},
bottomBarText: {
color: '#fff',
},
});
export default HomeScreen;