Skip to content

Commit 8cd5921

Browse files
added firebase and email auth
1 parent 58df468 commit 8cd5921

23 files changed

+1318
-92
lines changed

App.tsx

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
import React, { useEffect, useReducer } from "react";
2+
import RNBootSplash from "react-native-bootsplash";
3+
import Routes from "./navigation/Routes";
4+
import { defaultState, Provider, reducer } from "./state";
5+
6+
export default function App() {
7+
const [state, dispatch] = useReducer(reducer, defaultState);
8+
9+
useEffect(() => {
10+
setInterval(() => {
11+
RNBootSplash.hide({ fade: true });
12+
}, 500);
13+
}, []);
14+
return (
15+
<Provider value={{ state, dispatch }}>
16+
<Routes />
17+
</Provider>
18+
);
19+
}
20+
121
// import React, { useEffect } from "react";
222
// import {
323
// SafeAreaView,
@@ -17,19 +37,6 @@
1737
// ReloadInstructions,
1838
// } from "react-native/Libraries/NewAppScreen";
1939

20-
import React, { useEffect } from "react";
21-
import RNBootSplash from "react-native-bootsplash";
22-
import { AuthStack } from "./src/navigation/AuthStack";
23-
24-
export default function App() {
25-
useEffect(() => {
26-
setInterval(() => {
27-
RNBootSplash.hide({ fade: true });
28-
}, 500);
29-
}, []);
30-
return <AuthStack />;
31-
}
32-
3340
// const Section: React.FC<{
3441
// title: string;
3542
// }> = ({ children, title }) => {

Routes.tsx

-16
This file was deleted.

android/.project

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>aviatecodersappv1</name>
4+
<comment>Project android created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
<filteredResources>
18+
<filter>
19+
<id>1629383969817</id>
20+
<name></name>
21+
<type>30</type>
22+
<matcher>
23+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
24+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25+
</matcher>
26+
</filter>
27+
</filteredResources>
28+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arguments=
2+
auto.sync=false
3+
build.scans.enabled=false
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5+
connection.project.dir=
6+
eclipse.preferences.version=1
7+
gradle.user.home=
8+
java.home=C\:/Program Files/Java/jdk-15.0.1
9+
jvm.arguments=
10+
offline.mode=false
11+
override.workspace.settings=true
12+
show.console.view=true
13+
show.executions.view=true

android/app/.classpath

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15/"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin/default"/>
6+
</classpath>

android/app/.project

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>app</name>
4+
<comment>Project app created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1629383969810</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
34+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=..
2+
eclipse.preferences.version=1

android/app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
apply plugin: "com.android.application"
2+
apply plugin: 'com.google.gms.google-services'
23

34
import com.android.build.OutputFile
45

android/app/google-services.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"project_info": {
3+
"project_number": "117683662084",
4+
"project_id": "aviate-coders-f9b36",
5+
"storage_bucket": "aviate-coders-f9b36.appspot.com"
6+
},
7+
"client": [
8+
{
9+
"client_info": {
10+
"mobilesdk_app_id": "1:117683662084:android:beda2b021719684bbfb451",
11+
"android_client_info": {
12+
"package_name": "com.aviatecodersappv1"
13+
}
14+
},
15+
"oauth_client": [
16+
{
17+
"client_id": "117683662084-s4b3j3be99981sm7fsnrk17nbaihsjcc.apps.googleusercontent.com",
18+
"client_type": 1,
19+
"android_info": {
20+
"package_name": "com.aviatecodersappv1",
21+
"certificate_hash": "5e8f16062ea3cd2c4a0d547876baa6f38cabf625"
22+
}
23+
},
24+
{
25+
"client_id": "117683662084-1r32h7r8jm18gno47q727m40cnp5qfed.apps.googleusercontent.com",
26+
"client_type": 3
27+
}
28+
],
29+
"api_key": [
30+
{
31+
"current_key": "AIzaSyBrKNyNO9amRNl2ifGndpFEFqoWsgbFsMs"
32+
}
33+
],
34+
"services": {
35+
"appinvite_service": {
36+
"other_platform_oauth_client": [
37+
{
38+
"client_id": "117683662084-1r32h7r8jm18gno47q727m40cnp5qfed.apps.googleusercontent.com",
39+
"client_type": 3
40+
}
41+
]
42+
}
43+
}
44+
}
45+
],
46+
"configuration_version": "1"
47+
}

android/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ buildscript {
1313
jcenter()
1414
}
1515
dependencies {
16-
classpath("com.android.tools.build:gradle:4.1.0")
16+
classpath('com.android.tools.build:gradle:4.1.2')
17+
classpath 'com.google.gms:google-services:4.3.10'
1718
// NOTE: Do not place your application dependencies here; they belong
1819
// in the individual module build.gradle files
1920
}

navigation/AppStack.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from "react";
2+
import { createNativeStackNavigator } from "@react-navigation/native-stack";
3+
import { AppParamList } from "../types/AppParamList";
4+
import HomeScreen from "../screens/HomeScreen";
5+
6+
interface AppStackProps {}
7+
8+
const Stack = createNativeStackNavigator<AppParamList>();
9+
10+
const AppStack: React.FC<AppStackProps> = ({}) => {
11+
return (
12+
<Stack.Navigator
13+
screenOptions={{
14+
header: () => null,
15+
}}
16+
initialRouteName="HomeScreen"
17+
>
18+
<Stack.Screen
19+
// options={{
20+
// headerTitle: "Sign In"
21+
// }}
22+
name="HomeScreen"
23+
component={HomeScreen}
24+
/>
25+
</Stack.Navigator>
26+
);
27+
};
28+
29+
export default AppStack;

navigation/AuthStack.tsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from "react";
2+
import { createNativeStackNavigator } from "@react-navigation/native-stack";
3+
import { AuthParamList } from "../types/AuthParamList";
4+
import LoginScreen from "../screens/LoginScreen";
5+
import SignupScreen from "../screens/SignupScreen";
6+
7+
interface AuthStackProps {}
8+
9+
const Stack = createNativeStackNavigator<AuthParamList>();
10+
11+
const AuthStack: React.FC<AuthStackProps> = ({}) => {
12+
return (
13+
<Stack.Navigator
14+
screenOptions={{
15+
header: () => null,
16+
}}
17+
initialRouteName="SignupScreen"
18+
>
19+
<Stack.Screen
20+
// options={{
21+
// headerTitle: "Sign In"
22+
// }}
23+
name="LoginScreen"
24+
component={LoginScreen}
25+
/>
26+
<Stack.Screen
27+
// options={{
28+
// headerTitle: "Sign Up"
29+
// }}
30+
name="SignupScreen"
31+
component={SignupScreen}
32+
/>
33+
</Stack.Navigator>
34+
);
35+
};
36+
37+
export default AuthStack;

navigation/Routes.tsx

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React, { useContext, useState, useEffect } from "react";
2+
import { NavigationContainer } from "@react-navigation/native";
3+
import auth from "@react-native-firebase/auth";
4+
import { context } from "../state";
5+
6+
import AuthStack from "./AuthStack";
7+
import AppStack from "./AppStack";
8+
9+
const Routes = () => {
10+
const { state, dispatch } = useContext(context);
11+
const [initializing, setInitializing] = useState(true);
12+
13+
const onAuthStateChanged = (user: any) => {
14+
dispatch({ type: "SET_USER", payload: user });
15+
if (initializing) setInitializing(false);
16+
};
17+
18+
useEffect(() => {
19+
const subscriber = auth().onAuthStateChanged(onAuthStateChanged);
20+
return subscriber; // unsubscribe on unmount
21+
}, []);
22+
23+
if (initializing) return null;
24+
25+
return (
26+
<NavigationContainer>
27+
{state.user ? <AppStack /> : <AuthStack />}
28+
</NavigationContainer>
29+
);
30+
};
31+
32+
export default Routes;

0 commit comments

Comments
 (0)