-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewFile.jsx
More file actions
85 lines (78 loc) · 2.12 KB
/
ViewFile.jsx
File metadata and controls
85 lines (78 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import React, {useState} from 'react';
import {Modal, Portal, Text, TouchableRipple, Icon} from 'react-native-paper';
import {moderateScale} from 'react-native-size-matters';
import Pdf from 'react-native-pdf';
import {Image, StyleSheet, View} from 'react-native';
import {colors} from '../../Utils/colors';
import {fonts} from '../../Utils/fonts';
const ViewFile = ({props, visible, onClose, isImage, isVideo}) => {
const filePath = props.file.url || props.image;
var name = '';
if (filePath !== undefined) {
name = filePath.split('/').pop();
}
return (
<Portal>
<Modal visible={visible} contentContainerStyle={styles.containerStyle}>
<Text style={styles.pdfName}>{name}</Text>
<View style={styles.container}>
{!isImage && !isVideo && (
<Pdf
source={{uri: filePath}}
style={{
height: '100%',
width: '100%',
}}
/>
)}
{isImage && (
<Image
style={styles.viewImage}
source={{uri: filePath}}
width="100%"
height="90%"
/>
)}
<TouchableRipple onPress={onClose} style={styles.buttonCancel}>
<Icon source="close" color={colors.BLACK} size={20} />
</TouchableRipple>
</View>
</Modal>
</Portal>
);
};
export default ViewFile;
const styles = StyleSheet.create({
buttonCancel: {
width: moderateScale(30),
height: moderateScale(35),
borderRadius: 50,
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
borderColor: 'black',
left: '88%',
top: moderateScale(-30),
},
textBtn: {
fontSize: 18,
fontWeight: 'bold',
color: 'black',
},
containerStyle: {
backgroundColor: 'white',
height: '100%',
},
pdfName: {
// position: 'absolute',
paddingTop: moderateScale(50),
paddingLeft: moderateScale(20),
fontFamily: fonts.MEDIUM,
fontSize: moderateScale(12),
maxWidth: moderateScale(320),
},
viewImage: {
alignSelf: 'center',
resizeMode: 'contain',
},
});