-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
96 lines (93 loc) · 3.36 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
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
import React, {useEffect, useState} from 'react';
import {StatusUpdate} from './pages/update'
import {StatusComment} from './pages/createComment'
import {StatusDetail} from './pages/detail'
import {StatusShare} from './pages/reply'
import {StatusDelete} from './pages/delete'
import {GroupDetailScreen} from './pages/groupDetail'
import {NavigationContainer} from '@react-navigation/native'
import {createStackNavigator} from '@react-navigation/stack'
import {Home} from './home'
import {ProfileScreen} from './pages/viewProfile'
import {RegisterComponent} from './screens/auth/register'
import {LoginComponent} from './screens/auth/login.js'
import {CreatePostScreen} from './pages/createPost'
import AsyncStorage from '@react-native-async-storage/async-storage';
const Stack = createStackNavigator();
const homeStyles = {
headerTintColor: "black",
headerStyle :{
height:0,
}
}
const navbarStyles = {
headerTintColor: "black",
headerStyle :{
alignItems: 'center',
justifyContent: 'center',
height:40,
}
}
const profileStyles = {
alignItems: 'center',
justifyContent: 'center',
title:"Checkout",
headerStyle :{
alignItems: 'center',
justifyContent: 'center',
height:40,
}
}
const CreatePostStyles = {
title:"Create a Post",
backgroundColor:'white',
headerStyle :{
height:40,
backgroundColor:'white'
}
}
export default function App(props) {
const [tok, settok] = useState()
const [loggedIn, setLoggedIn] = useState(false)
const getData = async () => {
try {
const value = await AsyncStorage.getItem('Token')
if (value !== 'undefined'){
var token = value.replace('"', '').replace('"', '')
settok(token)
setLoggedIn(true)
}else{
setLoggedIn(false)
}
} catch(e) {
console.log(e)
}
}
getData()
if (loggedIn){
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="home">
<Stack.Screen style={{fontFamily: "Poppins-Bold"}} initialParams={{'token':tok}} options={homeStyles} name="home" component={Home} />
{/* <Stack.Screen initialParams={{'token':tok}} options={navbarStyles} name="reply" component={StatusShare}/>
<Stack.Screen initialParams={{'token':tok}} options={CreatePostStyles} name="createPost" component={CreatePostScreen}/>
<Stack.Screen initialParams={{'token':tok}} options={profileStyles} name="viewProfile" component={ProfileScreen}/>
<Stack.Screen initialParams={{'token':tok}} options={navbarStyles} name="update" component={StatusUpdate}/>
<Stack.Screen initialParams={{'token':tok}} options={navbarStyles} name="delete" component={StatusDelete}/>
<Stack.Screen initialParams={{'token':tok}} options={navbarStyles} name="detail" component={StatusDetail}/>
<Stack.Screen initialParams={{'token':tok}} options={navbarStyles} name="viewgroup" component={GroupDetailScreen}/>
<Stack.Screen initialParams={{'token':tok}} options={navbarStyles} name="comment" component={StatusComment}/> */}
</Stack.Navigator>
</NavigationContainer>
);
}else{
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="login">
<Stack.Screen name="login" component={LoginComponent}/>
<Stack.Screen name="register" component={RegisterComponent}/>
</Stack.Navigator>
</NavigationContainer>
);
}
}