avatar suggestion item

This commit is contained in:
Reinaldo Neto 2023-01-09 23:39:59 -03:00
parent 65dc56ad2d
commit 0ea494e3e7
3 changed files with 43 additions and 27 deletions

View File

@ -4,25 +4,10 @@ import { Text, View } from 'react-native';
import { IAvatar, IUser } from '../../definitions'; import { IAvatar, IUser } from '../../definitions';
import { Services } from '../../lib/services'; import { Services } from '../../lib/services';
import I18n from '../../i18n'; import I18n from '../../i18n';
import Avatar from '../../containers/Avatar';
import styles from './styles'; import styles from './styles';
import { useTheme } from '../../theme'; import { useTheme } from '../../theme';
import Touch from '../../containers/Touch'; import AvatarSuggestionItem from './AvatarSuggestionItem';
const Item = ({ item, onPress, text, testID }: { item?: IAvatar; testID?: string; onPress: Function; text?: string }) => {
const { colors } = useTheme();
return (
<Touch
key={item?.service}
testID={testID}
onPress={() => onPress(item)}
style={[styles.avatarButton, { backgroundColor: colors.borderColor }]}
>
<Avatar avatar={item?.url} text={text} size={64} />
</Touch>
);
};
const AvatarSuggestion = ({ const AvatarSuggestion = ({
onPress, onPress,
user, user,
@ -59,10 +44,10 @@ const AvatarSuggestion = ({
<Text style={[styles.itemLabel, { color: colors.titleText }]}>{I18n.t('Images_uploaded')}</Text> <Text style={[styles.itemLabel, { color: colors.titleText }]}>{I18n.t('Images_uploaded')}</Text>
<View style={styles.containerAvatarSuggestion}> <View style={styles.containerAvatarSuggestion}>
{user?.username && resetAvatar ? ( {user?.username && resetAvatar ? (
<Item text={`@${user.username}`} testID={`reset-avatar-suggestion`} onPress={resetAvatar} /> <AvatarSuggestionItem text={`@${user.username}`} testID={`reset-avatar-suggestion`} onPress={resetAvatar} />
) : null} ) : null}
{avatarSuggestions.slice(0, 7).map(item => ( {avatarSuggestions.slice(0, 7).map(item => (
<Item item={item} testID={`${item?.service}-avatar-suggestion`} onPress={onPress} /> <AvatarSuggestionItem item={item} testID={`${item?.service}-avatar-suggestion`} onPress={onPress} />
))} ))}
</View> </View>
</View> </View>

View File

@ -0,0 +1,40 @@
import React from 'react';
import { View, StyleSheet } from 'react-native';
import { IAvatar } from '../../definitions';
import Avatar from '../../containers/Avatar';
import { useTheme } from '../../theme';
const styles = StyleSheet.create({
container: {
width: 64,
height: 64,
alignItems: 'center',
justifyContent: 'center',
marginRight: 20,
marginBottom: 12,
borderRadius: 4
}
});
const AvatarSuggestionItem = ({
item,
onPress,
text,
testID
}: {
item?: IAvatar;
testID?: string;
onPress: Function;
text?: string;
}) => {
const { colors } = useTheme();
return (
<View key={item?.service} testID={testID} style={[styles.container, { backgroundColor: colors.borderColor }]}>
<Avatar avatar={item?.url} text={text} size={64} onPress={() => onPress(item)} />
</View>
);
};
export default AvatarSuggestionItem;

View File

@ -19,15 +19,6 @@ export default StyleSheet.create({
fontSize: 14, fontSize: 14,
...sharedStyles.textSemibold ...sharedStyles.textSemibold
}, },
avatarButton: {
width: 64,
height: 64,
alignItems: 'center',
justifyContent: 'center',
marginRight: 20,
marginBottom: 12,
borderRadius: 4
},
containerAvatarSuggestion: { containerAvatarSuggestion: {
flex: 1, flex: 1,
flexWrap: 'wrap', flexWrap: 'wrap',