-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMarketOverview.js
143 lines (137 loc) · 3.77 KB
/
MarketOverview.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
import axios from "axios";
import * as React from "react";
import { useEffect, useState } from "react";
import { StyleSheet, View } from "react-native";
import { Card, Divider, Header } from "react-native-elements";
import { ScrollView } from "react-native-gesture-handler";
import StockChart from "../components/Home/StockChart";
export default function MarketOverview() {
const [dowData, setDowData] = useState([]);
const [nasdqaData, setNasdqaData] = useState([]);
const [sp500Data, setSp500Data] = useState([]);
const initialLoading = async () => {
try {
const dowRes = await axios.get(
`https://sandbox.iexapis.com/stable/stock/DIA/chart?token=Tsk_9b260400520a4d23abfe1ef6cb0d3feb`
);
const nasdqaRes = await axios.get(
`https://sandbox.iexapis.com/stable/stock/qqq/chart?token=Tsk_9b260400520a4d23abfe1ef6cb0d3feb`
);
const sp500Res = await axios.get(
`https://sandbox.iexapis.com/stable/stock/spy/chart?token=Tsk_9b260400520a4d23abfe1ef6cb0d3feb`
);
setDowData(dowRes.data);
setNasdqaData(nasdqaRes.data);
setSp500Data(sp500Res.data);
} catch (error) {
console.log(error);
}
};
useEffect(() => {
initialLoading();
}, []);
return (
<ScrollView style={{ backgroundColor: "black" }}>
<View style={styles.container}>
<Header
leftComponent={{ icon: "menu", color: "#fff" }}
centerComponent={{
text: "Financial InfoX",
style: { color: "#fff" },
}}
rightComponent={{ icon: "home", color: "#fff" }}
backgroundColor="black"
/>
<Card
title="Market Overall"
titleStyle={{ textAlign: "center", color: "gold" }}
containerStyle={{ backgroundColor: "black" }}
>
<View style={styles.user}>
{dowData.length > 0 && (
<StockChart name="DOW JONES INDEX" data={dowData} />
)}
<Divider style={{ backgroundColor: "gray", height: 0.5 }} />
{nasdqaData.length > 0 && (
<StockChart name="NASDAQ INDEX" data={nasdqaData} />
)}
<Divider style={{ backgroundColor: "gray", height: 0.5 }} />
{sp500Data.length > 0 && (
<StockChart name="S&P 500 INDEX" data={sp500Data} />
)}
</View>
</Card>
<View style={styles.separator} />
</View>
</ScrollView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingLeft: 10,
paddingRight: 10,
backgroundColor: "black",
},
nameBlock: {
flex: 1,
paddingTop: 4,
justifyContent: "center",
alignItems: "center",
},
nameText: {
fontWeight: "bold",
fontSize: 12,
color: "white",
},
details: {
flex: 5,
flexDirection: "column",
borderTopWidth: StyleSheet.hairlineWidth,
borderBottomWidth: StyleSheet.hairlineWidth,
borderColor: "white",
},
detailsRow: {
flex: 1,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
marginTop: 10,
},
detailsRowColumn: {
flex: 1,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
paddingLeft: 5,
paddingRight: 5,
},
separator: {
height: StyleSheet.hairlineWidth,
backgroundColor: "white",
marginTop: 20,
},
separatorThin: {
height: StyleSheet.hairlineWidth,
backgroundColor: "#A6A6A6",
},
propertyText: {
fontSize: 12,
color: "#A6A6A6",
textAlign: "left",
},
valueText: {
fontSize: 15,
color: "white",
textAlign: "right",
},
title: {
paddingTop: 5,
color: "white",
fontSize: 15,
fontWeight: "bold",
textAlign: "center",
justifyContent: "center",
alignItems: "center",
},
});