-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
93 lines (82 loc) · 2.16 KB
/
App.js
File metadata and controls
93 lines (82 loc) · 2.16 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
import React, {useEffect, useState} from 'react'
import { View, Text, FlatList, StyleSheet, TextInput, StatusBar} from 'react-native'
import CoinItem from './components/CoinItem';
const App = () => {
const [criptoCoins, setcriptoCoins] = useState([]);
const [buscador, setBuscador] = useState('');
const [carga, setCarga] = useState(false)
const cargarData= async ()=>{
const res = await fetch(
'https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=1&sparkline=false'
);
const data = await res.json();
// console.log(data)
setcriptoCoins(data);
}
useEffect(() => {
cargarData();
}, [])
return (
<View style={styles.container}>
<StatusBar backgroundColor="#141414"></StatusBar>
<View style={styles.header}>
<Text style={styles.title}>Crypto Info</Text>
<TextInput style={styles.search}
onChangeText={text => setBuscador(text)}
placeholder="Buscar Cripto"
placeholderTextColor="#858585">
</TextInput>
</View>
<FlatList
style={styles.list}
data={
criptoCoins.filter(criptoCoin => criptoCoin.name.toLowerCase().includes(buscador)
||
criptoCoin.symbol.toLowerCase().includes(buscador))
}
renderItem={({item})=>{
return <CoinItem coin={item} />
}}
showsVerticalScrollIndicator={false}
refreshing={carga}
onRefresh={async ()=>{
setCarga(true)
await cargarData();
setCarga(false)
}}
/>
</View>
)
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#141414',
alignItems: 'center',
flex: 1
},
title: {
color: '#fff',
marginTop: 10,
// fontFamily: 'roboto',
fontSize: 20,
},
list: {
width: '90%'
},
header: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'flex-end',
width: '90%',
marginBottom: 10,
height: 50,
},
search: {
color: '#fff',
borderBottomColor: '#4657CE',
borderBottomWidth: 1,
width: '40%',
textAlign: 'center',
}
})
export default App