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-04-12 16:27:05 +00:00
|
|
|
import { TSupportedThemes, useTheme } from '../../../theme';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../../lib/constants';
|
2021-10-20 16:32:58 +00:00
|
|
|
import styles from '../../message/styles';
|
|
|
|
|
|
|
|
interface IImageProps {
|
|
|
|
value: ImageProps['value'];
|
|
|
|
}
|
|
|
|
|
|
|
|
type TMessageImage = {
|
|
|
|
img: string;
|
2022-04-12 16:27:05 +00:00
|
|
|
theme: TSupportedThemes;
|
2021-10-20 16:32:58 +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
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2022-03-25 17:20:09 +00:00
|
|
|
const Image = ({ value }: IImageProps) => {
|
2021-10-20 16:32:58 +00:00
|
|
|
const { theme } = useTheme();
|
|
|
|
const { src } = value;
|
|
|
|
|
2022-03-25 17:20:09 +00:00
|
|
|
return <MessageImage img={src.value} theme={theme} />;
|
2021-10-20 16:32:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Image;
|