-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
83 lines (78 loc) · 2.68 KB
/
App.js
File metadata and controls
83 lines (78 loc) · 2.68 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
import React from 'react';
import { View, Text, ActivityIndicator, TouchableOpacity, StyleSheet } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import TopBar from './src/components/TopBar';
import TabNavigator from './src/navigation/TabNavigator';
import { useBootstrap } from './src/hooks/useBootstrap';
import { useChat } from './src/hooks/useChat';
import { useDocuments } from './src/hooks/useDocuments';
import { colors } from './src/theme';
export default function App() {
const bootstrap = useBootstrap();
const chat = useChat();
const docs = useDocuments(() => bootstrap.setDocumentReady(true));
if (bootstrap.loading) {
return (
<SafeAreaProvider>
<View style={styles.splash}>
<ActivityIndicator size="large" color={colors.accent} />
<Text style={styles.splashText}>Connecting to LynorAI…</Text>
</View>
</SafeAreaProvider>
);
}
if (bootstrap.error) {
return (
<SafeAreaProvider>
<View style={styles.splash}>
<Text style={styles.errorIcon}>⚠️</Text>
<Text style={styles.errorText}>{bootstrap.error}</Text>
<TouchableOpacity
style={styles.retryBtn}
onPress={() => bootstrap.retry?.()}
>
<Text style={styles.retryText}>Retry</Text>
</TouchableOpacity>
</View>
</SafeAreaProvider>
);
}
return (
<SafeAreaProvider>
<NavigationContainer
theme={{
dark: true,
colors: {
primary: colors.accent,
background: colors.bgBase,
card: colors.bgSurface,
text: colors.textPrimary,
border: colors.border,
notification: colors.accent,
},
}}
>
<View style={styles.shell}>
<TopBar sandbox={bootstrap.sandbox} version={bootstrap.version} />
<TabNavigator bootstrap={bootstrap} chat={chat} docs={docs} />
</View>
</NavigationContainer>
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
shell: { flex: 1, backgroundColor: colors.bgBase },
splash: {
flex: 1, alignItems: 'center', justifyContent: 'center',
backgroundColor: colors.bgBase, gap: 16,
},
splashText: { fontSize: 14, color: colors.textSecondary },
errorIcon: { fontSize: 48 },
errorText: { fontSize: 14, color: colors.danger, textAlign: 'center', paddingHorizontal: 32 },
retryBtn: {
backgroundColor: colors.accent, paddingHorizontal: 24, paddingVertical: 10,
borderRadius: 8, marginTop: 8,
},
retryText: { color: '#fff', fontWeight: '600', fontSize: 14 },
});