2021-11-17 19:59:53 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Image } from 'react-native';
|
2022-05-31 16:08:18 +00:00
|
|
|
import { FastImageProps } from 'react-native-fast-image';
|
2021-11-17 19:59:53 +00:00
|
|
|
|
2020-06-26 20:22:56 +00:00
|
|
|
import { types } from './types';
|
2023-06-07 20:14:31 +00:00
|
|
|
import { LOCAL_DOCUMENT_PATH } from '../../lib/methods/handleMediaDownload';
|
2020-06-26 20:22:56 +00:00
|
|
|
|
2023-06-07 20:14:31 +00:00
|
|
|
export function ImageComponent({
|
|
|
|
type,
|
|
|
|
uri
|
|
|
|
}: {
|
|
|
|
type?: string;
|
|
|
|
uri: string;
|
|
|
|
}): React.ComponentType<Partial<Image> | FastImageProps> {
|
2020-06-26 20:22:56 +00:00
|
|
|
let Component;
|
2023-06-07 20:14:31 +00:00
|
|
|
if (type === types.REACT_NATIVE_IMAGE || uri.startsWith(LOCAL_DOCUMENT_PATH)) {
|
2020-06-26 20:22:56 +00:00
|
|
|
const { Image } = require('react-native');
|
|
|
|
Component = Image;
|
|
|
|
} else {
|
2022-05-31 16:08:18 +00:00
|
|
|
const FastImage = require('react-native-fast-image');
|
2020-06-26 20:22:56 +00:00
|
|
|
Component = FastImage;
|
|
|
|
}
|
|
|
|
return Component;
|
2023-06-07 20:14:31 +00:00
|
|
|
}
|