-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
90 lines (79 loc) · 2.7 KB
/
App.js
File metadata and controls
90 lines (79 loc) · 2.7 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
import { PaperProvider, Appbar, BottomNavigation } from 'react-native-paper';
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import ReaderView from './views/reader';
import SettingsView from './views/settings';
import { useContext, useState } from 'react';
import { NavigationContainer, useNavigation } from '@react-navigation/native';
import { SettingsContext, SettingsProvider } from './contexts/SettingsContext';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { getTheme } from './lib/themeUtils';
import * as SystemUI from 'expo-system-ui';
export default function App() {
return (
<SettingsProvider>
<StatusBar style="auto" />
<MainApp />
</SettingsProvider>
);
}
function MainApp() {
const Stack = createNativeStackNavigator();
const { colorScheme, showDlcsTab } = useContext(SettingsContext);
const theme = getTheme(colorScheme);
SystemUI.setBackgroundColorAsync(theme.colors.background);
const HomeView = () => {
const navigation = useNavigation();
const [index, setIndex] = useState(0);
const routes = [
{ key: 'games', title: 'Games', focusedIcon: 'gamepad-variant' },
...(showDlcsTab ? [{ key: 'dlcs', title: "DLC's", focusedIcon: 'puzzle' }] : [])
];
const GamesScene = () => <ReaderView route={{ params: { type: "GAMES" } }} />;
const DLCsScene = () => <ReaderView route={{ params: { type: "DLCS" } }} />;
const renderScene = BottomNavigation.SceneMap({
games: GamesScene,
...(showDlcsTab ? { dlcs: DLCsScene } : {})
});
return (
<>
<Appbar.Header>
<Appbar.Content title="NoPayStation" />
<Appbar.Action icon="cog" onPress={() => navigation.navigate('Settings')} />
</Appbar.Header>
<BottomNavigation
navigationState={{ index, routes }}
onIndexChange={setIndex}
renderScene={renderScene}
/>
</>
);
};
return (
<PaperProvider theme={theme}>
<NavigationContainer theme={theme}>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeView}
options={{ headerShown: false }}
/>
<Stack.Screen
name="Settings"
component={SettingsView}
options={{
header: ({ navigation }) => (
<>
<Appbar.Header>
<Appbar.BackAction onPress={() => navigation.goBack()} />
<Appbar.Content title="Settings" />
</Appbar.Header>
</>
),
}}
/>
</Stack.Navigator>
</NavigationContainer>
</PaperProvider>
);
}