# @georstat/react-native-image-gallery 中文文档

规范地址：https://npmcn.com/package/%40georstat/react-native-image-gallery/

版本：1\.1\.0
npm 元数据更新时间：2022-04-05T13:57:04.266Z
中文译文更新时间：2026-11-16T04:55:57.739Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40georstat/react-native-image-gallery
原文对照：https://npmcn.com/package/%40georstat/react-native-image-gallery/?lang=original
项目主页：https://github.com/georstat/react-native-image-gallery
源码仓库：https://github.com/georstat/react-native-image-gallery

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：107 kB，45 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \*，react-native \*
- 首次发布：2021-11-21T18:16:42.417Z
- 最新版本发布：2022-04-03T14:59:17.072Z
- 近 30 天下载量：2498（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 0 个）

## 中文简介

用缩略图反射本地图像图片库

## 安装

```sh
npm install @georstat/react-native-image-gallery
```

也可以使用：`pnpm add @georstat/react-native-image-gallery`、`yarn add @georstat/react-native-image-gallery`、`bun add @georstat/react-native-image-gallery`

## README

# 用缩略图反射本地图像图片库

[![npm version](https://img.shields.io/npm/v/@georstat/react-native-image-gallery.svg?style=for-the-badge)](https://www.npmjs.com/package/@georstat/react-native-image-gallery) [![npm](https://img.shields.io/npm/dt/@georstat/react-native-image-gallery.svg?style=for-the-badge)](https://www.npmjs.com/package/@georstat/react-native-image-gallery) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://opensource.org/licenses/MIT) ![GitHub package.json version](https://img.shields.io/github/package-json/v/georstat/react-native-image-gallery?style=for-the-badge) ![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20iOS-blue.svg?style=for-the-badge)

## 特征

-   有缩略图的图像画廊
-   制造的 `PanResponder`,没有外部依赖
-   写入 `Typescript`

### 如果你是来找影像的 [@georstat/ react-native-image-cache (英语)](https://github.com/georstat/react-native-image-cache)

### 默认图片库预览 :

![@georstat:react-native-image-gallery default\_demo](https://user-images.githubusercontent.com/717975/142775028-32cdfdd0-feef-48e8-9dfc-b749d5e01972.gif)

### 自定义图片库预览 :

![@georstat:react-native-image-gallery default\_demo](https://user-images.githubusercontent.com/717975/142775046-475bfc3b-6326-4b3d-afa3-58189e003043.gif)

## 安装

#### 线条 :

```bash
yarn add @georstat/react-native-image-gallery
```

#### 无 :

```bash
npm i @georstat/react-native-image-gallery
```

## 使用量

#### 有拇指的简单图片库 :

```tsx
import { ImageGallery } from '@georstat/react-native-image-gallery';

const images = [
  {
    id: 1,
    url: 'https://...',
    // any other extra info you want
  },
  ...
]

const MyGallery = () => {
    const [isOpen, setIsOpen] = useState(false);
    const openGallery = () => setIsOpen(true);
    const closeGallery = () => setIsOpen(false);

    return (
        <View>
            <Button onPress={openGallery} title="Open Gallery" />
            <ImageGallery close={closeGallery} isOpen={isOpen} images={images} />
        </View>
    )
}
```

#### 自定义没有拇指的图片库 :

需要更多的信息检查 [实例](https://github.com/georstat/react-native-image-gallery/tree/main/example/src)

此示例使用 [地质/反应-内生-图像-缓存](https://github.com/georstat/react-native-image-cache) 图像缓存

```tsx
import { ImageGallery } from '@georstat/react-native-image-gallery';
import { CacheManager, CachedImage } from '@georstat/react-native-image-cache';
import { Dirs } from 'react-native-file-access';
import {
  ImageGallery,
  ImageObject,
} from '@georstat/react-native-image-gallery';

CacheManager.config = {
  baseDir: `${Dirs.CacheDir}/images_cache/`,
  blurRadius: 15,
  sourceAnimationDuration: 1000,
  thumbnailAnimationDuration: 1000,
};

const MyGallery = () => {
  const [isOpen, setIsOpen] = useState(false);
  const openGallery = () => setIsOpen(true);
  const closeGallery = () => setIsOpen(false);

  const renderHeaderComponent = (image: ImageObject, currentIndex: number) => {
    return <Header currentIndex={currentIndex} />;
  };

  const renderFooterComponent = (image: ImageObject, currentIndex: number) => {
    return <Footer total={images.length} currentIndex={currentIndex} />;
  };

  const renderCustomImage = (image: ImageObject) => {
    return (
      <View style={styles.customImageContainer}>
        <CachedImage
          resizeMode="cover"
          source={image.url}
          style={styles.customImage}
          thumbnailSource="https://via.placeholder.com/350x150"
        />
      </View>
    );
  };
  return (
    <View>
      <Button onPress={openGallery} title="Open Gallery" />
      <ImageGallery
        close={closeCustomGallery}
        hideThumbs
        images={images}
        isOpen={isCustomGalleryOpen}
        renderCustomImage={renderCustomImage}
        renderFooterComponent={renderFooterComponent}
        renderHeaderComponent={renderHeaderComponent}
      />
    </View>
  );
};
```

## 道具

#### `CachedImage` 接受下列道具:

| 属性 | 螺旋管 | 说明 |
| --- | --- | --- |
| `isOpen` | `Boolean` | (单位:千美元)**需求**何时展示画廊. |
| `images` | `Array` | (单位:千美元)**需求**) 对象阵列。 每个图像都必须有一个 `url` (需要)、拇指(可选)和id(可选)以及您需要的任何其他信息 |
| `resizeMode` | `string` | 反应原生图像组件 [调整模式大小](https://reactnative.dev/docs/image#resizemode) 默认为 `contain`,用于图像 |
| `close` | `Func` | (单位:千美元)**需求**()关闭画廊图像的功能 |
| `disableSwipe` | `Boolean` | 禁用刷新手势. |
| `initialIndex` | `Number` | 打开画廊时要抓图的初步索引 |
| `thumbSize` | `Number` | 拇指的高度和宽度,默认为 `48` |
| `thumbColor` | `string` | 选定拇指的外观颜色,默认为 `#d9b44a` |
| `thumbResizeMode` | `string` | 反应原生图像组件 [调整模式大小](https://reactnative.dev/docs/image#resizemode) 默认为 `cover`缩略图 |
| `hideThumbs` | `Boolean` | 设定为真以隐藏拇指默认为 `false` |
| `renderCustomThumb` | `Func` | 生成自定义拇指的函数 。 接受图像、索引和如果选择了拇指,请联系. `(image:Image, index:number, isSelected:boolean) => ...` |
| `renderCustomImage` | `Func` | 生成自定义图像的函数 。 接受图像、索引和如果选择了拇指,请联系. `(image:Image, index:number, isSelected:boolean) => ...` |
| `renderHeaderComponent` | `Func` | 在屏幕上方创建自定义标题的功能 。 接受图像和当前索引, eg. `(image:Image, currentIndex:number) => ...` |
| `renderFooterComponent` | `Func` | 在屏幕上方创建自定义标题的功能 。 接受图像和当前索引 eg. `(image:Image, currentIndex:number) => ...` |

## 待办事宜:

-   [ ] 
    
    添加缩放因数
    
-   [ ] 
    
    添加道具以保持缩放和双拍以缩放
    

## 作者数 :

-   [埃夫斯塔蒂奥斯·恩托纳斯](https://github.com/efstathiosntonas)
-   [乔治·巴科吉安尼斯](https://github.com/geobako)
-   [乔治·卡利尼科斯](https://github.com/giokallis)

## 常见问题

### @georstat/react-native-image-gallery 是什么？

用缩略图反射本地图像图片库

### 如何安装 @georstat/react-native-image-gallery？

在项目目录运行 npm install @georstat/react-native-image-gallery，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\*）、react-native（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @georstat/react-native-image-gallery 支持 TypeScript 吗？

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

### @georstat/react-native-image-gallery 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @georstat/react-native-image-gallery 可以商用吗？

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

### @georstat/react-native-image-gallery 的下载量有多少？

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

### @georstat/react-native-image-gallery 还在维护吗？

最新版本 1\.1\.0 发布于 2022/04/03（4 年前）；至今共发布 3 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/11/22。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

