@cicko/react-native-image-viewing

中文文档
0.2.12发布于 2025/04/04MITTypeScriptCommonJS零依赖近 30 天下载 3618

React Native modal component for viewing images as a sliding gallery

原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. Props
  4. Contributing
  5. License

react-native-image-viewing

React Native modal component for viewing images 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

Try with Expo: https://expo.io/@antonkalinin/react-native-image-viewing

Installation

yarn add react-native-image-viewing

or

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

Usage

import ImageView from "react-native-image-viewing";

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

<ImageView
  images={images}
  imageIndex={0}
  visible={visible}
  onRequestClose={() => setIsVisible(false)}
/>

See Example

Props

Prop nameDescriptionTypeRequired
imagesArray of images to displayImageSource[]true
keyExtractorUniqely identifying each image(imageSrc: ImageSource, 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: 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
  • type ImageSource = ImageURISource | ImageRequireSource

Contributing

To start contributing clone this repo and then run inside react-native-image-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

版本与发布记录

@cicko/react-native-image-viewing 共发布 11 个版本,首次发布于 2025/03/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.12latest2025/04/041.6 年前
0.2.112025/04/041.6 年前
0.2.102025/04/041.6 年前
0.2.92025/04/041.6 年前
0.2.82025/04/041.6 年前
0.2.72025/04/041.6 年前

关于 @cicko/react-native-image-viewing 的常见问题

@cicko/react-native-image-viewing 是什么?

React Native modal component for viewing images as a sliding gallery

如何安装 @cicko/react-native-image-viewing?

在项目目录运行 npm install @cicko/react-native-image-viewing,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@babel/runtime(7.7.4)、@types/react(^18.3.20)、react(>=18.3.1)、react-native(>=0.74.5)、typescript(^5.6.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cicko/react-native-image-viewing 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cicko/react-native-image-viewing 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cicko/react-native-image-viewing 可以商用吗?

@cicko/react-native-image-viewing 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cicko/react-native-image-viewing 的下载量有多少?

根据 npm 官方下载统计,@cicko/react-native-image-viewing 在 2026/10/10 – 2026/11/08 这 30 天内被下载 3,618 次,日均约 121 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cicko/react-native-image-viewing 还在维护吗?

最新版本 0.2.12 发布于 2025/04/04(1.6 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/03/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。