2021-10-20 16:32:58 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Image as ImageProps } from '@rocket.chat/message-parser';
|
|
|
|
import { createImageProgress } from 'react-native-image-progress';
|
|
|
|
import * as Progress from 'react-native-progress';
|
2022-05-31 16:08:18 +00:00
|
|
|
import FastImage from 'react-native-fast-image';
|
2021-10-20 16:32:58 +00:00
|
|
|
|
2022-07-04 18:10:14 +00:00
|
|
|
import { TSupportedThemes, useTheme } from '../../../theme';
|
|
|
|
import { themes } from '../../../lib/constants';
|
2021-10-20 16:32:58 +00:00
|
|
|
import styles from '../../message/styles';
|
|
|
|
|
2022-07-04 18:10:14 +00:00
|
|
|
interface IImageProps {
|
|
|
|
value: ImageProps['value'];
|
|
|
|
}
|
2021-10-20 16:32:58 +00:00
|
|
|
|
2022-07-04 18:10:14 +00:00
|
|
|
type TMessageImage = {
|
|
|
|
img: string;
|
|
|
|
theme: TSupportedThemes;
|
2022-06-27 21:27:22 +00:00
|
|
|
};
|
2021-10-20 16:32:58 +00:00
|
|
|
|
2022-07-04 18:10:14 +00:00
|
|
|
const ImageProgress = createImageProgress(FastImage);
|
|
|
|
|
|
|
|
const MessageImage = ({ img, theme }: TMessageImage) => (
|
|
|
|
<ImageProgress
|
|
|
|
style={[styles.inlineImage, { borderColor: themes[theme].borderColor }]}
|
|
|
|
source={{ uri: encodeURI(img) }}
|
|
|
|
resizeMode={FastImage.resizeMode.cover}
|
|
|
|
indicator={Progress.Pie}
|
|
|
|
indicatorProps={{
|
|
|
|
color: themes[theme].actionTintColor
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const Image = ({ value }: IImageProps) => {
|
|
|
|
const { theme } = useTheme();
|
2021-10-20 16:32:58 +00:00
|
|
|
const { src } = value;
|
|
|
|
|
2022-07-04 18:10:14 +00:00
|
|
|
return <MessageImage img={src.value} theme={theme} />;
|
2021-10-20 16:32:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Image;
|