From c343de3389fa6ad40b10fff2773ab67c0ba19d3a Mon Sep 17 00:00:00 2001 From: Aditya Pawar Date: Tue, 28 Nov 2023 17:05:13 -0800 Subject: [PATCH] Style static data --- src/app/settings.tsx | 182 ++++++++++++------ .../AccountDataDisplay/AccountDataDisplay.tsx | 22 +++ src/components/AccountDataDisplay/styles.tsx | 23 +++ .../UserStringInput/UserStringInput.tsx | 6 +- src/components/UserStringInput/styles.tsx | 1 + src/styles/globalStyles.ts | 3 +- 6 files changed, 177 insertions(+), 60 deletions(-) create mode 100644 src/components/AccountDataDisplay/AccountDataDisplay.tsx create mode 100644 src/components/AccountDataDisplay/styles.tsx diff --git a/src/app/settings.tsx b/src/app/settings.tsx index 133c866c..e089e83f 100644 --- a/src/app/settings.tsx +++ b/src/app/settings.tsx @@ -2,20 +2,24 @@ import DateTimePicker from '@react-native-community/datetimepicker'; import { Redirect, router } from 'expo-router'; import { useEffect, useState } from 'react'; import { Text, StyleSheet, View, Alert, Platform } from 'react-native'; -import { Button, Input } from 'react-native-elements'; +import { Button } from 'react-native-elements'; import { SafeAreaView } from 'react-native-safe-area-context'; import StyledButton from '../components/StyledButton/StyledButton'; import UserStringInput from '../components/UserStringInput/UserStringInput'; import globalStyles from '../styles/globalStyles'; +import color from '../styles/colors'; import { useSession } from '../utils/AuthContext'; import supabase from '../utils/supabase'; +import AccountDataDisplay from '../components/AccountDataDisplay/AccountDataDisplay'; function SettingsScreen() { const { session, signOut } = useSession(); const [loading, setLoading] = useState(true); const [firstName, setFirstName] = useState(''); + const [username, setUsername] = useState(''); const [lastName, setLastName] = useState(''); + const [pronouns, setPronouns] = useState(''); const [birthday, setBirthday] = useState(new Date()); const [gender, setGender] = useState(''); const [raceEthnicity, setRaceEthnicity] = useState(''); @@ -28,7 +32,9 @@ function SettingsScreen() { const { data, error, status } = await supabase .from('profiles') - .select(`first_name, last_name, birthday, gender, race_ethnicity`) + .select( + `first_name, last_name, username, birthday, gender, race_ethnicity`, + ) .eq('user_id', session?.user.id) .single(); @@ -39,7 +45,15 @@ function SettingsScreen() { if (data) { setFirstName(data.first_name || firstName); setLastName(data.last_name || lastName); - setBirthday(new Date(data.birthday) || birthday); + setUsername(data.username || username); + + if (data.birthday) { + setBirthday(new Date(data.birthday)); + setShowDatePicker(false); + } else { + setShowDatePicker(true); + } + setGender(data.gender || gender); setRaceEthnicity(data.race_ethnicity || raceEthnicity); } @@ -119,70 +133,124 @@ function SettingsScreen() { return ( - Settings - - - - - - - {Platform.OS !== 'ios' && ( -