mattermost-mobile/app/screens/user_profile/title/avatar.tsx
Daniel Espino García 9d1030a445
Push react native to 0.73.6 (#7863)
* Bump react native to 0.73.6

* iOS changes

* Fix gallery

* Fix test

* Add missing patch

* Unify react native navigation patch

* Update the rest of libraries

* iOS updates

* Update mattermost libraries

* Fix tests and final bumps

* iOS podfile update

* Update android locks

* Revert webrtc update because it was messing with the tests

* Update podfile for webrtc
2024-04-22 12:44:39 +02:00

66 lines
1.9 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useMemo} from 'react';
import {StyleSheet, View} from 'react-native';
import FastImage from 'react-native-fast-image';
import Animated from 'react-native-reanimated';
import ProfilePicture from '@components/profile_picture';
import type UserModel from '@typings/database/models/servers/user';
const AnimatedFastImage = Animated.createAnimatedComponent(FastImage);
type Props = {
enablePostIconOverride: boolean;
forwardRef?: React.RefObject<any>;
imageSize?: number;
user: UserModel;
userIconOverride?: string;
}
const DEFAULT_IMAGE_SIZE = 96;
const getStyles = (size?: number) => {
return StyleSheet.create({
avatar: {
borderRadius: 48,
height: size || DEFAULT_IMAGE_SIZE,
width: size || DEFAULT_IMAGE_SIZE,
},
});
};
const UserProfileAvatar = ({enablePostIconOverride, forwardRef, imageSize, user, userIconOverride}: Props) => {
const styles = useMemo(() => getStyles(imageSize), [imageSize]);
if (enablePostIconOverride && userIconOverride) {
return (
<View style={styles.avatar}>
<AnimatedFastImage
// @ts-expect-error TS expects old type ref
ref={forwardRef}
style={styles.avatar}
source={{uri: userIconOverride}}
/>
</View>
);
}
return (
<ProfilePicture
author={user}
forwardRef={forwardRef}
showStatus={true}
size={imageSize || DEFAULT_IMAGE_SIZE}
statusSize={24}
testID={`user_profile_avatar.${user.id}.profile_picture`}
/>
);
};
export default UserProfileAvatar;