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
|
import {useNavigation} from '@react-navigation/native';
import React from 'react';
import {Image, StyleSheet, TouchableOpacity} from 'react-native';
import {useSelector} from 'react-redux';
import MoreIcon from '../../assets/icons/more_horiz-24px.svg';
import {TAGG_DARK_BLUE, TAGG_LIGHT_BLUE} from '../../constants';
import {RootState} from '../../store/rootreducer';
import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils';
import {GenericMoreInfoDrawer} from '../common';
interface ProfileMoreInfoDrawerProps {
isOpen: boolean;
setIsOpen: (visible: boolean) => void;
userXId: string | undefined;
userXName: string;
isBlocked: boolean;
handleBlockUnblock: (callback?: () => void) => void;
}
const ProfileMoreInfoDrawer: React.FC<ProfileMoreInfoDrawerProps> = (props) => {
const navigation = useNavigation();
const {setIsOpen, userXId, isBlocked, handleBlockUnblock, userXName} = props;
const {
user: {userId, username},
} = useSelector((state: RootState) => state.user);
const isOwnProfile = !userXId || userXName === username;
const goToEditProfile = () => {
navigation.navigate('EditProfile', {
userId: userId,
username: username,
});
setIsOpen(false);
};
const goToSettingsPage = () => {
navigation.navigate('SettingsScreen');
setIsOpen(false);
};
const onBlockUnblock = () => {
handleBlockUnblock(() => setIsOpen(false));
};
return (
<>
<TouchableOpacity
style={styles.more}
onPress={() => {
setIsOpen(true);
}}>
<MoreIcon height={30} width={30} color={TAGG_DARK_BLUE} />
</TouchableOpacity>
{!isOwnProfile ? (
<GenericMoreInfoDrawer
{...props}
showIcons={false}
buttons={[
[
(isBlocked ? 'Unblock' : 'Block') + ` ${userXName}`,
onBlockUnblock,
undefined,
{color: 'red'},
],
]}
/>
) : (
<GenericMoreInfoDrawer
{...props}
showIcons={true}
buttons={[
[
'Settings',
goToSettingsPage,
<Image
source={require('../../assets/images/settings/settings.png')}
style={styles.image}
/>,
{color: 'black'},
],
[
'Edit Profile',
goToEditProfile,
<Image
source={require('../../assets/images/settings/edit-profile.png')}
style={styles.image}
/>,
{color: 'black'},
],
]}
/>
)}
</>
);
};
const styles = StyleSheet.create({
panel: {
height: SCREEN_HEIGHT,
backgroundColor: 'white',
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
},
panelButton: {
height: 80,
flexDirection: 'row',
alignItems: 'center',
},
panelButtonTitle: {
fontSize: 18,
fontWeight: 'bold',
color: 'black',
},
icon: {
height: 25,
width: 25,
color: 'black',
marginLeft: SCREEN_WIDTH * 0.3,
marginRight: 25,
},
panelButtonTitleCancel: {
fontSize: 18,
fontWeight: 'bold',
color: TAGG_LIGHT_BLUE,
},
divider: {height: 1, borderWidth: 1, borderColor: '#e7e7e7'},
more: {
position: 'absolute',
right: '5%',
zIndex: 1,
},
image: {
width: 25,
height: 25,
},
});
export default ProfileMoreInfoDrawer;
|