-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApp.js
More file actions
127 lines (116 loc) · 3.99 KB
/
Copy pathApp.js
File metadata and controls
127 lines (116 loc) · 3.99 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import React, { Fragment, useEffect, useState } from 'react';
import { SafeAreaView, StatusBar, StyleSheet } from 'react-native';
import Text from './defaultSetting/FontText'
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { GoogleSignin } from '@react-native-google-signin/google-signin';
import auth from '@react-native-firebase/auth';
import Icon from 'react-native-vector-icons/FontAwesome';
import Authentication from './jin/screens/Authentication';
import RestHome from './restaurant/RestHome.js';
// import Chatroom from "./jin/screens/Chatroom.js";
import Chatroom from "./jin/ChatNavigator";
import ClientId from "./android/app/google-services.json";
//import SecureKey from "./defaultSetting/secure.json";
const BTab = createBottomTabNavigator();
export default function App() {
const [authenticated, setAuthenticated] = useState(false);
const [inProgress, setProgress] = useState(false);
useEffect(() => {
GoogleSignin.configure({
webClientId: ClientId["client"][0]["oauth_client"][3]["client_id"]
});
}, []);
/*
const linking = {
prefixes: ['kakao{' + SecureKey.kakaonative + '}://'],
config: {
screens: {
'식당 정보': 'kakaolink'
},
},
};
*/
async function onGoogleButtonPress() {
setProgress(true);
try {
const { idToken } = await GoogleSignin.signIn();
const googleCredential = auth.GoogleAuthProvider.credential(idToken);
return auth().signInWithCredential(googleCredential);
} catch (error) {
console.log(error);
setProgress(false);
}
}
auth().onAuthStateChanged((user) => {
if (user) {
setAuthenticated(true);
setProgress(false);
} else {
setAuthenticated(false);
}
});
if (authenticated) {
return (
<Fragment>
<SafeAreaView style={{ flex: 0, backgroundColor: '#BF2A52' }} />
<SafeAreaView style={{ flex: 1, backgroundColor: '#efefef' }}>
<StatusBar barStyle="light-content" />
{/* <NavigationContainer linking={linking}> */}
<NavigationContainer>
<BTab.Navigator
screenOptions={({ route }) => ({
tabBarLabel: ({ focused }) => {
return <Text style={focused ? styles.focusLabel : styles.unfocusLabel}>{route.name}</Text>
},
tabBarIcon: ({ focused }) => {
let iconName;
if (route.name == '식당') {
iconName = 'cutlery';
} else if (route.name == '같이 배달') {
iconName = 'automobile';
}
if (focused) {
return <Icon name={iconName} size={20} color="#BF2A52" />;
} else {
return <Icon name={iconName} size={16} color="#aaa" />;
}
},
tabBarStyle: {
height: '8%',
backgroundColor: '#efefef',
paddingTop: 7,
paddingBottom: 7
},
tabBarActiveBackgroundColor: '#efefef',
tabBarInactiveBackgroundColor: '#efefef',
tabBarHideOnKeyboard: true
})}>
<BTab.Screen
name='식당'
component={RestHome}
options={{ headerShown: false }} />
<BTab.Screen
name='같이 배달'
component={Chatroom}
options={{ headerShown: false }} />
</BTab.Navigator>
</NavigationContainer>
</SafeAreaView>
</Fragment>
);
}
return <Authentication onGoogleButtonPress={onGoogleButtonPress} disabled={inProgress} />
}
const styles = StyleSheet.create({
focusLabel: {
fontSize: 14,
color: '#bf2a52',
fontFamily: 'ELANDChoiceB',
},
unfocusLabel: {
fontSize: 12,
color: '#aaaaaa',
fontFamily: 'ELANDchoiceM'
}
})