2022-01-22 12:57:05 +05:00
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
import { View } from 'react-native';
|
2021-04-24 12:46:38 +05:00
|
|
|
import ImageViewer from 'react-native-image-zoom-viewer';
|
2021-07-20 09:52:20 +05:00
|
|
|
import RNFetchBlob from 'rn-fetch-blob';
|
|
|
|
|
import Storage from '../../utils/storage';
|
2022-01-22 12:57:05 +05:00
|
|
|
import { ActionIcon } from '../ActionIcon';
|
2021-04-24 12:46:38 +05:00
|
|
|
import BaseDialog from '../Dialog/base-dialog';
|
2022-01-22 12:57:05 +05:00
|
|
|
const { eSubscribeEvent, eUnSubscribeEvent } = require('../../services/EventManager');
|
2021-04-24 12:46:38 +05:00
|
|
|
|
|
|
|
|
const ImagePreview = () => {
|
|
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
|
|
const [image, setImage] = useState('');
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
eSubscribeEvent('ImagePreview', open);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
eUnSubscribeEvent('ImagePreview', open);
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const open = image => {
|
|
|
|
|
setImage(image);
|
|
|
|
|
setVisible(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const close = () => {
|
|
|
|
|
setImage(null);
|
|
|
|
|
setVisible(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
visible && (
|
|
|
|
|
<BaseDialog animation="slide" visible={true} onRequestClose={close}>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
2021-07-20 09:52:20 +05:00
|
|
|
backgroundColor: 'black'
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-04-24 12:46:38 +05:00
|
|
|
<ImageViewer
|
2021-07-20 09:52:20 +05:00
|
|
|
enableImageZoom={true}
|
2021-04-24 12:46:38 +05:00
|
|
|
renderIndicator={() => <></>}
|
|
|
|
|
enableSwipeDown
|
|
|
|
|
useNativeDriver
|
|
|
|
|
onSwipeDown={close}
|
2021-11-13 10:21:06 +05:00
|
|
|
saveToLocalByLongPress={false}
|
2021-04-24 12:46:38 +05:00
|
|
|
renderHeader={() => (
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
width: '100%',
|
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
|
alignItems: 'center',
|
2021-07-20 09:52:20 +05:00
|
|
|
height: 80,
|
|
|
|
|
marginTop: 0,
|
2021-04-24 12:46:38 +05:00
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
zIndex: 999,
|
2021-07-20 09:52:20 +05:00
|
|
|
backgroundColor: 'rgba(0,0,0,0.3)',
|
|
|
|
|
paddingTop: 30
|
2022-01-22 12:57:05 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2021-04-24 12:46:38 +05:00
|
|
|
<ActionIcon
|
|
|
|
|
name="close"
|
|
|
|
|
color="white"
|
|
|
|
|
onPress={() => {
|
|
|
|
|
close();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
)}
|
|
|
|
|
imageUrls={[
|
|
|
|
|
{
|
2021-07-20 09:52:20 +05:00
|
|
|
url: image
|
|
|
|
|
}
|
2021-04-24 12:46:38 +05:00
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
</BaseDialog>
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ImagePreview;
|