-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
59 lines (53 loc) · 1.53 KB
/
App.js
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
import React from "react";
import { View, Button } from "react-native";
import Amplify, { Auth } from "aws-amplify";
import { withAuthenticator } from "aws-amplify-react-native";
import { DataStore } from "@aws-amplify/datastore";
import Channels from "./src/channels";
import ChannelMessages from "./src/channelMessages";
import LoadAuth from "./src/auth";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import awsconfig from "./src/aws-exports"; // if you are using Amplify CLI
//Amplify.configure(awsconfig);
Amplify.configure({
...awsconfig,
Analytics: {
disabled: true
}
});
const Stack = createStackNavigator();
async function logout() {
await DataStore.clear();
Auth.signOut();
}
function Appstart() {
return (
<View
style={{
marginTop: 40,
display: "flex",
flex: 1
}}
>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Auth" component={LoadAuth} />
<Stack.Screen
name="Channel"
component={Channels}
options={{
headerLeft: null,
headerTitle: "Channels",
headerRight: () => (
<Button onPress={() => logout()} title="Logout" color="#000" />
)
}}
/>
<Stack.Screen name="Messages" component={ChannelMessages} />
</Stack.Navigator>
</NavigationContainer>
</View>
);
}
export default withAuthenticator(Appstart);