2020-03-30 19:20:50 +00:00
|
|
|
import React from 'react';
|
2023-03-07 12:28:51 +00:00
|
|
|
import { StyleSheet, View } from 'react-native';
|
2022-05-31 16:08:18 +00:00
|
|
|
import FastImage from 'react-native-fast-image';
|
2020-03-30 19:20:50 +00:00
|
|
|
|
2022-06-06 14:17:51 +00:00
|
|
|
import { isTablet } from '../../lib/methods/helpers';
|
2023-07-05 18:28:01 +00:00
|
|
|
import { useTheme } from '../../theme';
|
2020-03-30 19:20:50 +00:00
|
|
|
|
|
|
|
const SIZE = 96;
|
|
|
|
const MARGIN_TOP = isTablet ? 0 : 64;
|
2022-11-10 16:22:02 +00:00
|
|
|
const BORDER_RADIUS = 8;
|
2020-03-30 19:20:50 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
marginBottom: 16,
|
|
|
|
width: '100%',
|
|
|
|
height: SIZE + MARGIN_TOP,
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
alignItems: 'center'
|
|
|
|
},
|
|
|
|
image: {
|
|
|
|
width: SIZE,
|
|
|
|
height: SIZE,
|
|
|
|
borderRadius: BORDER_RADIUS
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-10-05 20:48:04 +00:00
|
|
|
interface IServerAvatar {
|
|
|
|
url: string;
|
|
|
|
image: string;
|
|
|
|
}
|
2023-03-07 12:28:51 +00:00
|
|
|
|
|
|
|
// TODO: missing skeleton
|
2023-07-05 18:28:01 +00:00
|
|
|
const ServerAvatar = React.memo(({ url, image }: IServerAvatar) => {
|
|
|
|
const { colors } = useTheme();
|
2020-03-30 19:20:50 +00:00
|
|
|
|
2023-07-05 18:28:01 +00:00
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
{image && <FastImage style={[styles.image, { borderColor: colors.borderColor }]} source={{ uri: `${url}/${image}` }} />}
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
2020-03-30 19:20:50 +00:00
|
|
|
|
|
|
|
export default ServerAvatar;
|