Skip to content

Commit bbb4fa9

Browse files
author
Sarthak Pranesh
authored
Merge pull request #5 from sarthakpranesh/develop
Updates
2 parents 542831e + bba809c commit bbb4fa9

File tree

5 files changed

+66
-68
lines changed

5 files changed

+66
-68
lines changed

App.js

Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import React from 'react';
1+
import React, {Component} from 'react';
22
import {StatusBar} from 'react-native';
3+
import auth from '@react-native-firebase/auth';
4+
import SplashScreen from 'react-native-splash-screen';
5+
36
import {NavigationContainer} from '@react-navigation/native';
47
import {createStackNavigator} from '@react-navigation/stack';
58

@@ -11,70 +14,78 @@ import LeaderBoard from './src/screens/Leaderboard.js';
1114

1215
const Stack = createStackNavigator();
1316

14-
function DefaultStack() {
15-
return (
16-
<Stack.Navigator
17-
options={{
18-
animationEnabled: false,
19-
}}
20-
initialRouteName="Home"
21-
headerMode="none">
22-
<Stack.Screen
23-
options={{
24-
animationEnabled: false,
25-
}}
26-
name="Home"
27-
component={GameHome}
28-
/>
29-
<Stack.Screen
30-
options={{
31-
animationEnabled: false,
32-
}}
33-
name="Play"
34-
component={Play}
35-
/>
36-
<Stack.Screen
37-
options={{
38-
animationEnabled: false,
39-
}}
40-
name="LeaderBoard"
41-
component={LeaderBoard}
42-
/>
43-
</Stack.Navigator>
44-
);
45-
}
17+
class DefaultStack extends Component {
18+
constructor(props) {
19+
super(props);
4620

47-
function UserStartingStack() {
48-
return (
49-
<Stack.Navigator
50-
options={{
51-
animationEnabled: false,
52-
}}
53-
initialRouteName="Start"
54-
headerMode="none">
55-
<Stack.Screen
21+
this.state = {
22+
isSigned: false,
23+
};
24+
}
25+
26+
componentDidMount() {
27+
auth().onAuthStateChanged(user => {
28+
this.setState({isSigned: user ? true : false});
29+
SplashScreen.hide();
30+
});
31+
}
32+
33+
render() {
34+
const {isSigned} = this.state;
35+
36+
return isSigned ? (
37+
<Stack.Navigator
5638
options={{
5739
animationEnabled: false,
5840
}}
59-
name="Start"
60-
component={UserStarting}
61-
/>
62-
<Stack.Screen
41+
initialRouteName="Home"
42+
headerMode="none">
43+
<Stack.Screen
44+
options={{
45+
animationEnabled: false,
46+
}}
47+
name="Home"
48+
component={GameHome}
49+
/>
50+
<Stack.Screen
51+
options={{
52+
animationEnabled: false,
53+
}}
54+
name="Play"
55+
component={Play}
56+
/>
57+
<Stack.Screen
58+
options={{
59+
animationEnabled: false,
60+
}}
61+
name="LeaderBoard"
62+
component={LeaderBoard}
63+
/>
64+
</Stack.Navigator>
65+
) : (
66+
<Stack.Navigator
6367
options={{
6468
animationEnabled: false,
6569
}}
66-
name="DefaultStack"
67-
component={DefaultStack}
68-
/>
69-
</Stack.Navigator>
70-
);
70+
initialRouteName="Home"
71+
headerMode="none">
72+
<Stack.Screen
73+
options={{
74+
animationEnabled: false,
75+
}}
76+
name="Start"
77+
component={UserStarting}
78+
/>
79+
</Stack.Navigator>
80+
);
81+
}
7182
}
7283

7384
export default function App() {
7485
return (
7586
<NavigationContainer>
7687
<StatusBar hidden={true} />
77-
<UserStartingStack />
88+
<DefaultStack />
7889
</NavigationContainer>
7990
);
8091
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"private": true,
55
"scripts": {
66
"android": "npx react-native run-android",
7-
"ios": "react-native run-ios",
8-
"start": "react-native start --reset-cache",
7+
"ios": "npx react-native run-ios",
8+
"start": "npx react-native start --reset-cache",
99
"test": "jest",
1010
"lint": "eslint .",
1111
"build-android": "cd ./android && ./gradlew clean && ./gradlew assembleRelease"

src/screens/GameHome.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ export default class GameHome extends Component {
158158
await GoogleSignin.revokeAccess();
159159
await GoogleSignin.signOut();
160160
auth().signOut();
161-
this.props.navigation.navigate('Start');
162161
}}>
163162
<Text style={styles.buttonText}>LogOut</Text>
164163
</TouchableOpacity>

src/screens/UserStarting.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import {
66
GoogleSigninButton,
77
statusCodes,
88
} from '@react-native-community/google-signin';
9-
import SplashScreen from 'react-native-splash-screen';
10-
119
GoogleSignin.configure({
1210
webClientId:
1311
'831535281165-raapdh2a3l20d64qvrfkdi3co1s96utr.apps.googleusercontent.com',
@@ -21,16 +19,6 @@ export default class UserStarting extends Component {
2119
super(props);
2220
}
2321

24-
componentDidMount() {
25-
auth().onAuthStateChanged(user => {
26-
if (user) {
27-
this.props.navigation.navigate('DefaultStack');
28-
}
29-
console.log('Start Screen');
30-
SplashScreen.hide();
31-
});
32-
}
33-
3422
async onContinueWithGoogle() {
3523
try {
3624
await GoogleSignin.hasPlayServices();

0 commit comments

Comments
 (0)