forked from victorsoares96/epubjs-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
103 lines (97 loc) · 2.34 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
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
import * as React from 'react';
import { NavigationContainer, useNavigation } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { SafeAreaView, StyleSheet, Text, TouchableOpacity } from 'react-native';
import {
Basic,
Formats,
CustomThemes,
InitialLocation,
Search,
} from './examples';
const { Navigator, Screen } = createNativeStackNavigator();
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'flex-start',
alignItems: 'center',
paddingVertical: 16,
},
button: {
padding: 8,
width: '90%',
borderBottomColor: '#c0c0c0',
borderBottomWidth: 2,
},
});
export const examples = [
{
title: 'Basic',
description: 'The minimum to work.',
route: 'Basic',
component: Basic,
},
{
title: 'Formats',
description:
'Loading a book of different formats. (opf, epub, base64 and internal)',
route: 'Formats',
component: Formats,
},
{
title: 'Custom Themes',
description: 'Loading a book with custom themes.',
route: 'Themes',
component: CustomThemes,
},
{
title: 'Initial Location',
description: 'Open book in specific location.',
route: 'InitialLocation',
component: InitialLocation,
},
{
title: 'Search',
description: 'Search terms in the book.',
route: 'Search',
component: Search,
},
];
function Examples() {
const { navigate } = useNavigation();
return (
<SafeAreaView style={styles.container}>
{examples.map(({ title, description, route }) => (
<TouchableOpacity
style={styles.button}
key={route}
onPress={() => navigate(route as never)}
>
<Text>{title}</Text>
<Text>{description}</Text>
</TouchableOpacity>
))}
</SafeAreaView>
);
}
export default function App() {
return (
<NavigationContainer>
<Navigator initialRouteName="Examples">
<Screen
name="Examples"
options={{ title: 'Examples' }}
component={Examples}
/>
{examples.map(({ title, route, component: Example }) => (
<Screen
key={route}
name={route}
options={{ title }}
component={Example}
/>
))}
</Navigator>
</NavigationContainer>
);
}