@@ -28,35 +28,28 @@ Usage:
2828import ImageViewer from ' @luu-truong/react-native-image-viewer' ;
2929
3030function Example () {
31- const imageViewerRef = React .createRef ( );
31+ const [ visible , setVisible ] = React .useState ( false );
3232
33- function showImagesViewer () {
34- imageViewerRef .ref .show ([
35- {
36- source: {
37- uri: ' https://...' ,
38- headers: {
39- ' X-Custom-Header' : ' foo' ,
40- },
41- width: 1200 ,
42- height: 600
33+ const images = [
34+ {
35+ source: {
36+ uri: ' https://...' ,
37+ headers: {
38+ ' X-Custom-Header' : ' foo' ,
4339 },
44- title: ' blah blah'
40+ width: 1200 ,
41+ height: 600
4542 },
46- {
47- source: require (' image.png' ),
48- }
49- ]);
50- }
43+ title: ' blah blah'
44+ },
45+ {
46+ source: require (' image.png' ),
47+ }
48+ ];
5149
5250 return (
5351 <>
54- < TouchableOpacity onPress= {() => showImagesViewer ()}>
55- < View>
56- < Text > Show Images< / Text >
57- < / View>
58- < / TouchableOpacity>
59- < ImageViewer ref= {imageViewerRef} imageProps= {{
52+ < ImageViewer images= {images} visible= {visible} onClose= {() => setVisible (false )} imageProps= {{
6053 initialWidth: 200 ,
6154 initialHeight: 200 ,
6255 renderFooter : (title ?: string ) => (< Text > {title}< / Text > )
@@ -75,6 +68,11 @@ Image Viewer Component Props:
7568| --- | --- | --- | --- |
7669| debug | boolean | no | Print debug message. Default: false |
7770| imageProps | object | no | Props passed to Image component. See Image Component Props |
71+ | visible | boolean | yes | |
72+ | images | Array | yes | |
73+ | initialIndex | number | no | Show image index at initialize |
74+ | onClose | () => void | yes | Callback when close image viewer |
75+ | animationType | `slide | fade | none` | no | |
7876
7977Image Component Props:
8078
0 commit comments