@chem-po/react-native 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/form/input/file/index.js +3 -1
- package/lib/commonjs/components/form/input/file/index.js.map +1 -1
- package/lib/commonjs/components/image/ImageViewModal.js +285 -0
- package/lib/commonjs/components/image/ImageViewModal.js.map +1 -0
- package/lib/commonjs/components/image/index.js +17 -0
- package/lib/commonjs/components/image/index.js.map +1 -0
- package/lib/commonjs/components/index.js +8 -8
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/loading/LoadingImage.js +11 -6
- package/lib/commonjs/components/loading/LoadingImage.js.map +1 -1
- package/lib/module/components/form/input/file/index.js +3 -1
- package/lib/module/components/form/input/file/index.js.map +1 -1
- package/lib/module/components/image/ImageViewModal.js +277 -0
- package/lib/module/components/image/ImageViewModal.js.map +1 -0
- package/lib/module/components/image/index.js +2 -0
- package/lib/module/components/image/index.js.map +1 -0
- package/lib/module/components/index.js +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/loading/LoadingImage.js +11 -6
- package/lib/module/components/loading/LoadingImage.js.map +1 -1
- package/lib/typescript/components/form/input/file/index.d.ts +2 -1
- package/lib/typescript/components/form/input/file/index.d.ts.map +1 -1
- package/lib/typescript/components/image/ImageViewModal.d.ts +9 -0
- package/lib/typescript/components/image/ImageViewModal.d.ts.map +1 -0
- package/lib/typescript/components/image/index.d.ts +2 -0
- package/lib/typescript/components/image/index.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +1 -1
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/loading/LoadingImage.d.ts +2 -2
- package/lib/typescript/components/loading/LoadingImage.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/form/input/file/index.tsx +3 -0
- package/src/components/image/ImageViewModal.tsx +261 -0
- package/src/components/image/index.ts +1 -0
- package/src/components/index.ts +1 -1
- package/src/components/loading/LoadingImage.tsx +10 -6
- package/lib/commonjs/components/overlay/ImageViewOverlay.js +0 -127
- package/lib/commonjs/components/overlay/ImageViewOverlay.js.map +0 -1
- package/lib/commonjs/components/overlay/index.js +0 -17
- package/lib/commonjs/components/overlay/index.js.map +0 -1
- package/lib/module/components/overlay/ImageViewOverlay.js +0 -119
- package/lib/module/components/overlay/ImageViewOverlay.js.map +0 -1
- package/lib/module/components/overlay/index.js +0 -2
- package/lib/module/components/overlay/index.js.map +0 -1
- package/lib/typescript/components/overlay/ImageViewOverlay.d.ts +0 -6
- package/lib/typescript/components/overlay/ImageViewOverlay.d.ts.map +0 -1
- package/lib/typescript/components/overlay/index.d.ts +0 -2
- package/lib/typescript/components/overlay/index.d.ts.map +0 -1
- package/src/components/overlay/ImageViewOverlay.tsx +0 -104
- package/src/components/overlay/index.ts +0 -1
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { useScreen } from '@chem-po/react'
|
|
2
|
-
import { Ionicons } from '@expo/vector-icons'
|
|
3
|
-
import React, { useCallback, useMemo, useState } from 'react'
|
|
4
|
-
import { Image, Modal, StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
5
|
-
import { LoadingLogo } from '../loading/Loading'
|
|
6
|
-
|
|
7
|
-
export const ImageViewOverlay = ({ src, onClose }: { src: string; onClose: () => void }) => {
|
|
8
|
-
const [loading, setLoading] = useState(true)
|
|
9
|
-
const screenWidth = useScreen(s => s.width)
|
|
10
|
-
const screenHeight = useScreen(s => s.height)
|
|
11
|
-
const [imageSize, setImageSize] = useState({ width: screenWidth / 2, height: screenHeight / 2 })
|
|
12
|
-
|
|
13
|
-
const { height, width } = useMemo(() => {
|
|
14
|
-
if (loading) return imageSize
|
|
15
|
-
const ratio = imageSize.width / imageSize.height
|
|
16
|
-
let h = Math.min(imageSize.height, screenHeight * 0.9)
|
|
17
|
-
let w = h * ratio
|
|
18
|
-
if (w > screenWidth * 0.9) {
|
|
19
|
-
w = Math.min(imageSize.width, screenWidth * 0.9)
|
|
20
|
-
h = w / ratio
|
|
21
|
-
}
|
|
22
|
-
return { height: h, width: w }
|
|
23
|
-
}, [screenHeight, screenWidth, imageSize, loading])
|
|
24
|
-
|
|
25
|
-
const onLoadStart = useCallback(() => setLoading(true), [])
|
|
26
|
-
const onLoad = useCallback((e: any) => {
|
|
27
|
-
const { width: naturalWidth, height: naturalHeight } = e.nativeEvent.source
|
|
28
|
-
setImageSize({ width: naturalWidth, height: naturalHeight })
|
|
29
|
-
setLoading(false)
|
|
30
|
-
}, [])
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Modal visible={true} transparent animationType="fade" onRequestClose={onClose}>
|
|
34
|
-
<View style={styles.modalOverlay}>
|
|
35
|
-
<View style={styles.contentContainer}>
|
|
36
|
-
<View
|
|
37
|
-
style={[
|
|
38
|
-
styles.imageContainer,
|
|
39
|
-
{
|
|
40
|
-
width,
|
|
41
|
-
height,
|
|
42
|
-
opacity: loading ? 0 : 1,
|
|
43
|
-
},
|
|
44
|
-
]}>
|
|
45
|
-
<Image
|
|
46
|
-
source={{ uri: src }}
|
|
47
|
-
style={styles.image}
|
|
48
|
-
onLoadStart={onLoadStart}
|
|
49
|
-
onLoad={onLoad}
|
|
50
|
-
resizeMode="contain"
|
|
51
|
-
/>
|
|
52
|
-
</View>
|
|
53
|
-
|
|
54
|
-
<TouchableOpacity style={styles.closeButton} onPress={onClose}>
|
|
55
|
-
<Ionicons name="close" size={24} color="white" />
|
|
56
|
-
</TouchableOpacity>
|
|
57
|
-
|
|
58
|
-
{loading && (
|
|
59
|
-
<View style={styles.loadingContainer}>
|
|
60
|
-
<LoadingLogo isLoading={loading} size={70} />
|
|
61
|
-
</View>
|
|
62
|
-
)}
|
|
63
|
-
</View>
|
|
64
|
-
</View>
|
|
65
|
-
</Modal>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const styles = StyleSheet.create({
|
|
70
|
-
modalOverlay: {
|
|
71
|
-
flex: 1,
|
|
72
|
-
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
73
|
-
},
|
|
74
|
-
contentContainer: {
|
|
75
|
-
flex: 1,
|
|
76
|
-
justifyContent: 'center',
|
|
77
|
-
alignItems: 'center',
|
|
78
|
-
padding: 16,
|
|
79
|
-
},
|
|
80
|
-
imageContainer: {
|
|
81
|
-
overflow: 'hidden',
|
|
82
|
-
borderRadius: 4,
|
|
83
|
-
},
|
|
84
|
-
image: {
|
|
85
|
-
width: '100%',
|
|
86
|
-
height: '100%',
|
|
87
|
-
},
|
|
88
|
-
closeButton: {
|
|
89
|
-
position: 'absolute',
|
|
90
|
-
top: 16,
|
|
91
|
-
right: 16,
|
|
92
|
-
width: 40,
|
|
93
|
-
height: 40,
|
|
94
|
-
borderRadius: 20,
|
|
95
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
96
|
-
justifyContent: 'center',
|
|
97
|
-
alignItems: 'center',
|
|
98
|
-
},
|
|
99
|
-
loadingContainer: {
|
|
100
|
-
...StyleSheet.absoluteFillObject,
|
|
101
|
-
justifyContent: 'center',
|
|
102
|
-
alignItems: 'center',
|
|
103
|
-
},
|
|
104
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ImageViewOverlay'
|