diff --git a/app/(tabs)/settings/profile.tsx b/app/(tabs)/settings/profile.tsx index dee08eb..ba7812f 100644 --- a/app/(tabs)/settings/profile.tsx +++ b/app/(tabs)/settings/profile.tsx @@ -2,8 +2,10 @@ import React, { useState, useEffect } from 'react'; import { StyleSheet, TouchableOpacity, Image, Alert, ActivityIndicator } from 'react-native'; import * as ImagePicker from 'expo-image-picker'; import { supabase } from '@/lib/supabase'; -import { ThemedView, ThemedText, ThemedTextInput } from '@/components/theme'; +import { ThemedView, ThemedText, ThemedTextButton, ThemedTextInput } from '@/components/theme'; import { IconSymbol } from '@/components/ui/IconSymbol'; +import Avatar from '@/components/auth/Profile_Avatar'; +import { Session } from '@supabase/supabase-js' export default function ProfileScreen() { const [loading, setLoading] = useState(false); @@ -72,16 +74,12 @@ export default function ProfileScreen() { return ( - - {avatar ? ( - - ) : ( - - - - )} - Change Photo - + + Full Name @@ -92,28 +90,18 @@ export default function ProfileScreen() { style={styles.input} /> - Email - - - {loading ? ( - - ) : ( - Save Changes - )} - + fontSize={18} + fontWeight='semibold' + width='90%' + style={styles.saveButton} + /> + ); } @@ -122,6 +110,7 @@ const styles = StyleSheet.create({ container: { flex: 1, padding: 16, + alignItems: 'center', }, avatarContainer: { alignItems: 'center', @@ -161,13 +150,8 @@ const styles = StyleSheet.create({ marginBottom: 20, }, saveButton: { - backgroundColor: '#007AFF', paddingVertical: 14, borderRadius: 8, alignItems: 'center', }, - saveButtonText: { - color: '#fff', - fontSize: 16, - }, }); diff --git a/assets/fonts/SpaceMono-Regular.ttf b/assets/fonts/SpaceMono-Regular.ttf old mode 100755 new mode 100644 diff --git a/components/Account.tsx b/components/Account.tsx deleted file mode 100644 index 1604c1b..0000000 --- a/components/Account.tsx +++ /dev/null @@ -1,120 +0,0 @@ -import { useState, useEffect } from 'react'; -import { supabase } from '../lib/supabase'; -import { StyleSheet, View, Alert } from 'react-native'; -import { Button, Input } from '@rneui/themed'; -import { Session } from '@supabase/supabase-js'; - -export default function Account({ session }: { session: Session }) { - const [loading, setLoading] = useState(true); - const [username, setUsername] = useState(''); - const [website, setWebsite] = useState(''); - const [avatarUrl, setAvatarUrl] = useState(''); - - useEffect(() => { - if (session) getProfile(); - }, [session]); - - async function getProfile() { - try { - setLoading(true); - if (!session?.user) throw new Error('No user on the session!'); - - const { data, error, status } = await supabase - .from('profiles') - .select(`username, website, avatar_url`) - .eq('id', session?.user.id) - .single(); - if (error && status !== 406) { - throw error; - } - - if (data) { - setUsername(data.username); - setWebsite(data.website); - setAvatarUrl(data.avatar_url); - } - } catch (error) { - if (error instanceof Error) { - Alert.alert(error.message); - } - } finally { - setLoading(false); - } - } - - async function updateProfile({ - username, - website, - avatar_url, - }: { - username: string; - website: string; - avatar_url: string; - }) { - try { - setLoading(true); - if (!session?.user) throw new Error('No user on the session!'); - - const updates = { - id: session?.user.id, - username, - website, - avatar_url, - updated_at: new Date(), - }; - - const { error } = await supabase.from('profiles').upsert(updates); - - if (error) { - throw error; - } - } catch (error) { - if (error instanceof Error) { - Alert.alert(error.message); - } - } finally { - setLoading(false); - } - } - - return ( - - - - - - setUsername(text)} /> - - - setWebsite(text)} /> - - - -