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
|
import {useNavigation} from '@react-navigation/core';
import React from 'react';
import {
Alert,
Image,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import {ERROR_ATTEMPT_EDIT_SP} from '../../constants/strings';
import {normalize, SCREEN_WIDTH} from '../../utils/layouts';
type SettingsCellProps = {
title: string;
preimage: number;
postimage: number;
isPrivate?: boolean;
suggested_people_linked?: number;
};
const SettingsCell: React.FC<SettingsCellProps> = ({
title,
preimage,
postimage,
isPrivate,
suggested_people_linked,
}) => {
const navigation = useNavigation();
const goToUpdateSPProfile = () => {
if (suggested_people_linked === 0) {
Alert.alert(ERROR_ATTEMPT_EDIT_SP);
} else {
// Sending undefined for updatedSelectedBadges to mark that there was no update yet
navigateTo('UpdateSPPicture', {
editing: true,
});
}
};
const getActions = (type: string) => {
switch (type) {
case 'Account Type':
navigateTo('AccountTypeScreen', {});
break;
case 'Blocked Accounts':
navigateTo('Blocked Accounts', {});
break;
case 'Suggested People Profile':
goToUpdateSPProfile();
break;
case 'Privacy':
navigateTo('PrivacyScreen', {});
break;
case 'Terms of use':
//TODO:
break;
case 'Privacy Policy':
//TODO:
break;
default:
break;
}
};
const navigateTo = (screen: string, options: object) => {
navigation.navigate(screen, options);
};
return (
<TouchableOpacity
onPress={() => getActions(title)}
style={styles.itemStyles}>
<Image
resizeMode={'cover'}
style={styles.preImageStyles}
source={preimage}
/>
<View style={styles.titleContainerStyles}>
<Text style={styles.titleStyles}>{title}</Text>
</View>
<View style={[styles.itemStyles, styles.subItemStyles]}>
{title === 'Account Type' && (
<Text style={[styles.titleStyles, styles.subtitleStyles]}>
{isPrivate ? 'Private' : 'Public'}
</Text>
)}
<Image style={styles.postImageStyles} source={postimage} />
</View>
</TouchableOpacity>
);
};
const styles = StyleSheet.create({
container: {marginHorizontal: '8%'},
itemStyles: {
marginTop: 36,
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
},
subItemStyles: {position: 'absolute', right: 0},
preImageStyles: {width: SCREEN_WIDTH * 0.05, height: SCREEN_WIDTH * 0.05},
postImageStyles: {width: 15, height: 15},
titleContainerStyles: {marginLeft: '12%'},
titleStyles: {
fontSize: normalize(15),
fontWeight: '600',
lineHeight: normalize(17.9),
color: 'white',
},
subtitleStyles: {color: '#C4C4C4', marginRight: 13},
});
export default SettingsCell;
|