-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathApp.tsx
57 lines (47 loc) · 1.59 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
import "react-native-gesture-handler";
import "react-native-get-random-values";
import { useEffect } from "react";
import { StatusBar } from "expo-status-bar";
import { SafeAreaProvider } from "react-native-safe-area-context";
import useCachedResources from "./src/hooks/useCachedResources";
import Navigation from "./src/navigation";
import { StreamChat } from "stream-chat";
import { OverlayProvider, Chat, Theme, DeepPartial } from "stream-chat-expo";
import AuthContext from "./src/contexts/AuthContext";
import { StreamColors } from "./src/constants/Colors";
import { Amplify, Auth } from "aws-amplify";
import { withAuthenticator } from "aws-amplify-react-native";
import awsconfig from "./src/aws-exports";
Amplify.configure({ ...awsconfig, Analytics: { disabled: true } });
const API_KEY = "tmdq3ta7ah6k";
const client = StreamChat.getInstance(API_KEY);
const theme: DeepPartial<Theme> = {
colors: StreamColors,
};
function App() {
const isLoadingComplete = useCachedResources();
useEffect(() => {
// this is done when component mounts
return () => {
// this is done when component unmounts
client.disconnectUser();
};
}, []);
if (!isLoadingComplete) {
return null;
} else {
return (
<SafeAreaProvider>
<AuthContext client={client}>
<OverlayProvider value={{ style: theme }}>
<Chat client={client}>
<Navigation colorScheme={"dark"} />
</Chat>
</OverlayProvider>
</AuthContext>
<StatusBar style="light" />
</SafeAreaProvider>
);
}
}
export default withAuthenticator(App);