0.1.3 • Published 2 years ago

react-native-media-viewing v0.1.3

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

react-native-media-viewing

Media viewing inherit from react-native-image-viewing library.

React Native modal component for viewing images and videos as a sliding gallery.

styled with prettier

Installation

yarn add react-native-media-viewing

or

npm install --save react-native-media-viewing

Usage

import MediaViewing from "react-native-media-viewing";

const media = [
  {
    uri: "https://images.unsplash.com/photo-1571501679680-de32f1e7aad4",
  },
  {
    uri: "https://images.unsplash.com/photo-1573273787173-0eb81a833b34",
  },
  {
    uri: "https://images.unsplash.com/photo-1569569970363-df7b6160d111",
  },
];

const [visible, setIsVisible] = useState(false);

<MediaViewing
  media={media}
  imageIndex={0}
  visible={visible}
  onRequestClose={() => setIsVisible(false)}
/>;

See Example

Props

Prop nameDescriptionTypeRequired
imagesArray of images to displayMediaSource[]true
keyExtractorUniqely identifying each image(mediaSrc: MediaSource, index: number) => stringfalse
imageIndexCurrent index of image to displaynumbertrue
visibleIs modal shown or notbooleantrue
onRequestCloseFunction called to close the modalfunctiontrue
onImageIndexChangeFunction called when image index has been changedfunctionfalse
onLongPressFunction called when image long pressedfunction (event: GestureResponderEvent, image: MediaSource)false
delayLongPressDelay in ms, before onLongPress is called: default 800numberfalse
animationTypeAnimation modal presented with: default fadenone, fade, slidefalse
presentationStyleModal presentation style: default: fullScreen Android: Use overFullScreen to hide StatusBarfullScreen, pageSheet, formSheet, overFullScreenfalse
backgroundColorBackground color of the modal in HEX (#000000EE)stringfalse
swipeToCloseEnabledClose modal with swipe up or down: default truebooleanfalse
doubleTapToZoomEnabledZoom image by double tap on it: default truebooleanfalse
HeaderComponentHeader component, gets current imageIndex as a propcomponent, functionfalse
FooterComponentFooter component, gets current imageIndex as a propcomponent, functionfalse
  • type MediaSource = ImageURISource | ImageRequireSource

Contributing

See the repository to learn how to contribute to the repository and the development workflow.

License

MIT