diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-01-22 19:05:36 -0500 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-01-22 19:05:36 -0500 |
| commit | e5915b02008dfcebe08de063f0440974c8415d4b (patch) | |
| tree | 308517c416605f13163bf6847e5c322ee23ab2e8 /src/screens | |
| parent | cf420db54deb32be1e6bc4092eef105cc23d93e4 (diff) | |
| parent | 9921e80e60cb24d0fc7b99123a8b146c6e7d14ff (diff) | |
Merge branch 'master' into tma552-adjust-styles-and-sizes
# Conflicts:
# src/components/profile/Content.tsx
# src/screens/profile/MomentCommentsScreen.tsx
Diffstat (limited to 'src/screens')
| -rw-r--r-- | src/screens/profile/EditProfile.tsx | 46 | ||||
| -rw-r--r-- | src/screens/profile/MomentCommentsScreen.tsx | 36 | ||||
| -rw-r--r-- | src/screens/search/SearchScreen.tsx | 4 |
3 files changed, 64 insertions, 22 deletions
diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index c5ae8c6f..7d3ca581 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -29,9 +29,10 @@ import { websiteRegex, bioRegex, genderRegex, + CLASS_YEAR_LIST, } from '../../constants'; import AsyncStorage from '@react-native-community/async-storage'; -import {ProfileStackParams} from '../../routes'; +import {MainStackParams} from '../../routes'; import Animated from 'react-native-reanimated'; import {HeaderHeight, SCREEN_HEIGHT} from '../../utils'; import {RootState} from '../../store/rootReducer'; @@ -47,12 +48,12 @@ import { import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; type EditProfileNavigationProp = StackNavigationProp< - ProfileStackParams, + MainStackParams, 'EditProfile' >; interface EditProfileProps { - route: RouteProp<ProfileStackParams, 'EditProfile'>; + route: RouteProp<MainStackParams, 'EditProfile'>; navigation: EditProfileNavigationProp; } @@ -65,7 +66,7 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { const y: Animated.Value<number> = Animated.useValue(0); const {userId, username} = route.params; const { - profile: {website, biography, gender, snapchat, tiktok}, + profile: {website, biography, gender, snapchat, tiktok, university_class}, avatar, cover, } = useSelector((state: RootState) => state.user); @@ -99,6 +100,13 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { isValidSnapchat: true, isValidTiktok: true, attemptedSubmit: false, + classYear: university_class, + }); + + var classYearList: Array<any> = []; + + CLASS_YEAR_LIST.map((value) => { + classYearList.push({label: value, value: value}); }); /** @@ -254,6 +262,14 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { }); }; + const handleClassYearUpdate = (value: string) => { + const classYear = Number.parseInt(value); + setForm({ + ...form, + classYear, + }); + }; + const handleSubmit = useCallback(async () => { if (!form.largePic) { Alert.alert(ERROR_UPLOAD_LARGE_PROFILE_PIC); @@ -335,6 +351,15 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { invalidFields = true; } + if (form.classYear !== university_class) { + if (!form.classYear) { + invalidFields = true; + Alert.alert('Please select a valid class year'); + } else { + request.append('university_class', form.classYear); + } + } + if (invalidFields) { return; } @@ -487,6 +512,19 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { value={form.customGenderText} /> )} + + <TaggDropDown + value={form.classYear.toString()} + onValueChange={(value: string) => + handleClassYearUpdate(value) + } + items={classYearList} + placeholder={{ + label: 'Class Year', + value: null, + color: '#ddd', + }} + /> {snapchat !== '' && ( <View style={styles.row}> <SocialIcon social={'Snapchat'} style={styles.icon} /> diff --git a/src/screens/profile/MomentCommentsScreen.tsx b/src/screens/profile/MomentCommentsScreen.tsx index fa35a33b..2bceafc9 100644 --- a/src/screens/profile/MomentCommentsScreen.tsx +++ b/src/screens/profile/MomentCommentsScreen.tsx @@ -1,9 +1,12 @@ -import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp, useNavigation} from '@react-navigation/native'; -import * as React from 'react'; -import {useEffect} from 'react'; -import {StyleSheet, Text, TouchableOpacity, View} from 'react-native'; -import Animated from 'react-native-reanimated'; +import React, {useEffect, useRef} from 'react'; +import { + ScrollView, + StyleSheet, + Text, + TouchableOpacity, + View, +} from 'react-native'; import {SafeAreaView} from 'react-native-safe-area-context'; import {useDispatch} from 'react-redux'; import {getMomentComments} from '../..//services'; @@ -11,9 +14,8 @@ import BackIcon from '../../assets/icons/back-arrow.svg'; import {CommentTile, TabsGradient} from '../../components'; import {AddComment} from '../../components/'; import {ProfileStackParams} from '../../routes/main'; -import {logout} from '../../store/actions'; import {CommentType} from '../../types'; -import {SCREEN_WIDTH, SCREEN_HEIGHT} from '../../utils'; +import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; /** * Comments Screen for an image uploaded @@ -36,19 +38,20 @@ const MomentCommentsScreen: React.FC<MomentCommentsScreenProps> = ({route}) => { const [commentsList, setCommentsList] = React.useState([]); const [newCommentsAvailable, setNewCommentsAvailable] = React.useState(true); const dispatch = useDispatch(); + const ref = useRef<ScrollView>(null); useEffect(() => { const loadComments = async () => { - const token = await AsyncStorage.getItem('token'); - if (!token) { - dispatch(logout()); - return; - } - getMomentComments(moment_id, setCommentsList, token); + getMomentComments(moment_id, setCommentsList); setNewCommentsAvailable(false); }; if (newCommentsAvailable) { loadComments(); + setTimeout(() => { + ref.current?.scrollToEnd({ + animated: true, + }); + }, 500); } }, [dispatch, moment_id, newCommentsAvailable]); @@ -68,7 +71,8 @@ const MomentCommentsScreen: React.FC<MomentCommentsScreenProps> = ({route}) => { </Text> </View> <View style={styles.body}> - <Animated.ScrollView + <ScrollView + ref={ref} style={styles.scrollView} contentContainerStyle={styles.scrollViewContent}> {commentsList && @@ -79,7 +83,7 @@ const MomentCommentsScreen: React.FC<MomentCommentsScreenProps> = ({route}) => { screenType={screenType} /> ))} - </Animated.ScrollView> + </ScrollView> <AddComment setNewCommentsAvailable={setNewCommentsAvailable} moment_id={moment_id} @@ -117,7 +121,7 @@ const styles = StyleSheet.create({ }, body: { width: SCREEN_WIDTH, - height: (4.9 / 6) * SCREEN_HEIGHT, + height: SCREEN_HEIGHT * 0.8, paddingTop: '3%', }, scrollView: { diff --git a/src/screens/search/SearchScreen.tsx b/src/screens/search/SearchScreen.tsx index f1bdbea2..059bd968 100644 --- a/src/screens/search/SearchScreen.tsx +++ b/src/screens/search/SearchScreen.tsx @@ -21,7 +21,7 @@ import { SearchResultsBackground, TabsGradient, } from '../../components'; -import {SEARCH_ENDPOINT, TAGG_TEXT_LIGHT_BLUE} from '../../constants'; +import {SEARCH_ENDPOINT, TAGG_LIGHT_BLUE} from '../../constants'; import {loadRecentlySearched, resetScreenType} from '../../store/actions'; import {RootState} from '../../store/rootReducer'; import {ProfilePreviewType, ScreenType, UserType} from '../../types'; @@ -214,7 +214,7 @@ const styles = StyleSheet.create({ clear: { fontSize: 17, fontWeight: 'bold', - color: TAGG_TEXT_LIGHT_BLUE, + color: TAGG_LIGHT_BLUE, }, image: { width: SCREEN_WIDTH, |
