-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.js
More file actions
46 lines (42 loc) · 1.27 KB
/
Main.js
File metadata and controls
46 lines (42 loc) · 1.27 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
import React, { useState } from 'react';
import { View, StyleSheet, ScrollView, useWindowDimensions } from 'react-native';
import { useThemeContext } from './context/ThemeContext';
import Navbar from './components/Navbar';
import Home from './screens/Home';
import Playground from './screens/Playground';
import Docs from './screens/Docs';
export default function Main() {
const [page, setPage] = useState('Home');
const { colors } = useThemeContext();
const { width } = useWindowDimensions();
const isSmall = width < 500;
const renderPage = () => {
switch (page) {
case 'Home': return <Home navigate={setPage} />;
case 'Playground': return <Playground />;
case 'Docs': return <Docs />;
default: return <Home navigate={setPage} />;
}
};
return (
<View style={[styles.container, { backgroundColor: colors.background }]}>
<Navbar currentPage={page} navigate={setPage} />
<ScrollView contentContainerStyle={[styles.content, isSmall && styles.contentSmall]}>
{renderPage()}
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1 },
content: {
alignItems: 'center',
justifyContent: 'center',
padding: 40,
gap: 20,
},
contentSmall: {
padding: 20,
gap: 14,
},
});