verdnatura-chat/app/containers/Avatar/AvatarWithEdit.tsx

66 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-01-06 20:51:16 +00:00
import React from 'react';
import Button from '../Button';
import AvatarContainer from './AvatarContainer';
import { IAvatar } from './interfaces';
import I18n from '../../i18n';
import { useTheme } from '../../theme';
2023-01-06 21:52:48 +00:00
import { BUTTON_HIT_SLOP } from '../message/utils';
2023-01-06 20:51:16 +00:00
import styles from './styles';
interface IAvatarContainer extends IAvatar {
2023-01-11 17:18:57 +00:00
handleEdit?: () => void;
2023-01-06 20:51:16 +00:00
}
const AvatarWithEdit = ({
style,
text = '',
avatar,
emoji,
size,
borderRadius,
type,
children,
onPress,
getCustomEmoji,
isStatic,
rid,
handleEdit
}: IAvatarContainer): React.ReactElement => {
const { colors } = useTheme();
return (
<>
<AvatarContainer
style={style}
text={text}
avatar={avatar}
emoji={emoji}
size={size}
borderRadius={borderRadius}
type={type}
children={children}
onPress={onPress}
getCustomEmoji={getCustomEmoji}
isStatic={isStatic}
rid={rid}
/>
2023-01-11 17:18:57 +00:00
{handleEdit ? (
<Button
title={I18n.t('Edit')}
type='secondary'
backgroundColor={colors.editAndUploadButtonAvatar}
onPress={handleEdit}
testID='avatar-edit-button'
style={styles.editAvatarButton}
styleText={[styles.textButton]}
color={colors.titleText}
hitSlop={BUTTON_HIT_SLOP}
/>
) : null}
2023-01-06 20:51:16 +00:00
</>
);
};
export default AvatarWithEdit;