aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/profile/ProfileHeader.tsx15
-rw-r--r--src/components/profile/UniversityIcon.tsx20
-rw-r--r--src/components/search/SearchBar.tsx21
-rw-r--r--src/components/search/SearchResultCell.tsx17
-rw-r--r--src/components/suggestedPeople/BadgesDropdown.tsx8
-rw-r--r--src/components/suggestedPeople/UniversityIconClicked.tsx9
6 files changed, 47 insertions, 43 deletions
diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx
index e5bd9d93..2c623c2b 100644
--- a/src/components/profile/ProfileHeader.tsx
+++ b/src/components/profile/ProfileHeader.tsx
@@ -1,7 +1,6 @@
import React, {useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import {useSelector} from 'react-redux';
-import UniversityIcon from './UniversityIcon';
import {PROFILE_CUTOUT_TOP_Y} from '../../constants';
import {RootState} from '../../store/rootreducer';
import {ScreenType} from '../../types';
@@ -9,6 +8,7 @@ import {normalize} from '../../utils';
import Avatar from './Avatar';
import FriendsCount from './FriendsCount';
import ProfileMoreInfoDrawer from './ProfileMoreInfoDrawer';
+import UniversityIcon from './UniversityIcon';
type ProfileHeaderProps = {
userXId: string | undefined;
@@ -24,11 +24,11 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({
handleBlockUnblock,
}) => {
const {
- profile: {name = '', university_class = 2021} = {},
+ profile: {name = '', university_class = 2021, university},
user: {username: userXName = ''},
- } = userXId
- ? useSelector((state: RootState) => state.userX[screenType][userXId])
- : useSelector((state: RootState) => state.user);
+ } = useSelector((state: RootState) =>
+ userXId ? state.userX[screenType][userXId] : state.user,
+ );
const [drawerVisible, setDrawerVisible] = useState(false);
const [firstName, lastName] = [...name.split(' ')];
return (
@@ -59,10 +59,7 @@ const ProfileHeader: React.FC<ProfileHeaderProps> = ({
)}
<View style={styles.friendsAndUniversity}>
<FriendsCount screenType={screenType} userXId={userXId} />
- <UniversityIcon
- university="brown"
- university_class={university_class}
- />
+ <UniversityIcon {...{university, university_class}} />
</View>
</View>
</View>
diff --git a/src/components/profile/UniversityIcon.tsx b/src/components/profile/UniversityIcon.tsx
index 48cfe3dc..4cb1abe6 100644
--- a/src/components/profile/UniversityIcon.tsx
+++ b/src/components/profile/UniversityIcon.tsx
@@ -1,10 +1,11 @@
import React from 'react';
import {ImageStyle, StyleProp, StyleSheet, ViewProps} from 'react-native';
import {Image, Text, View} from 'react-native-animatable';
-import {getUniversityClass, normalize} from '../../utils';
+import {getUniversityBadge, getUniversityClass, normalize} from '../../utils';
+import {UniversityType} from '../../types';
export interface UniversityIconProps extends ViewProps {
- university: string;
+ university: UniversityType;
university_class?: number;
imageStyle?: StyleProp<ImageStyle>;
}
@@ -18,19 +19,12 @@ const UniversityIcon: React.FC<UniversityIconProps> = ({
university_class,
imageStyle,
}) => {
- var universityIcon;
- switch (university) {
- case 'brown':
- universityIcon = require('../../assets/universities/brown.png');
- break;
- default:
- universityIcon = require('../../assets/universities/brown.png');
- break;
- }
-
return (
<View style={[styles.container, style]}>
- <Image source={universityIcon} style={[styles.icon, imageStyle]} />
+ <Image
+ source={getUniversityBadge(university, 'Crest')}
+ style={[styles.icon, imageStyle]}
+ />
{university_class && (
<Text style={styles.univClass}>
{getUniversityClass(university_class)}
diff --git a/src/components/search/SearchBar.tsx b/src/components/search/SearchBar.tsx
index 62bda77e..4824b56f 100644
--- a/src/components/search/SearchBar.tsx
+++ b/src/components/search/SearchBar.tsx
@@ -1,19 +1,21 @@
-import React, {useState, useEffect} from 'react';
+import React, {useEffect, useState} from 'react';
import {
+ Keyboard,
+ NativeSyntheticEvent,
StyleSheet,
- TextInput,
- TouchableOpacity,
Text,
- View,
+ TextInput,
TextInputProps,
- Keyboard,
- NativeSyntheticEvent,
TextInputSubmitEditingEventData,
+ TouchableOpacity,
+ View,
} from 'react-native';
+import {normalize} from 'react-native-elements';
import Animated, {interpolate} from 'react-native-reanimated';
import Icon from 'react-native-vector-icons/Feather';
-import {normalize} from 'react-native-elements';
-import {SCREEN_HEIGHT, getSearchSuggestions} from '../../utils';
+import {useSelector} from 'react-redux';
+import {RootState} from '../../store/rootReducer';
+import {getSearchSuggestions, SCREEN_HEIGHT} from '../../utils';
const AnimatedIcon = Animated.createAnimatedComponent(Icon);
@@ -37,9 +39,10 @@ const SearchBar: React.FC<SearchBarProps> = ({
e.preventDefault();
Keyboard.dismiss();
};
+ const {university} = useSelector((state: RootState) => state.user.profile);
const DEFAULT_PLACEHOLDER: string = 'Search';
// the list of suggestions to cycle through. TODO: get this from the backend
- const SEARCH_SUGGESTIONS: string[] = getSearchSuggestions();
+ const SEARCH_SUGGESTIONS: string[] = getSearchSuggestions(university);
/*
* index & id of current placeholder, used in selecting next placeholder. -1
* indicates DEFAULT_PLACEHOLDER. TODO: make it appear more random by tracking
diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx
index 9a8216e5..5a6ea110 100644
--- a/src/components/search/SearchResultCell.tsx
+++ b/src/components/search/SearchResultCell.tsx
@@ -2,7 +2,7 @@ import {useNavigation} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
import {Alert, Image, StyleSheet, Text, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
-import {useDispatch, useStore} from 'react-redux';
+import {useDispatch, useSelector, useStore} from 'react-redux';
import {ERROR_UNABLE_TO_VIEW_PROFILE} from '../../constants/strings';
import {loadImageFromURL} from '../../services';
import {RootState} from '../../store/rootReducer';
@@ -10,11 +10,13 @@ import {
CategoryPreviewType,
ProfilePreviewType,
ScreenType,
+ UniversityType,
UserType,
} from '../../types';
import {
addCategoryToRecentlySearched,
addUserToRecentlySearched,
+ getUniversityBadge,
normalize,
SCREEN_WIDTH,
} from '../../utils';
@@ -43,6 +45,9 @@ const SearchResultsCell: React.FC<SearchResults> = ({
loggedInUser,
}) => {
const [avatar, setAvatar] = useState<string | undefined>(undefined);
+
+ const {university} = useSelector((state: RootState) => state.user.profile);
+
useEffect(() => {
(async () => {
if (thumbnail_url !== undefined) {
@@ -143,17 +148,17 @@ const SearchResultsCell: React.FC<SearchResults> = ({
return require('../../assets/images/search.png');
};
- const universityIcon = () => {
- return require('../../assets/images/bwbadges.png');
- };
-
const categoryCell = () => {
return (
<TouchableOpacity style={styles.cellContainer} onPress={onPressCategory}>
<View style={[styles.imageContainer, styles.categoryBackground]}>
<Image
resizeMode="contain"
- source={category === 'Brown' ? universityIcon() : searchIcon()}
+ source={
+ category in UniversityType
+ ? getUniversityBadge(university, 'Search')
+ : searchIcon()
+ }
style={styles.categoryImage}
/>
</View>
diff --git a/src/components/suggestedPeople/BadgesDropdown.tsx b/src/components/suggestedPeople/BadgesDropdown.tsx
index 99c03057..bc4e7a54 100644
--- a/src/components/suggestedPeople/BadgesDropdown.tsx
+++ b/src/components/suggestedPeople/BadgesDropdown.tsx
@@ -4,11 +4,12 @@ import {Image, StyleSheet} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import LinearGradient from 'react-native-linear-gradient';
import Animated, {Easing} from 'react-native-reanimated';
-import {UniversityBadge} from 'src/types';
+import {UniversityType, UniversityBadge} from '../../types';
import {UniversityIcon} from '..';
import {normalize, SCREEN_WIDTH} from '../../utils';
import UniversityIconClicked from './UniversityIconClicked';
interface BadgesDropdownProps {
+ university: UniversityType;
localBadges: {
badge: UniversityBadge;
img: string;
@@ -17,6 +18,7 @@ interface BadgesDropdownProps {
}
const BadgesDropdown: React.FC<BadgesDropdownProps> = ({
+ university,
localBadges,
badges,
}) => {
@@ -81,13 +83,13 @@ const BadgesDropdown: React.FC<BadgesDropdownProps> = ({
}}>
{displayBadges ? (
<UniversityIconClicked
- university="brown"
+ university={university}
style={styles.universityIconContainer}
imageStyle={{width: normalize(31), height: normalize(38)}}
/>
) : (
<UniversityIcon
- university="brown"
+ university={university}
style={styles.universityIconContainer}
imageStyle={{width: normalize(31), height: normalize(38)}}
/>
diff --git a/src/components/suggestedPeople/UniversityIconClicked.tsx b/src/components/suggestedPeople/UniversityIconClicked.tsx
index bde4e17f..41e27c8e 100644
--- a/src/components/suggestedPeople/UniversityIconClicked.tsx
+++ b/src/components/suggestedPeople/UniversityIconClicked.tsx
@@ -2,9 +2,9 @@ import React from 'react';
import {ImageStyle, StyleProp, StyleSheet, ViewProps} from 'react-native';
import {Image, Text, View} from 'react-native-animatable';
import {getUniversityClass, normalize} from '../../utils';
-
+import {UniversityType} from '../../types';
export interface UniversityIconClickedProps extends ViewProps {
- university: string;
+ university: UniversityType;
university_class?: number;
imageStyle?: StyleProp<ImageStyle>;
}
@@ -20,7 +20,10 @@ const UniversityIconClicked: React.FC<UniversityIconClickedProps> = ({
}) => {
var universityIcon;
switch (university) {
- case 'brown':
+ case UniversityType.Cornell:
+ universityIcon = require('../../assets/universities/cornell-clicked.png');
+ break;
+ case UniversityType.Brown:
universityIcon = require('../../assets/universities/brown-clicked.png');
break;
default: