-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
77 lines (69 loc) · 1.94 KB
/
App.tsx
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
import React, { useState, useEffect } from "react";
import { View, ActivityIndicator, Platform } from "react-native";
import { createAppContainer } from "react-navigation";
import { createStackNavigator } from "react-navigation-stack";
import { ScreenOrientation } from "expo";
import * as Font from "expo-font";
import StartGameScreen from "./src/screens/StartGameScreen";
import GameBoardScreen from "./src/screens/GameBoardScreen";
import ScoreBoardScreen from "./src/screens/ScoreBoardScreen";
import { playMusic, unloadMusic } from "./src/utilities/musicController";
const navigator = createStackNavigator(
{
Start: StartGameScreen,
Game: GameBoardScreen,
Score: ScoreBoardScreen
},
{
initialRouteName: "Start",
headerMode: "none",
transparentCard: true
}
);
const App = createAppContainer(navigator);
export default () => {
const [playMusicState, setPlayMusicState] = useState(false);
const [fontLoaded, setFontLoaded] = useState(false);
const [playerName, setPlayerName] = useState("Anonymous");
const [scoreboard, setScoreboard] = useState([]);
useEffect(() => {
playMusic(true);
return () => {
unloadMusic();
};
}, []);
useEffect(() => {
(async () => {
await Font.loadAsync({
"orbitron-medium": require("./assets/Orbitron-Medium.ttf")
});
setFontLoaded(true);
})();
}, []);
useEffect(() => {
if (Platform.OS === "android")
(async () => {
await ScreenOrientation.lockAsync(
ScreenOrientation.OrientationLock.PORTRAIT
);
})();
}, []);
return fontLoaded ? (
<App
screenProps={{
playMusicState,
setPlayMusicState,
playerName,
setPlayerName,
scoreboard,
setScoreboard
}}
/>
) : (
<View
style={{ backgroundColor: "#090C22", flex: 1, justifyContent: "center" }}
>
<ActivityIndicator size="large" color="#00ff00" />
</View>
);
};