diff options
Diffstat (limited to 'src/screens')
| -rw-r--r-- | src/screens/index.ts | 3 | ||||
| -rw-r--r-- | src/screens/main/Profile.tsx | 24 | ||||
| -rw-r--r-- | src/screens/main/index.ts | 1 | ||||
| -rw-r--r-- | src/screens/onboarding/Login.tsx | 21 | ||||
| -rw-r--r-- | src/screens/onboarding/ProfileOnboarding.tsx | 11 | ||||
| -rw-r--r-- | src/screens/onboarding/RegistrationOne.tsx | 6 | ||||
| -rw-r--r-- | src/screens/onboarding/RegistrationTwo.tsx | 6 | ||||
| -rw-r--r-- | src/screens/onboarding/Verification.tsx | 6 | ||||
| -rw-r--r-- | src/screens/onboarding/index.ts | 2 | ||||
| -rw-r--r-- | src/screens/profile/ProfileScreen.tsx | 26 | ||||
| -rw-r--r-- | src/screens/profile/index.ts | 1 |
11 files changed, 58 insertions, 49 deletions
diff --git a/src/screens/index.ts b/src/screens/index.ts new file mode 100644 index 00000000..5dd3007a --- /dev/null +++ b/src/screens/index.ts @@ -0,0 +1,3 @@ +export * from './main'; +export * from './onboarding'; +export * from './profile'; diff --git a/src/screens/main/Profile.tsx b/src/screens/main/Profile.tsx deleted file mode 100644 index 3a6536e4..00000000 --- a/src/screens/main/Profile.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react'; -import {Text} from 'react-native-animatable'; -import {StyleSheet} from 'react-native'; -import {GradientBackground} from '../../components'; - -/** - * Profile Screen for a user's logged in profile - * including posts, messaging, and settings - */ - -const Profile: React.FC = () => { - return ( - <GradientBackground> - <Text style={styles.text}> Profile Screen 🤩 </Text> - </GradientBackground> - ); -}; -const styles = StyleSheet.create({ - text: { - justifyContent: 'center', - backgroundColor: 'transparent', - }, -}); -export default Profile; diff --git a/src/screens/main/index.ts b/src/screens/main/index.ts index 9bd00c57..fb1bf49b 100644 --- a/src/screens/main/index.ts +++ b/src/screens/main/index.ts @@ -1,5 +1,4 @@ export {default as Home} from './Home'; export {default as Notifications} from './Notifications'; -export {default as Profile} from './Profile'; export {default as Search} from './Search'; export {default as Upload} from './Upload'; diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx index 7b76e97c..5c569ec3 100644 --- a/src/screens/onboarding/Login.tsx +++ b/src/screens/onboarding/Login.tsx @@ -13,13 +13,14 @@ import { Platform, } from 'react-native'; -import {RootStackParamList, AuthContext} from '../../routes'; +import {OnboardingStackParams} from '../../routes/onboarding'; +import {AuthContext} from '../../routes/authentication'; import {Background, TaggInput, SubmitButton} from '../../components'; import {usernameRegex, LOGIN_ENDPOINT} from '../../constants'; -type VerificationScreenRouteProp = RouteProp<RootStackParamList, 'Login'>; +type VerificationScreenRouteProp = RouteProp<OnboardingStackParams, 'Login'>; type VerificationScreenNavigationProp = StackNavigationProp< - RootStackParamList, + OnboardingStackParams, 'Login' >; interface LoginProps { @@ -98,9 +99,9 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => { }; /** - * Handler for the Let's Start button or the Go button on the keyboard. - Makes a POST request to the Django login API and presents Alerts based on the status codes that the backend returns. - */ + * Handler for the Let's Start button or the Go button on the keyboard. + Makes a POST request to the Django login API and presents Alerts based on the status codes that the backend returns. + */ const handleLogin = async () => { if (!form.attemptedSubmit) { setForm({ @@ -110,17 +111,19 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => { } try { if (form.isValidUser && form.isValidPassword) { + const {username, password} = form; let response = await fetch(LOGIN_ENDPOINT, { method: 'POST', body: JSON.stringify({ - username: form.username, - password: form.password, + username, + password, }), }); let statusCode = response.status; + let data = await response.json(); if (statusCode === 200) { - login(); + login(data.UserID, username); } else if (statusCode === 401) { Alert.alert( 'Login failed 😔', diff --git a/src/screens/onboarding/ProfileOnboarding.tsx b/src/screens/onboarding/ProfileOnboarding.tsx index 6ce1ff80..9405ca52 100644 --- a/src/screens/onboarding/ProfileOnboarding.tsx +++ b/src/screens/onboarding/ProfileOnboarding.tsx @@ -10,17 +10,18 @@ import { Alert, View, } from 'react-native'; -import {RootStackParamList, AuthContext} from '../../routes'; +import {OnboardingStackParams} from '../../routes/onboarding'; +import {AuthContext} from '../../routes/authentication'; import {Background} from '../../components'; import ImagePicker from 'react-native-image-crop-picker'; import {REGISTER_ENDPOINT} from '../../constants'; type ProfileOnboardingScreenRouteProp = RouteProp< - RootStackParamList, + OnboardingStackParams, 'ProfileOnboarding' >; type ProfileOnboardingScreenNavigationProp = StackNavigationProp< - RootStackParamList, + OnboardingStackParams, 'ProfileOnboarding' >; interface ProfileOnboardingProps { @@ -150,10 +151,10 @@ const ProfileOnboarding: React.FC<ProfileOnboardingProps> = ({route}) => { }, body: form, }); - let data = await response.json(); let statusCode = response.status; + let data = await response.json(); if (statusCode === 200) { - login(); + login(userId, username); } else if (statusCode === 400) { Alert.alert('Profile update failed. 😔', `${data}`); } else { diff --git a/src/screens/onboarding/RegistrationOne.tsx b/src/screens/onboarding/RegistrationOne.tsx index 3b9ddb3e..720fcaed 100644 --- a/src/screens/onboarding/RegistrationOne.tsx +++ b/src/screens/onboarding/RegistrationOne.tsx @@ -12,7 +12,7 @@ import { KeyboardAvoidingView, } from 'react-native'; -import {RootStackParamList} from '../../routes'; +import {OnboardingStackParams} from '../../routes'; import { ArrowButton, RegistrationWizard, @@ -22,11 +22,11 @@ import { import {nameRegex, emailRegex} from '../../constants'; type RegistrationScreenOneRouteProp = RouteProp< - RootStackParamList, + OnboardingStackParams, 'RegistrationOne' >; type RegistrationScreenOneNavigationProp = StackNavigationProp< - RootStackParamList, + OnboardingStackParams, 'RegistrationOne' >; interface RegistrationOneProps { diff --git a/src/screens/onboarding/RegistrationTwo.tsx b/src/screens/onboarding/RegistrationTwo.tsx index 09e217f6..b67c2403 100644 --- a/src/screens/onboarding/RegistrationTwo.tsx +++ b/src/screens/onboarding/RegistrationTwo.tsx @@ -14,7 +14,7 @@ import { } from 'react-native'; import {usePromiseTracker, trackPromise} from 'react-promise-tracker'; -import {RootStackParamList} from '../../routes'; +import {OnboardingStackParams} from '../../routes'; import { ArrowButton, RegistrationWizard, @@ -30,11 +30,11 @@ import { } from '../../constants'; type RegistrationScreenTwoRouteProp = RouteProp< - RootStackParamList, + OnboardingStackParams, 'RegistrationTwo' >; type RegistrationScreenTwoNavigationProp = StackNavigationProp< - RootStackParamList, + OnboardingStackParams, 'RegistrationTwo' >; interface RegistrationTwoProps { diff --git a/src/screens/onboarding/Verification.tsx b/src/screens/onboarding/Verification.tsx index 197bc0ca..0676bb3a 100644 --- a/src/screens/onboarding/Verification.tsx +++ b/src/screens/onboarding/Verification.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import {RootStackParamList} from '../../routes'; +import {OnboardingStackParams} from '../../routes'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import {Background, RegistrationWizard, SubmitButton} from '../../components'; @@ -23,11 +23,11 @@ import { import {usePromiseTracker, trackPromise} from 'react-promise-tracker'; type VerificationScreenRouteProp = RouteProp< - RootStackParamList, + OnboardingStackParams, 'Verification' >; type VerificationScreenNavigationProp = StackNavigationProp< - RootStackParamList, + OnboardingStackParams, 'Verification' >; interface VerificationProps { diff --git a/src/screens/onboarding/index.ts b/src/screens/onboarding/index.ts index 9b2f4cb0..7a9816e7 100644 --- a/src/screens/onboarding/index.ts +++ b/src/screens/onboarding/index.ts @@ -1,5 +1,5 @@ export {default as Login} from './Login'; +export {default as ProfileOnboarding} from './ProfileOnboarding'; export {default as RegistrationOne} from './RegistrationOne'; export {default as RegistrationTwo} from './RegistrationTwo'; export {default as Verification} from './Verification'; -export {default as ProfileOnboarding} from './ProfileOnboarding'; diff --git a/src/screens/profile/ProfileScreen.tsx b/src/screens/profile/ProfileScreen.tsx new file mode 100644 index 00000000..3d1ef2a8 --- /dev/null +++ b/src/screens/profile/ProfileScreen.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import {Cover, Content} from '../../components'; +import Animated from 'react-native-reanimated'; +import {AuthContext} from '../../routes/authentication'; +import {StatusBar} from 'react-native'; + +// destructure Value object from Animated +const {Value} = Animated; + +/** + * Profile Screen for a user's logged in profile + * including posts, messaging, and settings + */ +const ProfileScreen: React.FC = () => { + const {user} = React.useContext(AuthContext); + const y = new Value(0); + return ( + <> + <StatusBar /> + <Cover {...{y, user}} /> + <Content {...{y, user}} /> + </> + ); +}; + +export default ProfileScreen; diff --git a/src/screens/profile/index.ts b/src/screens/profile/index.ts new file mode 100644 index 00000000..0ade259d --- /dev/null +++ b/src/screens/profile/index.ts @@ -0,0 +1 @@ +export {default as ProfileScreen} from './ProfileScreen'; |
