-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
62 lines (55 loc) · 1.42 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
import { FlatList, StyleSheet, Text, View,SafeAreaView } from 'react-native';
import React, {useState, useEffect} from 'react';
import ListItem from './components/ListItem';
import { getMarketData } from './services/cryptoService';
export default function App() {
const [data, setData] = useState([]);
useEffect(() => {
const fetchMarketData = async () => {
const marketData = await getMarketData();
setData(marketData);
}
fetchMarketData();
}, [])
return (
<SafeAreaView style={styles.container}>
<View style={styles.titleWrapper}>
<Text style={styles.largeTitle}>CryptAura-Watcher</Text>
</View>
<View style={styles.divider}/>
<FlatList
keyExtractor={(item) => item.id}
data={data}
renderItem={({ item }) => (
<ListItem
name={item.name}
symbol={item.symbol}
currentPrice={item.current_price}
priceChangePercentage14d={item.price_change_percentage_14d_in_currency}
logoUrl={item.image}
/>
)}
/>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff'
},
largeTitle:{
fontSize:24,
fontWeight:"bold"
},
titleWrapper:{
marginTop:64,
paddingHorizontal:16
},
divider:{
height:StyleSheet.hairlineWidth,
backgroundColor:"#A9ABB1",
marginHorizontal:16,
marginTop:16,
}
});