forked from court-me/court-me
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
410 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
|
@@ -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", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.