Skip to content

Commit

Permalink
Merge pull request #5 from sarthakpranesh/develop
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
Sarthak Pranesh authored Jun 7, 2020
2 parents 542831e + bba809c commit bbb4fa9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 68 deletions.
115 changes: 63 additions & 52 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';
import React, {Component} from 'react';
import {StatusBar} from 'react-native';
import auth from '@react-native-firebase/auth';
import SplashScreen from 'react-native-splash-screen';

import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';

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

const Stack = createStackNavigator();

function DefaultStack() {
return (
<Stack.Navigator
options={{
animationEnabled: false,
}}
initialRouteName="Home"
headerMode="none">
<Stack.Screen
options={{
animationEnabled: false,
}}
name="Home"
component={GameHome}
/>
<Stack.Screen
options={{
animationEnabled: false,
}}
name="Play"
component={Play}
/>
<Stack.Screen
options={{
animationEnabled: false,
}}
name="LeaderBoard"
component={LeaderBoard}
/>
</Stack.Navigator>
);
}
class DefaultStack extends Component {
constructor(props) {
super(props);

function UserStartingStack() {
return (
<Stack.Navigator
options={{
animationEnabled: false,
}}
initialRouteName="Start"
headerMode="none">
<Stack.Screen
this.state = {
isSigned: false,
};
}

componentDidMount() {
auth().onAuthStateChanged(user => {
this.setState({isSigned: user ? true : false});
SplashScreen.hide();
});
}

render() {
const {isSigned} = this.state;

return isSigned ? (
<Stack.Navigator
options={{
animationEnabled: false,
}}
name="Start"
component={UserStarting}
/>
<Stack.Screen
initialRouteName="Home"
headerMode="none">
<Stack.Screen
options={{
animationEnabled: false,
}}
name="Home"
component={GameHome}
/>
<Stack.Screen
options={{
animationEnabled: false,
}}
name="Play"
component={Play}
/>
<Stack.Screen
options={{
animationEnabled: false,
}}
name="LeaderBoard"
component={LeaderBoard}
/>
</Stack.Navigator>
) : (
<Stack.Navigator
options={{
animationEnabled: false,
}}
name="DefaultStack"
component={DefaultStack}
/>
</Stack.Navigator>
);
initialRouteName="Home"
headerMode="none">
<Stack.Screen
options={{
animationEnabled: false,
}}
name="Start"
component={UserStarting}
/>
</Stack.Navigator>
);
}
}

export default function App() {
return (
<NavigationContainer>
<StatusBar hidden={true} />
<UserStartingStack />
<DefaultStack />
</NavigationContainer>
);
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"scripts": {
"android": "npx react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start --reset-cache",
"ios": "npx react-native run-ios",
"start": "npx react-native start --reset-cache",
"test": "jest",
"lint": "eslint .",
"build-android": "cd ./android && ./gradlew clean && ./gradlew assembleRelease"
Expand Down
1 change: 0 additions & 1 deletion src/screens/GameHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export default class GameHome extends Component {
await GoogleSignin.revokeAccess();
await GoogleSignin.signOut();
auth().signOut();
this.props.navigation.navigate('Start');
}}>
<Text style={styles.buttonText}>LogOut</Text>
</TouchableOpacity>
Expand Down
12 changes: 0 additions & 12 deletions src/screens/UserStarting.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
GoogleSigninButton,
statusCodes,
} from '@react-native-community/google-signin';
import SplashScreen from 'react-native-splash-screen';

GoogleSignin.configure({
webClientId:
'831535281165-raapdh2a3l20d64qvrfkdi3co1s96utr.apps.googleusercontent.com',
Expand All @@ -21,16 +19,6 @@ export default class UserStarting extends Component {
super(props);
}

componentDidMount() {
auth().onAuthStateChanged(user => {
if (user) {
this.props.navigation.navigate('DefaultStack');
}
console.log('Start Screen');
SplashScreen.hide();
});
}

async onContinueWithGoogle() {
try {
await GoogleSignin.hasPlayServices();
Expand Down

0 comments on commit bbb4fa9

Please sign in to comment.