2020-03-30 19:20:50 +00:00
|
|
|
import React from 'react';
|
2023-02-24 13:54:34 +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-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../lib/constants';
|
2022-06-06 14:17:51 +00:00
|
|
|
import { isTablet } from '../../lib/methods/helpers';
|
2022-04-12 16:27:05 +00:00
|
|
|
import { TSupportedThemes } 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 {
|
2022-04-12 16:27:05 +00:00
|
|
|
theme: TSupportedThemes;
|
2021-10-05 20:48:04 +00:00
|
|
|
url: string;
|
|
|
|
image: string;
|
|
|
|
}
|
2023-02-24 13:54:34 +00:00
|
|
|
|
|
|
|
// TODO: missing skeleton
|
2021-10-05 20:48:04 +00:00
|
|
|
const ServerAvatar = React.memo(({ theme, url, image }: IServerAvatar) => (
|
2020-03-30 19:20:50 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
{image && (
|
2023-02-24 13:54:34 +00:00
|
|
|
<FastImage style={[styles.image, { borderColor: themes[theme].borderColor }]} source={{ uri: `${url}/${image}` }} />
|
2020-03-30 19:20:50 +00:00
|
|
|
)}
|
|
|
|
</View>
|
|
|
|
));
|
|
|
|
|
|
|
|
ServerAvatar.displayName = 'ServerAvatar';
|
|
|
|
|
|
|
|
export default ServerAvatar;
|