99999.114514.6 • Published 1 year ago

@0-a-e/react-native-media-viewing v99999.114514.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-media-viewing

react-native-image-viewingのフォークです.動画再生に対応.音声にも後で対応するかも. Expo非対応

React Native modal component for viewing image and Video as a sliding gallery.

npm version styled with prettier

  • 🔥Pinch zoom for both iOS and Android
  • 🔥Double tap to zoom for both iOS and Android
  • 🔥Supports swipe-to-close animation
  • 🔥Custom header and footer components
  • 🔥Uses VirtualizedList to optimize image loading and rendering

Installation

yarn add react-native-image-viewing

or

npm install --save react-native-image-viewing

Usage

import MediaView from "@0-a-e/react-native-media-viewing";

const medias = [
  {
    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);

<MediaView
  mediaSource={medias}
  mediaIndex={0}
  visible={visible}
  onRequestClose={() => setIsVisible(false)}
  unknownErrorMessage={"不明なエラー"}
  unsupportedFiletypeMessage={"対応していないファイル形式です"}
  errorMessage={"エラー"}
  noFileMessage={'表示可能なメディアがありません。'}
/>;

See Example

Props

Prop nameDescriptionTypeRequired
mediasArray of medias to displayImageSource[]true
keyExtractorUniqely identifying each image(imageSrc: ImageSource, index: number) => stringfalse
mediaIndexCurrent 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: ImageSource)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
unknownErrorMessageunknown Error Message.stringfalse
unsupportedFiletypeMessageUnsupported file Message.stringfalse
errorMessageerror Message.stringfalse
noFileMessageno file Message.stringfalse

Contributing

To start contributing clone this repo and then run inside react-native-media-viewing folder:

yarn

Then go inside example folder and run:

yarn & yarn start

This will start packager for expo so you can change /src/ImageViewing and see changes in expo example app.

License(ライセンス)

MIT