-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy path_layout.tsx
More file actions
157 lines (149 loc) · 4.31 KB
/
_layout.tsx
File metadata and controls
157 lines (149 loc) · 4.31 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import { Drawer } from 'expo-router/drawer';
import { initExecutorch } from 'react-native-executorch';
import { ExpoResourceFetcher } from '@react-native-executorch/expo-resource-fetcher';
import ColorPalette from '../colors';
import React, { useState } from 'react';
import { Text, StyleSheet, View } from 'react-native';
import {
DrawerContentComponentProps,
DrawerContentScrollView,
DrawerItemList,
} from '@react-navigation/drawer';
import { GeneratingContext } from '../context';
initExecutorch({
resourceFetcher: ExpoResourceFetcher,
});
interface CustomDrawerProps extends DrawerContentComponentProps {
isGenerating: boolean;
}
function CustomDrawerContent(props: CustomDrawerProps) {
const { isGenerating, ...otherProps } = props;
return (
<DrawerContentScrollView {...otherProps}>
{!isGenerating ? (
<DrawerItemList {...otherProps} />
) : (
<View style={styles.centerContent}>
<Text style={styles.mainText}>Model is generating...</Text>
<Text style={styles.subText}>Interrupt before switching model</Text>
</View>
)}
</DrawerContentScrollView>
);
}
export default function _layout() {
const [isGenerating, setIsGenerating] = useState(false);
return (
<GeneratingContext
value={{
setGlobalGenerating: (newState: boolean) => {
setIsGenerating(newState);
},
}}
>
<Drawer
drawerContent={(props) => (
<CustomDrawerContent {...props} isGenerating={isGenerating} />
)}
screenOptions={{
drawerActiveTintColor: ColorPalette.primary,
drawerInactiveTintColor: '#888',
headerTintColor: ColorPalette.primary,
headerTitleStyle: { color: ColorPalette.primary },
}}
>
<Drawer.Screen
name="vision_camera/index"
options={{
drawerLabel: 'Vision Camera',
title: 'Vision Camera',
headerShown: false,
headerTitleStyle: { color: ColorPalette.primary },
}}
/>
<Drawer.Screen
name="classification/index"
options={{
drawerLabel: 'Classification',
title: 'Classification',
headerTitleStyle: { color: ColorPalette.primary },
}}
/>
<Drawer.Screen
name="semantic_segmentation/index"
options={{
drawerLabel: 'Semantic Segmentation',
title: 'Semantic Segmentation',
headerTitleStyle: { color: ColorPalette.primary },
}}
/>
<Drawer.Screen
name="object_detection/index"
options={{
drawerLabel: 'Object Detection',
title: 'Object Detection',
headerTitleStyle: { color: ColorPalette.primary },
}}
/>
<Drawer.Screen
name="ocr/index"
options={{
drawerLabel: 'OCR',
title: 'OCR',
headerTitleStyle: { color: ColorPalette.primary },
}}
/>
<Drawer.Screen
name="ocr_vertical/index"
options={{
drawerLabel: 'OCR Vertical',
title: 'Vertical OCR',
headerTitleStyle: { color: ColorPalette.primary },
}}
/>
<Drawer.Screen
name="style_transfer/index"
options={{
drawerLabel: 'Style Transfer',
title: 'Style Transfer',
headerTitleStyle: { color: ColorPalette.primary },
}}
/>
<Drawer.Screen
name="text_to_image/index"
options={{
drawerLabel: 'Image Generation',
title: 'Image Generation',
headerTitleStyle: { color: ColorPalette.primary },
}}
/>
<Drawer.Screen
name="index"
options={{
drawerLabel: () => null,
title: 'Main Menu',
drawerItemStyle: { display: 'none' },
}}
/>
</Drawer>
</GeneratingContext>
);
}
const styles = StyleSheet.create({
centerContent: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
},
mainText: {
fontSize: 18,
fontWeight: 'bold',
marginBottom: 10,
color: ColorPalette.primary,
},
subText: {
fontSize: 14,
color: ColorPalette.strongPrimary,
},
});