2.0.4 • Published 3 years ago

@luu-truong/react-native-image-viewer v2.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Native Image Viewer

  • Double tap to zoom image
  • Pinch to zoom image
  • Swipe down to close
  • Caption and summaries

Installation

Yarn:

yarn add @luu-truong/react-native-image-viewer react-native-gesture-handler

NPM:

npm install @luu-truong/react-native-image-viewer react-native-gesture-handler

To complete installation you must following this guide to setup react-native-gesture-handler

Usage:

import ImageViewer from '@luu-truong/react-native-image-viewer';

function Example() {
  const [visible, setVisible] = React.useState(false);
  
  const images = [
    {
      source: {
        uri: 'https://...',
        headers: {
          'X-Custom-Header': 'foo',
        },
        width: 1200,
        height: 600
      },
      title: 'blah blah'
    },
    {
      source: require('image.png'),
    }
  ];
  
  return (
    <>
      <ImageViewer images={images} visible={visible} onClose={() => setVisible(false)} imageProps={{
        initialWidth: 200,
        initialHeight: 200,
        renderFooter: (title?: string) => (<Text>{title}</Text>)
      }} />
    </>
  );
}

Documentation

Image Viewer Component Props:

NameTypeRequiredDescription
debugbooleannoPrint debug message. Default: false
imagePropsobjectnoProps passed to Image component. See Image Component Props
visiblebooleanyes
imagesArrayyes
initialIndexnumbernoShow image index at initialize
onClose() => voidyesCallback when close image viewer
animationTypestringno

Image Component Props:

NameTypeRequiredDescription
initialWidthnumbernoDefault: 200
initialHeightnumbernoDefault: 200
renderFooter(title?: string) => JSX.ElementnullnoDefault: undefined
debugbooleannoDefault: false

Examples

If you want to play with the API but don't feel like to trying it on a real device. Clone the repo and go to demo folder and run:

yarn install

If you want to try IOS, run pod install in the ios folder.

Run yarn start to start metro server.

Run yarn ios to playing with iOS simulator Run yarn android to playing with Android simulator

React native support

versionreact-native version
1.x.x0.64.0+
2.0.3

3 years ago

2.0.2

3 years ago

2.0.4

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago