Skip to content

Commit

Permalink
Profile tab and user type
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslindfors committed Jan 30, 2025
1 parent 5e13418 commit 35b31bc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
36 changes: 36 additions & 0 deletions app/(tabs)/profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { useEffect, useState } from "react";
import { Button, StyleSheet } from "react-native";
import { ThemedView } from "@/components/ThemedView";
import { ThemedText } from "@/components/ThemedText";
import { useSession } from "@/hooks/ctx";
import { GoogleUser } from "@/types/user";

export default function ProfileScreen() {
const { session, signOut } = useSession();
const [user, setUser] = useState<GoogleUser | null>(null);

useEffect(() => {
if (session) {
setUser(JSON.parse(session));
}
}, [session]);

return (
<ThemedView style={styles.container}>
<ThemedText type="title">{user?.name}</ThemedText>
<ThemedText type="subtitle">{user?.email}</ThemedText>
<Button
title="Sign Out"
onPress={signOut}
/>
</ThemedView>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
});
8 changes: 8 additions & 0 deletions types/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface GoogleUser {
"id": string,
"name": string,
"givenName": string,
"familyName": string,
"email": string,
"photo": string | null
}

0 comments on commit 35b31bc

Please sign in to comment.