Skip to content

Commit

Permalink
feat: migrate to firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammedKpln committed Jan 7, 2024
1 parent 0e82008 commit b43e14a
Show file tree
Hide file tree
Showing 46 changed files with 2,486 additions and 2,709 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@ yarn-error.log

.env
.vscode
.tamagui
.tamagui

# Firebase

lib/firebase/google-services.json
lib/firebase/GoogleService-Info.plist
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
# The following patterns were generated by expo-cli

expo-env.d.ts
# @end expo-cli
53 changes: 53 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ConfigContext, ExpoConfig } from 'expo/config';

export default ({ config }: ConfigContext): ExpoConfig => ({
scheme: 'scango',
userInterfaceStyle: 'automatic',
splash: {
backgroundColor: '#ddffe2',
image: './assets/splash.png',
resizeMode: 'contain'
},
web: {
bundler: 'metro'
},
android: {
softwareKeyboardLayoutMode: 'pan',
googleServicesFile: process.env.GOOGLE_SERVICES_ANDROID_JSON,
package: 'com.muhammedkpln.scango'
},
ios: {
googleServicesFile: process.env.GOOGLE_SERVICES_IOS,
bundleIdentifier: 'com.muhammedkpln.scango'
},
icon: './assets/icon.png',
name: 'scan-and-go-mobile',
slug: 'scan-and-go-mobile',
experiments: {
tsconfigPaths: true,
typedRoutes: true
},
plugins: [
'expo-router',
'@react-native-firebase/app',
'@react-native-firebase/auth',
[
'expo-build-properties',
{
ios: {
useFrameworks: 'static'
}
}
]
],
sdkVersion: '49.0.0',
extra: {
eas: {
projectId: '408c9fba-4d1d-444a-adf9-4156fa5175b0'
}
},
updates: {
url: 'https://u.expo.dev/408c9fba-4d1d-444a-adf9-4156fa5175b0'
},
runtimeVersion: 'appVersion'
});
25 changes: 0 additions & 25 deletions app.json

This file was deleted.

7 changes: 3 additions & 4 deletions app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { useSession } from '@/lib/context/auth.context';
import { AuthState } from '@/lib/stores/auth.store';
import useSession from '@lib/hooks/useSession';
import { Redirect, Stack } from 'expo-router';
import React from 'react';

export default function Layout() {
const { authState } = useSession();
const { isLoggedIn } = useSession();

if (authState === AuthState.None) {
if (!isLoggedIn) {
return <Redirect href="/sign-in" />;
}

Expand Down
17 changes: 6 additions & 11 deletions app/(app)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Button } from '@/lib/components/Button';
import { useSession } from '@/lib/context/auth.context';
import { AuthState } from '@/lib/stores/auth.store';
import { Button } from '@lib/components/Button';
import useSession from '@lib/hooks/useSession';
import { useAssets } from 'expo-asset';
import { Redirect, router } from 'expo-router';
import { router } from 'expo-router';
import { useCallback } from 'react';
import { Image, Text, View, styled } from 'tamagui';

Expand All @@ -23,12 +22,8 @@ const LogoBackground = styled(View, {
});

export default function Home() {
const [assets] = useAssets([require('@/assets/logo-icon.png')]);
const { authState } = useSession();

if (authState === AuthState.LoggedIn) {
return <Redirect href="/home" />;
}
const [assets] = useAssets([require('@assets/logo-icon.png')]);
const { isLoggedIn } = useSession();

const onPressContiune = useCallback(() => {
// Check if email exists, if not contiune to registration
Expand All @@ -39,7 +34,7 @@ export default function Home() {
<View flex={1}>
<LogoBackground />

{assets ? <Logo source={assets[0]} /> : null}
{assets ? <Logo source={{ uri: assets[0].uri }} /> : null}

<View
flex={1}
Expand Down
4 changes: 2 additions & 2 deletions app/(app)/tag/[tag].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from '@/lib/components/Button';
import { PopOver } from '@/lib/components/Popover';
import { Button } from '@lib/components/Button';
import { PopOver } from '@lib/components/Popover';
import { Send, StickyNote } from '@tamagui/lucide-icons';
import { LinearGradient } from 'expo-linear-gradient';
import { useNavigation } from 'expo-router';
Expand Down
9 changes: 1 addition & 8 deletions app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { AuthState, useAuthStore } from '@/lib/stores/auth.store';
import {
Home,
MessagesSquare,
QrCode,
UserCircle2
} from '@tamagui/lucide-icons';
import { Redirect, Tabs } from 'expo-router';
import { Tabs } from 'expo-router';

export default function TabsLayout() {
const authState = useAuthStore((state) => state.authState);

if (authState === AuthState.None) {
return <Redirect href="/sign-in" />;
}

return (
<Tabs>
<Tabs.Screen
Expand Down
46 changes: 26 additions & 20 deletions app/(tabs)/home.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
import {
FetchNotesOutput,
FetchNotesQuery
} from '@/lib/gql/queries/notes.query';
import { useQuery } from '@apollo/client';
import { Spinner, Text } from 'tamagui';
import { Collections } from '@lib/firebase/models';
import { INote } from '@lib/firebase/models/note.model';
import useCollection from '@lib/hooks/useCollection';
import { useEffect, useState } from 'react';
import { Text } from 'tamagui';

export default function Home() {
const gqlQuery = useQuery<FetchNotesOutput>(FetchNotesQuery);
const { collection } = useCollection<INote>(Collections.Notes);
const [data, setData] = useState<INote[]>([]);

if (gqlQuery.loading) {
return <Spinner size="large" />;
}
useEffect(() => {
async function getMarker() {
const snapshot = await collection.get();

const s = snapshot.docs.map((doc) => doc.data());

setData(s);
}

getMarker();
}, []);

if (gqlQuery.data?.fetchNotes.length < 1) {
if (data.length < 1) {
return <Text>No new note</Text>;
}
// TODO: REMOVE
// return <Redirect href="/tag/232" />;

// return (
// <>
// {gqlQuery.data.fetchNotes.map((note) => (
// <Text key={note.id}>{note.content}</Text>
// ))}
// </>
// );
return (
<>
{data.map((note) => (
<Text key={note.title}>{note.content}</Text>
))}
</>
);
}
16 changes: 8 additions & 8 deletions app/(tabs)/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { Button } from '@/lib/components/Button';
import { Text } from '@/lib/components/Text';
import { useSession } from '@/lib/context/auth.context';
import { Button } from '@lib/components/Button';
import { Text } from '@lib/components/Text';
import useSession from '@lib/hooks/useSession';
import { ChevronRight } from '@tamagui/lucide-icons';
import { useNavigation } from 'expo-router';
import { useLayoutEffect, useMemo } from 'react';
import { SectionList } from 'react-native';
import { Image, ListItem, YStack } from 'tamagui';

export default function ProfileView() {
const { user } = useSession();
const { currentUser } = useSession();
const navigation = useNavigation();
const userName = useMemo(() => {
if (user.name && user.last_name) {
return `${user.name} ${user.last_name}`;
if (currentUser?.displayName) {
return currentUser.displayName;
}

return 'Namn ej angivet';
}, [user]);
}, [currentUser]);

useLayoutEffect(() => {
navigation.setOptions({
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function ProfileView() {
color="$gray10Light"
fontSize={13}
>
{user.email}
{currentUser?.email}
</Text>

<Button
Expand Down
Loading

0 comments on commit b43e14a

Please sign in to comment.