-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.tsx
58 lines (52 loc) · 1.19 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
import * as React from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';
import { AuthProvider, useAuth } from './Auth';
const LogOutButton = () => {
const { signOut } = useAuth();
return <Button title="Log Out" onPress={signOut} />;
};
const LogInButton = () => {
const { signIn } = useAuth();
return <Button title="Log IN" onPress={() => signIn('my_token')} />;
};
const Main = () => {
const { status, userToken } = useAuth();
return (
<View style={styles.container}>
<Text style={styles.text}>status : {status}</Text>
<Text style={styles.text}>
userToken : {userToken ? userToken : 'null'}
</Text>
<View style={styles.actions}>
<LogInButton />
<LogOutButton />
</View>
</View>
);
};
export default function App() {
return (
<AuthProvider>
<Main />
</AuthProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#ecf0f1',
padding: 8,
},
button: {
margin: 24,
},
actions: {
flexDirection: 'row',
justifyContent: 'space-around',
paddingVertical: 20,
},
text: {
textAlign: 'center',
},
});