-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
85 lines (77 loc) · 2.62 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
import { StatusBar } from "expo-status-bar";
import { View } from "react-native";
import Home from "./pages/Home/Home";
import standings from "./pages/Standings/standings";
import raceStandings from "./pages/RaceResult/RaceRes";
import Schedule from "./pages/Schedule/schedule";
import { useEffect,useState } from "react";
import Axios from "axios";
import { CarStore } from "./pages/TokenProvider";
import XMLParser from "react-xml-parser";
import { NavigationContainer } from "@react-navigation/native";
import {
useFonts,
TitilliumWeb_400Regular,
TitilliumWeb_700Bold,
TitilliumWeb_600SemiBold,
TitilliumWeb_300Light_Italic,
TitilliumWeb_300Light,
} from "@expo-google-fonts/titillium-web";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
const Stack = createNativeStackNavigator();
export default function App() {
const [done, setdone] = useState(false)
useEffect(() => {
Axios.get("https://ergast.com/api/f1/current/next").then((response) => {
const schedule = new XMLParser().parseFromString(response["data"]);
CarStore.update(s=>{
s.nextRaceName = schedule.getElementsByTagName("RaceName")[0]["value"];
s.nextRaceTime=schedule.getElementsByTagName("Time")[0]["value"];
s.nextRaceDate = schedule.getElementsByTagName("Date")[0]["value"];
})
}).finally(()=>{
setdone(true)
});
}, [CarStore]);
let [fontsLoaded] = useFonts({
TitilliumWeb_400Regular,
TitilliumWeb_600SemiBold,
TitilliumWeb_700Bold,
TitilliumWeb_300Light,
TitilliumWeb_300Light_Italic,
});
if (!fontsLoaded) {
console.log("loading fonts");
return null;
} else {
return (
<View style={{ width: "100%", height: "100%" }}>
<StatusBar style="light" />
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={Home}
options={{ title: "Home", headerShown: false }}
></Stack.Screen>
<Stack.Screen
name="Standings"
component={standings}
options={{ title: "Standings", headerShown: false }}
></Stack.Screen>
<Stack.Screen
name="RaceRes"
component={raceStandings}
options={{ title: "Race Standings", headerShown: false }}
></Stack.Screen>
<Stack.Screen
name="Schedule"
component={Schedule}
options={{ title: "Race Schedule", headerShown: false }}
></Stack.Screen>
</Stack.Navigator>
</NavigationContainer>
</View>
);
}
}