Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[auth] Style onboarding screen #66

Merged
merged 18 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.formatDocument": "explicit",
"source.fixAll.eslint": "explicit"
}
}
2 changes: 1 addition & 1 deletion src/app/auth/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function LoginScreen() {

<View style={styles.redirectText}>
<Text style={globalStyles.body1}>Don&apos;t have an account?</Text>
<Link style={globalStyles.bodyBoldUnderline} href="/auth/signup">
<Link style={globalStyles.bodyBoldUnderline} href="/auth/onboarding">
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
Sign Up
</Link>
</View>
Expand Down
63 changes: 44 additions & 19 deletions src/app/auth/onboarding/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import DateTimePicker from '@react-native-community/datetimepicker';
import { Redirect, router } from 'expo-router';
import { Link, Redirect, router } from 'expo-router';
import { useState, useEffect } from 'react';
import { Alert, ScrollView, Platform, Text, View } from 'react-native';
import { Icon } from 'react-native-elements';

import styles from './styles';
import StyledButton from '../../../components/StyledButton/StyledButton';
import UserSelectorInput from '../../../components/UserSelectorInput/UserSelectorInput';
import UserStringInput from '../../../components/UserStringInput/UserStringInput';
import colors from '../../../styles/colors';
import globalStyles from '../../../styles/globalStyles';
import { useSession } from '../../../utils/AuthContext';
import supabase from '../../../utils/supabase';
Expand All @@ -19,7 +21,7 @@ function OnboardingScreen() {
const [username, setUsername] = useState('');
const [lastName, setLastName] = useState('');
const [pronouns, setPronouns] = useState('');
const [birthday, setBirthday] = useState(new Date());
const [birthday, setBirthday] = useState('');
const [gender, setGender] = useState('');
const [raceEthnicity, setRaceEthnicity] = useState('');
const [showDatePicker, setShowDatePicker] = useState(Platform.OS === 'ios');
Expand All @@ -46,7 +48,7 @@ function OnboardingScreen() {
setLastName(data.last_name || lastName);
setUsername(data.username || username);
setPronouns(data.pronouns || pronouns);
setBirthday(new Date(data.birthday) || birthday);
setBirthday('');
setGender(data.gender || gender);
setRaceEthnicity(data.race_ethnicity || raceEthnicity);
}
Expand Down Expand Up @@ -111,13 +113,13 @@ function OnboardingScreen() {
}
};

if (!session) {
return <Redirect href="/auth/login" />;
}
// if (!session) {
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
// return <Redirect href="/auth/login" />;
// }

return (
<ScrollView style={styles.container}>
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
<Text style={[globalStyles.h1, styles.h1]}>
<Text style={globalStyles.h1}>
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
Welcome, {user?.user_metadata.username}
</Text>
<Text style={[globalStyles.body1, styles.body1]}>
Expand All @@ -130,6 +132,20 @@ function OnboardingScreen() {
visible to other users on the app.
</Text>
</View>
<UserStringInput
label="Birthday"
placeholder="Select Date"
// onChange={setBirthday}
value={birthday}
placeholderTextColor={colors.darkGrey}
attributes={{ editable: false }}
>
<Icon
name="calendar-outline"
type="material-community"
color={colors.darkGrey}
/>
</UserStringInput>
<UserSelectorInput
options={['Female', 'Male', 'Prefer Not to Disclose', 'Other']}
label="Gender"
Expand All @@ -155,7 +171,8 @@ function OnboardingScreen() {
value={raceEthnicity}
setValue={setRaceEthnicity}
/>
{showDatePicker && (
{/* Birthday Button Implementation */}
{/* {showDatePicker && (
<DateTimePicker
testID="dateTimePicker"
value={birthday}
Expand All @@ -167,17 +184,25 @@ function OnboardingScreen() {
}
}}
/>
)}
<StyledButton
text={loading ? 'Loading ...' : 'Update profile'}
onPress={updateProfileAndGoHome}
disabled={loading}
/>
<StyledButton
text="Skip"
onPress={() => router.replace('/home')}
disabled={false}
/>
)} */}
<View style={styles.bottomContainer}>
<View style={styles.updateProfileButton}>
<StyledButton
text={loading ? 'Loading ...' : 'Update profile'}
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
onPress={updateProfileAndGoHome}
disabled={
loading ||
(gender === '' && pronouns === '' && raceEthnicity === '')
}
/>
</View>
<Link
style={[globalStyles.bodyBoldUnderline, styles.skipButton]}
href="/(tabs)/home"
>
Skip For Now
</Link>
</View>
</ScrollView>
);
}
Expand Down
18 changes: 13 additions & 5 deletions src/app/auth/onboarding/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,33 @@ import colors from '../../../styles/colors';

export default StyleSheet.create({
container: {
paddingVertical: 63,
paddingVertical: 66,
paddingLeft: 43,
paddingRight: 44,
},
subtext: {
color: colors.darkGrey,
marginLeft: 8,
},
h1: {
marginTop: 66,
},
body1: {
marginTop: 26,
},
info: {
flex: 1,
flexDirection: 'row',
marginTop: 12,
marginBottom: 16,
width: 250,
},
bottomContainer: {
marginTop: 112,
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
},
updateProfileButton: {
marginTop: 30,
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
marginBottom: 24,
},
skipButton: {
flex: 1,
alignSelf: 'center',
color: colors.darkGrey,
},
});
2 changes: 1 addition & 1 deletion src/components/UserStringInput/UserStringInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ReactNode } from 'react';
import { View, Text, TextInput } from 'react-native';

import styles from './styles';
import globalStyles from '../../styles/globalStyles';
import colors from '../../styles/colors';
import globalStyles from '../../styles/globalStyles';

type UserStringInputProps = {
placeholder: string;
Expand Down
1 change: 1 addition & 0 deletions src/components/UserStringInput/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default StyleSheet.create({
container: {
paddingRight: 10,
marginTop: 8,
marginBottom: 16,
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
Expand Down
Loading