aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/SocialLinkModal.tsx
blob: 0bd5a0a53d94f51f3ff94dd82774583834ad9052 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import React from 'react';
import {Modal, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {TextInput} from 'react-native-gesture-handler';
import { ScreenType } from '../../types';
import {SocialIcon} from '.';
import CloseIcon from '../../assets/ionicons/close-outline.svg';
import {normalize, SCREEN_WIDTH} from '../../utils';
import TaggSquareButton from './TaggSquareButton';

interface SocialLinkModalProps {
  social: string;
  modalVisible: boolean;
  setModalVisible: (_: boolean) => void;
  completionCallback: (username: string) => void;
}

const SocialLinkModal: React.FC<SocialLinkModalProps> = ({
  social,
  modalVisible,
  setModalVisible,
  completionCallback,
}) => {
  const [username, setUsername] = React.useState('');

  const onClosePress = () => {
    setModalVisible(false);
  };

  const onSubmit = () => {
    if (username !== '') {
      setModalVisible(!modalVisible);
      setUsername('');
      completionCallback(username);
    }
  };

  return (
    <>
      <View style={styles.centeredView}>
        <Modal
          animationType="slide"
          transparent={true}
          visible={modalVisible}
          onRequestClose={() => {}}>
          <View style={styles.centeredView}>
            <View style={styles.modalView}>
              <TouchableOpacity
                style={styles.closeButton}
                onPress={onClosePress}>
                <CloseIcon height={'100%'} width={'100%'} color={'grey'} />
              </TouchableOpacity>
              <SocialIcon
                style={styles.icon}
                social={social}
                screenType={ScreenType.Profile}
              />
              <Text style={styles.titleLabel}>{social}</Text>
              <Text style={styles.descriptionLabel}>
                Insert your {social.toLowerCase()} username to link your{' '}
                {social.toLowerCase()} account to your profile!
              </Text>
              <TextInput
                autoCapitalize={'none'}
                autoCorrect={false}
                placeholder={'Username'}
                style={styles.textInput}
                onChangeText={setUsername}
                selectionColor={'grey'}
                value={username}
              />
              <TaggSquareButton
                title={'Submit'}
                onPress={onSubmit}
                mode={'gradient'}
                color={'white'}
              />
            </View>
          </View>
        </Modal>
      </View>
    </>
  );
};

const styles = StyleSheet.create({
  centeredView: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  modalView: {
    width: SCREEN_WIDTH * 0.8,
    backgroundColor: 'white',
    borderRadius: 5,
    padding: '10%',
    alignItems: 'center',
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 3.84,
    elevation: 5,
  },
  textInput: {
    marginTop: '8%',
    width: '85%',
    paddingBottom: '2%',
    borderBottomWidth: 0.4,
    borderBottomColor: '#C4C4C4',
    fontSize: normalize(20),
    textAlign: 'center',
    fontWeight: '500',
  },
  closeButton: {
    position: 'absolute',
    height: normalize(20),
    width: normalize(20),
    left: '5%',
    top: '5%',
  },
  icon: {
    top: -(normalize(70) / 3),
    height: normalize(70),
    width: normalize(70),
    borderRadius: 30,
    position: 'absolute',
  },
  titleLabel: {
    marginTop: '8%',
    fontSize: normalize(17),
    fontWeight: '600',
    lineHeight: 20,
  },
  descriptionLabel: {
    width: SCREEN_WIDTH * 0.7,
    marginTop: '3%',
    fontSize: normalize(11),
    fontWeight: '600',
    textAlign: 'center',
    lineHeight: 15,
    color: '#828282',
  },
});

export default SocialLinkModal;