# @freakycoder/react-native-helpers 中文文档

规范地址：https://npmcn.com/package/%40freakycoder/react-native-helpers/

版本：2\.5\.1
npm 元数据更新时间：2025-02-26T08:23:50.635Z
中文译文更新时间：2026-11-15T14:31:15.805Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：113 kB，53 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2019-05-11T20:01:11.997Z
- 最新版本发布：2025-02-26T08:23:50.491Z
- 近 30 天下载量：2651（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：22（近 12 个月 0 个）

## 中文简介

一个中的所有帮助者; iPhone 系列支持, 维度帮助者, has Notch 帮助者, 正常的文本帮助者和文本帮助者, 对 React Natural 非常容易使用

## 安装

```sh
npm install @freakycoder/react-native-helpers
```

也可以使用：`pnpm add @freakycoder/react-native-helpers`、`yarn add @freakycoder/react-native-helpers`、`bun add @freakycoder/react-native-helpers`

## README

![React Native Helpers](https://npmcn.com/package/%40freakycoder/react-native-helpers/assets/logo.png)

[![Battle Tested ✅](https://img.shields.io/badge/-Battle--Tested%20%E2%9C%85-03666e?style=for-the-badge)](https://github.com/WrathChaos/react-native-helpers)

**_一个中的所有帮助者; iPhone 系列支持, 维度帮助者, has Notch 帮助者, 正常的文本帮助者和文本帮助者, 对 React Natural 非常容易使用_**

[![npm version](https://img.shields.io/npm/v/@freakycoder/react-native-helpers.svg?style=for-the-badge)](https://www.npmjs.com/package/@freakycoder/react-native-helpers) [![npm](https://img.shields.io/npm/dt/@freakycoder/react-native-helpers.svg?style=for-the-badge)](https://www.npmjs.com/package/@freakycoder/react-native-helpers) ![expo-compatible](https://img.shields.io/badge/Expo-compatible-9cf.svg?style=for-the-badge) ![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20iOS-blue.svg?style=for-the-badge) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)

![React Native Helpers](https://github.com/WrathChaos/react-native-helpers/blob/master/assets/Screenshots/example.png)

## 安装

添加依赖 :

### 原生反应

```bash
npm i @freakycoder/react-native-helpers
```

## 设备信息使用

```tsx
import {
  Screen,
  ScreenWidth,
  ScreenHeight,
  isIOS,
  isAndroid,
  isTablet
} from "@freakycoder/react-native-helpers";

<View>
  <Container title="Device OS" subtitle={isIOS ? "iOS" : "Android"} />
  <Container title="Screen Height" subtitle={ScreenHeight} />
  <Container title="Screen Width" subtitle={ScreenWidth} />
  <Container title="Tablet?: " subtitle={isTablet ? "Tablet" : "Phone"} />
</View>;
```

## Notch 动态岛使用法( D)

```ts
import {
  getStatusBarHeight,
  hasNotch,
  hasNotchOnly,
  hasDynamicIsland,
  getStatusBarHeight,
} from "@freakycoder/react-native-helpers";

<View>
  <Container
    title="hasNotch?"
    subtitle={hasNotch() ? "Has Notch" : "NOT notch"}
  />
  <Container
    title="hasDynamicIsland?"
    subtitle={
      hasDynamicIsland(Screen) ? "Has Dynamic Island" : "NOT Dynamic Island"
    }
  />
  <Container title="getStatusBarHeight?" subtitle={getStatusBarHeight()} />
</View>;
```

## 通过链接打开应用程序或存储

```ts
import { openAppInPlayStore, openAppInAppStore, openExternalApp } from "@freakycoder/react-native-helpers";

openAppInPlayStore('com.example.android');
openAppInAppStore('123456789');
openExternalApp('com.example.android', '123456789');
```

## 文本使用规范化

实现不同设备字体大小正常化的方法

```ts
import { normalizeText } from "@freakycoder/react-native-helpers";

fontSize: normalizeText(24),
```

## 原生数字格式使用

格式化文本编号的方法。 你可以改变每个选项.

```ts
import { numberFormat } from "@freakycoder/react-native-helpers";

<Text>{numberFormat(50319341)</Text> // Output: 50.319.341
<Text>
  {numberFormat(1093495, "en", {
    style: "currency",
    currency: "GBP"
  })}
</Text>// Output: £ 50.319.341
```

# 配置 - 道具

## 设备信息软件

| 财产 | 类型 | 说明 |
| --- | :-: | --- |
| 是IOS系统 | 布尔 | 返回是否为 iOS 设备 |
| 类机器人 | 布尔 | 返回是否为Android设备 |
| 列表 | 布尔 | 如果是平板电脑或电话,则返回 |
| 屏幕宽度 | 编号 | 获得设备的屏幕宽度 |
| 屏幕高度 | 编号 | 获得设备屏幕高度 |
| 屏幕比例 | 编号 | 获得设备屏幕比例 |
| 屏幕缩放 | 编号 | 获得设备的屏幕字体比例( 取决于用户的设备字体比例设置) |
| 窗口宽度 | 编号 | 获得设备的窗口宽度 |
| 窗口高度 | 编号 | 获得设备的窗口高度 |
| 窗口缩放 | 编号 | 获得设备的窗口比例 |
| 窗口缩放 | 编号 | 获得设备的窗口字体比例( 取决于用户的设备字体比例设置) |
| 平台服务器 | 编号 | 返回平台版本 |
| 屏幕明码 | 编号 | 获得设备的屏幕宽度/ 高度, 即 **最低** 取决于地貌或肖像模式 |
| 屏幕麦克斯 | 编号 | 获得设备的屏幕宽度/ 高度, 即 **上限** 取决于地貌或肖像模式 |
| 页:1 | 编号 | 获得设备的高度,但作为一个 **视图端口单位** |
| 维 | 编号 | 获得设备的宽度,但作为一个 **视图端口单位** |
| 维明 | 编号 | 获得设备的屏幕宽度/ 高度为 **视图端口单位** 它们是 **最低** 取决于地貌或肖像模式 |
| vmax 图像 | 编号 | 获得设备的屏幕宽度/ 高度为 **视图端口单位** 它们是 **上限** 取决于地貌或肖像模式 |
| 获取DeviceLanguage 语言 | 字符串 | 获取设备的语言( en US) |

## 设备信息软件

获得状态 BarH8, has Notch, has Notch Only, has Dynamic Island

| 财产 | 类型 | 说明 |
| --- | :-: | --- |
| 备忘 | 函数 | 如果设备有正弦, 返回 |
| 仅此而已 | 函数 | 返回,如果设备仅具有非曲直,则不检测设备是否有动态岛 |
| 有动态岛 | 函数 | 如果设备有动态岛,则返回 |
| 获得状态 | 编号 | 返回设备的状态栏高度 |

## Utils 道具

| 财产 | 类型 | 说明 |
| --- | :-: | --- |
| 打开 AppInPlayStore | 函数( 应用程序包Name | 在 Android 或 Google Play 上打开应用程序 |
| 打开 AppInAppStore | 函数( appStoreId) | 在 ios 或 App Store 上打开应用程序 |
| 打开外部App | 函数( 应用程序包Name, appStoreId) | 在 ios 或 android 上打开应用程序 - 处理平台 |

## 规范文本道具

| 财产 | 类型 | 说明 |
| --- | :-: | --- |
| 常态 | 函数(数目) | 返回规范字体大小 |

## 自定义文本道具

| 财产 | 类型 | 说明 |
| --- | :-: | --- |
| 数字格式 | 函数( 值、 位置、 选项) | 返回带有给定参数的数字格式字体 |

### 路线图

-   [x] ~自由主义~
-   [x] ~字体~
-   [x] ~iPhone 系列支持~
-   [x] ~动态岛屿~
-   [ ] 从设备中分离样式帮助
-   [ ] 更多自定义文本助手
-   [ ] 写一篇关于介质上的 lib 的文章

## 作者

怪人编剧, [库拉约贡@gmail.com](mailto:kurayogun@gmail.com)

## 许可证

麻省理工学院的许可下可提供React Independent Helpers Library. 更多信息见LICENSE文件.

## 常见问题

### @freakycoder/react-native-helpers 是什么？

一个中的所有帮助者; iPhone 系列支持, 维度帮助者, has Notch 帮助者, 正常的文本帮助者和文本帮助者, 对 React Natural 非常容易使用

### 如何安装 @freakycoder/react-native-helpers？

在项目目录运行 npm install @freakycoder/react-native-helpers，或使用 pnpm add / yarn add / bun add。

### @freakycoder/react-native-helpers 支持 TypeScript 吗？

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

### @freakycoder/react-native-helpers 支持 ESM 还是 CommonJS？

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

### @freakycoder/react-native-helpers 可以商用吗？

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

### @freakycoder/react-native-helpers 的下载量有多少？

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

### @freakycoder/react-native-helpers 还在维护吗？

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

