Skip to content

Commit

Permalink
reconfiguring expo config
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtm984 committed Feb 12, 2024
1 parent 39855be commit 4209d3e
Show file tree
Hide file tree
Showing 5 changed files with 410 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ yarn-error.*

# local env files
.env*.local
.env

# typescript
*.tsbuildinfo

# add app.json to git ignore
app.json
app.config.js
GoogleService-Info.plist
GoogleService-Info-1.plist
firebaseConfig.js
80 changes: 67 additions & 13 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,57 @@
import React, { useEffect } from 'react';
import app from './firebaseConfig';
import { getAuth, signInWithEmailAndPassword} from "firebase/auth";
import React, { useEffect } from "react";
import { StyleSheet, Text, View, Button } from "react-native";
import app from "./firebaseConfig";
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword, GoogleAuthProvider, signInWithCredential } from "firebase/auth";
import * as Google from "expo-auth-session/providers/google";
import { ResponseType } from "expo-auth-session";

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Button } from 'react-native';
import { StatusBar } from "expo-status-bar";

const auth = getAuth(app);

// Sign Up
const signUpWithEmail = async (email: string, password: string) => {
try {
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
console.log("User created:", userCredential.user);
// Navigate to your app's main content or verify email
} catch (error) {
console.error(error);
// Show error message to user

}
};

// Sign In
const signInWithEmail = async (email: string, password: string) => {
try {
const userCredential = await signInWithEmailAndPassword(auth, email, password);
console.log("User signed in:", userCredential.user);
// Navigate to your app's main content
} catch (error) {
console.error(error);
// Show error message to user
}
};

const googleLogin = async () => {
const auth = getAuth();
const [request, response, promptAsync] = await Google.useIdTokenAuthRequest({
clientId: 'YOUR_WEB_CLIENT_ID_FROM_FIREBASE',
});

if (response?.type === 'success' && response.authentication) {
const credential = GoogleAuthProvider.credential(response.authentication.idToken);
signInWithCredential(auth, credential).catch((error) => {
console.log(error);
});
}
};

export default function App() {
const [request, response, promptAsync] = Google.useIdTokenAuthRequest({
clientId: "Your_Google_ClientId",
});

const testSignIn = () => {
signInWithEmailAndPassword(auth, "[email protected]", "testpassword")
Expand All @@ -20,28 +64,38 @@ export default function App() {
const errorCode = error.code;
const errorMessage = error.message;
console.log("Error signing in: ", errorCode, errorMessage);
})
}
});
};

useEffect(() => {

}, [])

if (response?.type === "success") {
const { id_token } = response.params;
// Use the Google ID token to sign in with backend
}
}, [response]);

return (
<View style={styles.container}>
<Text>Firebase Authentication Test</Text>
<StatusBar style="auto" />
<Button title="Test Sign In" onPress={testSignIn} />
<Button
disabled={!request}
title="Login with Google"
onPress={() => {
promptAsync();
}}
/>
<Button title="Sign in with Google" onPress={googleLogin} />
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
20 changes: 20 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Firebase Authentication Integration:
Continue integrating Firebase for authentication features, which seems to be in progress. Ensure various authentication methods (like social logins) are available to cater to different user preferences.

# Implement User Interface (UI) for Authentication:
Develop a more sophisticated UI for sign-in, sign-up, password reset, etc., using React Native components. This should provide a seamless and intuitive experience for users.

# Setup Navigation:
Implement navigation for the app using React Navigation or a similar library. This will allow users to move between different screens, such as the home screen, court search, favorites, and profile settings.

# Implement Court Search Functionality:
Utilize Firebase Firestore or Realtime Database to store and retrieve court information. Implement functionality for users to search for sports courts based on location, availability, and other criteria.

# Court Booking System:
Develop a mock booking system where users can choose a court and time slot for booking. This system can initially use static data, with plans to integrate a backend service for real-time bookings in the future.

# User Reviews and Ratings:
Allow users to submit reviews and ratings for sports courts. This involves UI components for displaying and submitting reviews, as well as backend logic to store and retrieve these reviews from Firebase.

# Deployment and Testing:
Prepare the app for deployment using Expo's build services. Ensure thorough testing on both iOS and Android devices to catch and fix any platform-specific issues.
Loading

0 comments on commit 4209d3e

Please sign in to comment.