-
Notifications
You must be signed in to change notification settings - Fork 15
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
11 changed files
with
832 additions
and
91 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NativeStack } from 'expo-router' | ||
import { useDripsyTheme } from 'dripsy' | ||
|
||
export function Stack({ children }) { | ||
const { colors } = useDripsyTheme().theme | ||
return ( | ||
<NativeStack | ||
screenOptions={{ | ||
headerStyle: { | ||
backgroundColor: colors.$background2, | ||
}, | ||
headerTitleStyle: { | ||
color: colors.$text, | ||
}, | ||
headerTintColor: '#D864D8', | ||
headerShadowVisible: false, | ||
}} | ||
> | ||
{children} | ||
</NativeStack> | ||
) | ||
} | ||
|
||
Stack.Screen = NativeStack.Screen |
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,17 @@ | ||
import Constants from 'expo-constants' | ||
import { Firebase } from './types' | ||
|
||
const isExpoGo = Constants.appOwnership == 'expo' | ||
|
||
let exports: Firebase | ||
|
||
// here we check if the user has properly set up their native app | ||
// if not, we fall back to firebase JS | ||
|
||
if (isExpoGo) { | ||
exports = require('./init.web') | ||
} else { | ||
exports = require('./init.native') | ||
} | ||
|
||
module.exports = exports |
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 @@ | ||
export * from './init.web' |
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,17 @@ | ||
import auth from '@react-native-firebase/auth' | ||
import { Firebase } from './types' | ||
|
||
const getIsSignedIn: Firebase['getIsSignedIn'] = () => | ||
Boolean(auth().currentUser) | ||
|
||
const signOut: Firebase['signOut'] = () => auth().signOut() | ||
|
||
const signInAnonymously: Firebase['signInAnonymously'] = async () => { | ||
return (await auth().signInAnonymously()).user | ||
} | ||
|
||
const onIdTokenChanged: Firebase['onIdTokenChanged'] = (callback) => { | ||
return auth().onIdTokenChanged(callback) | ||
} | ||
|
||
export { getIsSignedIn, signOut, signInAnonymously, onIdTokenChanged } |
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,37 @@ | ||
import { initializeApp } from 'firebase/app' | ||
import { | ||
initializeAuth, | ||
browserPopupRedirectResolver, | ||
browserLocalPersistence, | ||
signInAnonymously as signInAnonymouslyFirebase, | ||
onIdTokenChanged as onIdTokenChangedFirebase, | ||
} from 'firebase/auth' | ||
import { Firebase } from './types' | ||
|
||
let auth: ReturnType<typeof initializeAuth> | ||
|
||
if (typeof window !== 'undefined') { | ||
const firebaseApp = initializeApp({ | ||
// REPLACE THIS WITH YOUR AUTH CONFIG | ||
}) | ||
|
||
auth = initializeAuth(firebaseApp, { | ||
popupRedirectResolver: browserPopupRedirectResolver, | ||
persistence: browserLocalPersistence, | ||
}) | ||
} | ||
|
||
const getIsSignedIn: Firebase['getIsSignedIn'] = () => | ||
Boolean(auth?.currentUser) | ||
|
||
const signOut: Firebase['signOut'] = () => auth.signOut() | ||
|
||
const signInAnonymously: Firebase['signInAnonymously'] = async () => { | ||
return (await signInAnonymouslyFirebase(auth)).user | ||
} | ||
|
||
const onIdTokenChanged: Firebase['onIdTokenChanged'] = (callback) => { | ||
return onIdTokenChangedFirebase(auth, callback) | ||
} | ||
|
||
export { getIsSignedIn, signInAnonymously, signOut, onIdTokenChanged } |
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,10 @@ | ||
import type * as firebase from 'firebase/auth' | ||
|
||
export type Firebase = { | ||
getIsSignedIn: () => boolean | ||
signInAnonymously: () => Promise<Pick<firebase.User, 'uid'>> | ||
signOut: () => Promise<void> | ||
onIdTokenChanged: ( | ||
callback: (user: { uid: string } | null) => void | ||
) => () => void | ||
} |
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
Oops, something went wrong.