aboutsummaryrefslogtreecommitdiff
path: root/src/components/onboarding/UniversitySelection.tsx
blob: 8ef013d357d4dce394f3c22bab55fceab563af8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import React from 'react';
import {Image, ImageSourcePropType, StyleSheet, Text, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {UniversityType} from '../../types';
import {normalize} from '../../utils';

interface UniversitySelectionProps {
  selected: UniversityType | undefined;
  setSelected: (selected: UniversityType) => void;
}

const UniversitySelection: React.FC<UniversitySelectionProps> = ({
  selected,
  setSelected,
}) => {
  const crestData = [
    {
      imagePath: require('../../assets/images/badges/brown_badge.png'),
      title: 'Brown',
      key: 'Brown University',
    },
    {
      imagePath: require('../../assets/images/badges/brown_badge.png'),
      title: 'Cornell',
      key: 'Cornell University',
    },
    {
      imagePath: require('../../assets/images/badges/brown_badge.png'),
      title: 'Harvard',
      key: 'Harvard University',
    },
  ];
  const renderButton = (
    imagePath: ImageSourcePropType,
    title: string,
    key: string,
  ) => (
    <TouchableOpacity
      style={
        selected === key ? styles.crestContainerSelected : styles.crestContainer
      }
      onPress={() => setSelected(key)}>
      <Image source={imagePath} style={styles.crest} />
      <Text style={styles.crestLabel}>{title}</Text>
    </TouchableOpacity>
  );
  return (
    <>
      <Text style={styles.title}>University Badge</Text>
      <View style={styles.container}>
        {crestData.map((data) =>
          renderButton(data.imagePath, data.title, data.key),
        )}
      </View>
    </>
  );
};

const styles = StyleSheet.create({
  title: {
    color: 'white',
    fontSize: normalize(15),
    lineHeight: normalize(18),
    fontWeight: '700',
    marginBottom: 10,
  },
  container: {
    flexDirection: 'row',
    justifyContent: 'space-around',
    marginBottom: 10,
  },
  crest: {
    height: normalize(25),
    aspectRatio: 31 / 38,
    marginBottom: 5,
  },
  crestContainer: {
    alignItems: 'center',
    padding: 10,
  },
  crestContainerSelected: {
    alignItems: 'center',
    borderWidth: 2,
    borderColor: 'white',
    borderRadius: 5,
    padding: 8,
    backgroundColor: '#fff2',
  },
  crestLabel: {
    color: 'white',
    fontSize: normalize(15),
    lineHeight: normalize(18),
    fontWeight: '500',
  },
});

export default UniversitySelection;