diff --git a/zh-cn/bam-tech-react-native-image-resizer.md b/zh-cn/bam-tech-react-native-image-resizer.md index ea0465131fb66d98ea6db6206e3c0d4e09a37075..9548a5b59a94207e7b0c383dce45f58fce31a3de 100644 --- a/zh-cn/bam-tech-react-native-image-resizer.md +++ b/zh-cn/bam-tech-react-native-image-resizer.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-image-resizer Releases](https://github.com/react-native-oh-library/react-native-image-resizer/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.0.9 | [@react-native-oh-tpl/react-native-image-resizer Releases](https://github.com/react-native-oh-library/react-native-image-resizer/releases) | 0.72 | +| 3.0.11 | [@react-native-ohos/react-native-image-resizer Releases](https://github.com/react-native-oh-library/react-native-image-resizer/releases) | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -26,13 +33,21 @@ #### **npm** ```bash +# V3.0.9 npm install @react-native-oh-tpl/react-native-image-resizer + +# V3.0.11 +npm install @react-native-ohos/react-native-image-resizer ``` #### **yarn** ```bash +# V3.0.9 yarn add @react-native-oh-tpl/react-native-image-resizer + +# V3.0.11 +yarn add @react-native-ohos/react-native-image-resizer ``` @@ -270,7 +285,9 @@ export default ImageResizerDemo; ## 使用 Codegen -本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 +本库未带rc.x的版本已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 + +**注意:** V3.0.11 不需要执行 Codegen。 ## Link @@ -302,6 +319,8 @@ export default ImageResizerDemo; 打开 `entry/oh-package.json5`,添加以下依赖 +V3.0.9 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -309,6 +328,15 @@ export default ImageResizerDemo; } ``` +V3.0.11 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-image-resizer": "file:../../node_modules/@react-native-ohos/react-native-image-resizer/harmony/image_resizer.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -328,7 +356,10 @@ ohpm install ```diff ... + #V3.0.9 + import {ImageResizerPackage} from '@react-native-oh-tpl/react-native-image-resizer/ts'; + #V3.0.11 ++ import {ImageResizerPackage} from '@react-native-ohos/react-native-image-resizer/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ @@ -338,7 +369,62 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 4.配置 CMakeLists 和引入 ImageResizerPackage + +> V3.0.11 需要配置 CMakeLists 和引入 ImageResizerPackage。 + +打开 `entry/src/main/cpp/CMakeLists.txt`,添加: + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") ++ set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_END: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-image-resizer/src/main/cpp" ./image-resizer) + +# RNOH_END: manual_package_linking_1 + +add_library(rnoh_app SHARED + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) + +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++ target_link_libraries(rnoh_app PUBLIC rnoh_ImageResizer) +# RNOH_BEGIN: manual_package_linking_2 +``` + +> [!Tip] 注意:上面NODE_MODULES定义,为源库的安装路径,用户可以根据安装源库的路径定义NODE_MODULES + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "ImageResizerPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx) + }; +} +``` + +### 5.运行 点击右上角的 `sync` 按钮 @@ -351,13 +437,22 @@ ohpm install 然后编译、运行即可。 +[!TIP] 本库还依赖了[[@react-native-oh-tpl/react-native-image-picker](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-image-picker.md),如已在 HarmonyOS 工程中引入过该库,则无需再次引入,可跳过本章节步骤,直接使用。 + +如未引入请参照[@react-native-oh-tpl/react-native-image-picker](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-image-picker.md) 文档的 Link 章节](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-image-picker.md#link)进行引入 + ## 约束与限制 ### 兼容性 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-image-resizer Releases](https://github.com/react-native-oh-library/react-native-image-resizer/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.0.9 | [@react-native-oh-tpl/react-native-image-resizer Releases](https://github.com/react-native-oh-library/react-native-image-resizer/releases) | 0.72 | +| 3.0.11 | [@react-native-ohos/react-native-image-resizer Releases](https://github.com/react-native-oh-library/react-native-image-resizer/releases) | 0.77 | ## API @@ -391,4 +486,5 @@ ohpm install ## 开源协议 -本项目基于 [The MIT License (MIT)](https://github.com/bamlab/react-native-image-resizer/blob/master/LICENSE) ,请自由地享受和参与开源。 \ No newline at end of file +本项目基于 [The MIT License (MIT)](https://github.com/bamlab/react-native-image-resizer/blob/master/LICENSE) ,请自由地享受和参与开源。 + diff --git a/zh-cn/baronha-ting.md b/zh-cn/baronha-ting.md index bf92399f3970763ddd6111159391aa315146bf29..43bcdb128bce1b7b9a12a6310fca80974900d89a 100644 --- a/zh-cn/baronha-ting.md +++ b/zh-cn/baronha-ting.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/ting Releases](https://github.com/react-native-oh-library/ting/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.2.2 | [@react-native-oh-tpl/ting Releases](https://github.com/react-native-oh-library/ting/releases) | 0.72 | +| 1.2.3 | [@react-native-ohos/ting Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -26,13 +33,21 @@ #### **npm** ```bash +# V1.2.2 npm install @react-native-oh-tpl/ting + +# V1.2.3 +npm install @react-native-ohos/ting ``` #### **yarn** ```bash +# V1.2.2 yarn add @react-native-oh-tpl/ting + +# V1.2.3 +yarn add @react-native-ohos/ting ``` @@ -41,8 +56,9 @@ yarn add @react-native-oh-tpl/ting > [!WARNING] 使用时 import 的库名不变。 + ```js -import { View } from "react-native"; +import { View, Button } from "react-native"; import { ToastOptions, toast @@ -54,18 +70,19 @@ function handleToast(options: ToastOptions) { const App = () => { return ( - - - - - - - ) - } -} - -export default App; -``` - -## 使用 Codegen - -本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 - -## Link - -目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 - -首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony` - -### 1.在工程根目录的 `oh-package.json5` 添加 overrides 字段 - -```json -{ - ... - "overrides": { - "@rnoh/react-native-openharmony" : "./react_native_openharmony" - } -} -``` - -### 2.引入原生端代码 - -目前有两种方法: - -1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法); -2. 直接链接源码。 - -方法一:通过 har 包引入(推荐) - -> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。 - -打开 `entry/oh-package.json5`,添加以下依赖 - -```json -"dependencies": { - "@rnoh/react-native-openharmony": "file:../react_native_openharmony", - "@react-native-oh-tpl/react-native-ble-plx": "file:../../node_modules/@react-native-oh-tpl/react-native-ble-plx/harmony/rn_bleplx.har" - } -``` - -点击右上角的 `sync` 按钮 - -或者在终端执行: - -```bash -cd entry -ohpm install -``` - -方法二:直接链接源码 - -> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) - -### 3.在 ArkTs 侧引入 BlePlxPackage - -打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: - -```diff - ... -+ import {BlePlxPackage} from '@react-native-oh-tpl/react-native-ble-plx/ts'; - -export function createRNPackages(ctx: RNPackageContext): RNPackage[] { - return [ - new SamplePackage(ctx), -+ new BlePlxPackage(ctx) - ]; -} -``` - -### 4.运行 - -点击右上角的 `sync` 按钮 - -或者在终端执行: - -```bash -cd entry -ohpm install -``` - -然后编译、运行即可。 - -## 约束与限制 - -### 兼容性 - -要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 - -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-ble-plx Releases](https://github.com/react-native-oh-library/react-native-ble-plx/releases) - -### 权限要求 - -- 由于此库涉及蓝牙系统控制功能,使用对应接口时则需要配置对应的权限,权限需配置在entry/src/main目录下module.json5文件中。其中部分权限需弹窗向用户申请授权。具体权限配置见文档:[程序访问控制](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/Readme-CN.md#/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/app-permission-mgmt-overview.md)。 - -- 此库部分功能与接口需要normal权限:ohos.permission.ACCESS_BLUETOOTH。 - -## API - -> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。 - -> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 - -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| createClient(restoreStateIdentifier?: string) | creat client | void | No | iOS/Android | yes | -| destroyClient() | remove client | Promise | No | iOS/Android | yes | -| cancelTransaction(transactionId: string) | cancel transcation | Promise | No | iOS/Android | no | -| setLogLevel(logLevel: string) | set log level | Promise | No | iOS/Android | no | -| logLevel() | show log level | Promise | No | iOS/Android | no | -| enable(transactionId: string) | can get transaction Id | Promise | No | iOS/Android | yes | -| disable(transactionId: string) | cannot get transaction Id | Promise | No | iOS/Android | yes | -| state() | bluetooth state | Promise | No | iOS/Android | yes | -| startDeviceScan(filteredUUIDs: string[], options: Object) | start scan device | Promise| No | iOS/Android | yes | -| stopDeviceScan() | stop scan device | Promise | No | iOS/Android | yes | -| requestConnectionPriorityForDevice(deviceId: string, connectionPriority: number,transactionId: string) | request connect priority device | Promise | No | iOS/Android | no | -| readRSSIForDevice(deviceId: string, transactionId: string) | read RSSI device | Promise | No | iOS/Android | yes | -| requestMTUForDevice(deviceId: string, mtu: number, transactionId: string) | request MTU device | Promise | No | iOS/Android | yes | -| devices(deviceIdentifiers: string[]) | identify devices | Promise | No | iOS/Android | yes | -| connectedDevices(serviceUUIDs: string[]) | connect devices | Promise | No | iOS/Android | yes | -| connectToDevice(deviceId: string, options?: Object) | option to connect device | Promise | No | iOS/Android | yes | -| cancelDeviceConnection(deviceId: string) | cancel device connection | Promise | No | iOS/Android | yes | -| isDeviceConnected(deviceId: string) | connected device | Promise | No | iOS/Android | yes | -| discoverAllServicesAndCharacteristicsForDevice(deviceId: string, transactionId: string) | discover all device service and characteristics | Promise | No | iOS/Android | yes | -| servicesForDevice(deviceId: string) | device service | Promise | No | iOS/Android | yes | -| characteristicsForDevice(deviceId: string, serviceUUID: string) | device characteristics | Promise | No | iOS/Android | yes | -| characteristicsForService(serviceIdentifier: number) | service characteristics | Promise | No | iOS/Android | yes | -| descriptorsForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string): Promise | device descriptors | Promise | No | iOS/Android | yes | -| descriptorsForService(serviceIdentifier: number, characteristicUUID: string) | service descriptors | Promise | No | iOS/Android | yes | -| descriptorsForCharacteristic(characteristicIdentifier: number) |descriptors identifier device characteristic | Promise | No | iOS/Android | yes | -| readCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, transactionId: string) | read device characteristic | Promise | No | iOS/Android | yes | -| readCharacteristicForService(serviceIdentifier: number, characteristicUUID: string,transactionId: string) | read service charcteristic | Promise | No | iOS/Android | yes | -| readCharacteristic(characteristicIdentifier: number, transactionId: string) | read identifier characteristic | Promise | No | iOS/Android | yes | -| writeCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, valueBase64: string,response: boolean, transactionId: string) | write device characteristic | Promise | No | iOS/Android | yes | -| writeCharacteristicForService(serviceIdentifier: number, characteristicUUID: string, valueBase64: string,response: boolean, transactionId: string) | write service characteristic | Promise | No | iOS/Android | yes | -| writeCharacteristic(characteristicIdentifier: number, valueBase64: string, response: boolean,transactionId: string) | write identifier characteristic | Promise | No | iOS/Android | yes | -| monitorCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string,transactionId: string) | monitor device characteristic | Promise | No | iOS/Android | yes | -| monitorCharacteristicForService(serviceIdentifier: number, characteristicUUID: string,transactionId: string) | monitor service characteristic | Promise | No | iOS/Android | yes | -| monitorCharacteristic(characteristicIdentifier: number, transactionId: string) | monitor identifier characteristic | Promise | No | iOS/Android | yes | -| readDescriptorForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string,transactionId: string) | read device descriptor | Promise | No | iOS/Android | yes | -| readDescriptorForService(serviceIdentifier: number, characteristicUUID: string, descriptorUUID: string,transactionId: string) | read service descriptor | Promise | No | iOS/Android | yes | -| readDescriptorForCharacteristic(characteristicIdentifier: number, descriptorUUID: string,transactionId: string) | read identifier characteristic descriptor | Promise | No | iOS/Android | yes | -| readDescriptor(descriptorIdentifier: number, transactionId: string) | read identifier descriptor | Promise | No | iOS/Android | yes | -| writeDescriptorForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string,valueBase64: string, transactionId: string) | write device descriptor | Promise | No | iOS/Android | yes | -| writeDescriptorForService(serviceIdentifier: number, characteristicUUID: string, descriptorUUID: string,valueBase64: string, transactionId: string) | write service descriptor | Promise | No | iOS/Android | yes | -| writeDescriptorForCharacteristic(characteristicIdentifier: number, descriptorUUID: string, valueBase64: string,transactionId: string) | write identifier characteristic descriptor | Promise | No | iOS/Android | yes | -| writeDescriptor(descriptorIdentifier: number, valueBase64: string, transactionId: string) | write identifier descriptor | Promise | No | iOS/Android | yes | - -## 遗留问题 - -- [ ] cancelTransaction(transactionId: string)接口harmony暂不支持: [issue#2](https://github.com/react-native-oh-library/react-native-ble-plx/issues/2) -- [ ] setLogLevel(logLevel: string)接口harmony暂不支持: [issue#3](https://github.com/react-native-oh-library/react-native-ble-plx/issues/3) -- [ ] logLevel()接口harmony暂不支持: [issue#4](https://github.com/react-native-oh-library/react-native-ble-plx/issues/4) -- [ ] requestConnectionPriorityForDevice(deviceId: string, connectionPriority: number,transactionId: string)接口harmony暂不支持: [issue#5](https://github.com/react-native-oh-library/react-native-ble-plx/issues/5) - -## 其他 - -## 开源协议 - -本项目基于 [Apache License 2.0](https://github.com/dotintent/react-native-ble-plx/blob/master/LICENSE) ,请自由地享受和参与开源。 +> 模板版本:v0.2.2 + +

+

react-native-ble-plx

+

+

+ + Supported platforms + + + License + +

+ +> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-ble-plx) + +## 安装与使用 + +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.2.0 | [@react-native-oh-tpl/react-native-ble-plx Releases](https://github.com/react-native-oh-library/react-native-ble-plx/releases) | 0.72 | +| 3.5.0 | [@react-native-ohos/react-native-ble-plx Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 + +进入到工程目录并输入以下命令: + + + +#### **npm** + +```bash +# V3.2.0 +npm install @react-native-oh-tpl/react-native-ble-plx + +# V3.5.0 +npm install @react-native-ohos/react-native-ble-plx +``` + +#### **yarn** + +```bash +# V3.2.0 +yarn add @react-native-oh-tpl/react-native-ble-plx + +# V3.5.0 +yarn add @react-native-ohos/react-native-ble-plx +``` + + + +下面的代码展示了这个库的基本使用场景: + +> [!WARNING] 使用时 import 的库名不变。 + +```js +import { + BleError, + BleErrorCode, + BleManager, + Device, + State as BluetoothState, + LogLevel, + type DeviceId, + type TransactionId, + type UUID, + type Characteristic, + type Base64, + type Subscription +} from 'react-native-ble-plx' + +class BLEServiceInstance { + manager: BleManager + device: Device | null + + constructor() { + this.device = null + this.manager = new BleManager() + } + + scanDevices = async (onDeviceFound: (device: Device) => void, UUIDs: UUID[] | null = null) => { + this.manager.startDeviceScan(UUIDs, null, (error, device) => { + if (error) { + console.error(error.message) + this.manager.stopDeviceScan() + return + } + if (device) { + onDeviceFound(device) + } + }) + } + + connectToDevice = (deviceId: DeviceId) => + new Promise((resolve, reject) => { + this.manager.stopDeviceScan() + this.manager + .connectToDevice(deviceId) + .then(device => { + this.device = device + resolve(device) + }) + .catch(error => { + if (error.errorCode === BleErrorCode.DeviceAlreadyConnected && this.device) { + resolve(this.device) + } else { + console.error(error.message) + reject(error) + } + }) + }) + + discoverAllServicesAndCharacteristicsForDevice = async () => + new Promise((resolve, reject) => { + if (!this.device) { + reject(new Error(deviceNotConnectedErrorText)) + return + } + this.manager + .discoverAllServicesAndCharacteristicsForDevice(this.device.id) + .then(device => { + resolve(device) + this.device = device + }) + .catch(error => { + reject(error) + }) + }) + + readCharacteristicForDevice = async (serviceUUID: UUID, characteristicUUID: UUID) => + new Promise((resolve, reject) => { + if (!this.device) { + reject(new Error(deviceNotConnectedErrorText)) + return + } + this.manager + .readCharacteristicForDevice(this.device.id, serviceUUID, characteristicUUID) + .then(characteristic => { + resolve(characteristic) + }) + .catch(error => { + console.error(error.message) + }) + }) + + writeCharacteristicWithResponseForDevice = async (serviceUUID: UUID, characteristicUUID: UUID, time: Base64) => { + if (!this.device) { + console.error(deviceNotConnectedErrorText) + throw new Error(deviceNotConnectedErrorText) + } + return this.manager + .writeCharacteristicWithResponseForDevice(this.device.id, serviceUUID, characteristicUUID, time) + .catch(error => { + console.error(error.message) + }) + } +``` + +## 使用 Codegen + +本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 + +**注意:**V3.5.0 不需要执行 Codegen。 + +## 配置 CMakeLists和引入 RNOHGeneratedPackage + +> V3.5.0 需要配置 CMakeLists和引入 RNOHGeneratedPackage。 + +打开 entry/src/main/cpp/CMakeLists.txt,添加: +```diff +{ +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + +set(RNOH_CPP_DIR "${OH_MODULE_DIR}/@rnoh/react-native-openharmony/src/main/cpp") +set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated") +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") + +add_compile_definitions(WITH_HITRACE_SYSTRACE) +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-ble-plx/src/main/cpp" ./ble_plx) + +#file(GLOB GENERATED_CPP_FILES "${OH_MODULES}/@react-native-ohos/react-native-email-link/src/main/cpp/generated/*.cpp") +#file(GLOB VISION_CAMERA_CPP_FILES "${OH_MODULES}/@react-native-ohos/react-native-vision-camera/src/main/cpp/*.cpp") + +file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) + +target_link_libraries(rnoh_app PUBLIC rnoh) ++ target_link_libraries(rnoh_app PUBLIC rnoh_ble_plx) +} +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "BlePlxRNOHGeneratedPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { ++ std::make_shared(ctx) + }; +} +``` + +## Link + +目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 + +首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony` + +### 1.在工程根目录的 `oh-package.json5` 添加 overrides 字段 + +```json +{ + ... + "overrides": { + "@rnoh/react-native-openharmony" : "./react_native_openharmony" + } +} +``` + +### 2.引入原生端代码 + +目前有两种方法: + +1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法); +2. 直接链接源码。 + +方法一:通过 har 包引入(推荐) + +> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。 + +打开 `entry/oh-package.json5`,添加以下依赖 + +- V3.2.0 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-ble-plx": "file:../../node_modules/@react-native-oh-tpl/react-native-ble-plx/harmony/rn_bleplx.har" + } +``` + +- V3.5.0 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-ble-plx": "file:../../node_modules/@react-native-ohos/react-native-ble-plx/harmony/rn_bleplx.har" + } +``` + +点击右上角的 `sync` 按钮 + +或者在终端执行: + +```bash +cd entry +ohpm install +``` + +方法二:直接链接源码 + +> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) + +### 3.在 ArkTs 侧引入 BlePlxPackage + +打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: + +```diff + ... +// V3.2.0 ++ import {BlePlxPackage} from '@react-native-oh-tpl/react-native-ble-plx/ts'; + +// V3.5.0 ++ import {BlePlxPackage} from '@react-native-ohos/react-native-ble-plx/ts'; + +export function createRNPackages(ctx: RNPackageContext): RNPackage[] { + return [ + new SamplePackage(ctx), ++ new BlePlxPackage(ctx) + ]; +} +``` + +### 4.运行 + +点击右上角的 `sync` 按钮 + +或者在终端执行: + +```bash +cd entry +ohpm install +``` + +然后编译、运行即可。 + +## 约束与限制 + +### 兼容性 + +要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 + +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.2.0 | [@react-native-oh-tpl/react-native-ble-plx Releases](https://github.com/react-native-oh-library/react-native-ble-plx/releases) | 0.72 | +| 3.5.0 | [@react-native-ohos/react-native-ble-plx Releases]() | 0.77 | + +### 权限要求 + +- 由于此库涉及蓝牙系统控制功能,使用对应接口时则需要配置对应的权限,权限需配置在entry/src/main目录下module.json5文件中。其中部分权限需弹窗向用户申请授权。具体权限配置见文档:[程序访问控制](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/Readme-CN.md#/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/app-permission-mgmt-overview.md)。 + +- 此库部分功能与接口需要normal权限:ohos.permission.ACCESS_BLUETOOTH。 + +## API + +> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。 + +> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 + +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ---- | ----------- | ---- | -------- | -------- | ------------------ | +| createClient(restoreStateIdentifier?: string) | creat client | void | yes | iOS/Android | yes | +| destroyClient() | remove client | Promise | yes | iOS/Android | yes | +| cancelTransaction(transactionId: string) | cancel transcation | Promise | yes | iOS/Android | no | +| setLogLevel(logLevel: string) | set log level | Promise | yes | iOS/Android | no | +| logLevel() | show log level | Promise | yes | iOS/Android | no | +| enable(transactionId: string) | can get transaction Id | Promise | yes | iOS/Android | yes | +| disable(transactionId: string) | cannot get transaction Id | Promise | yes | iOS/Android | yes | +| state() | bluetooth state | Promise | yes | iOS/Android | yes | +| startDeviceScan(filteredUUIDs: string[], options: Object) | start scan device | Promise| yes | iOS/Android | yes | +| stopDeviceScan() | stop scan device | Promise | yes | iOS/Android | yes | +| requestConnectionPriorityForDevice(deviceId: string, connectionPriority: number,transactionId: string) | request connect priority device | Promise | yes | iOS/Android | no | +| readRSSIForDevice(deviceId: string, transactionId: string) | read RSSI device | Promise | yes | iOS/Android | yes | +| requestMTUForDevice(deviceId: string, mtu: number, transactionId: string) | request MTU device | Promise | yes | iOS/Android | yes | +| devices(deviceIdentifiers: string[]) | identify devices | Promise | yes | iOS/Android | yes | +| connectedDevices(serviceUUIDs: string[]) | connect devices | Promise | yes | iOS/Android | yes | +| connectToDevice(deviceId: string, options?: Object) | option to connect device | Promise | yes | iOS/Android | yes | +| cancelDeviceConnection(deviceId: string) | cancel device connection | Promise | yes | iOS/Android | yes | +| isDeviceConnected(deviceId: string) | connected device | Promise | yes | iOS/Android | yes | +| discoverAllServicesAndCharacteristicsForDevice(deviceId: string, transactionId: string) | discover all device service and characteristics | Promise | yes | iOS/Android | yes | +| servicesForDevice(deviceId: string) | device service | Promise | yes | iOS/Android | yes | +| characteristicsForDevice(deviceId: string, serviceUUID: string) | device characteristics | Promise | yes | iOS/Android | yes | +| characteristicsForService(serviceIdentifier: number) | service characteristics | Promise | yes | iOS/Android | yes | +| descriptorsForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string): Promise | device descriptors | Promise | yes | iOS/Android | yes | +| descriptorsForService(serviceIdentifier: number, characteristicUUID: string) | service descriptors | Promise | yes | iOS/Android | yes | +| descriptorsForCharacteristic(characteristicIdentifier: number) |descriptors identifier device characteristic | Promise | yes | iOS/Android | yes | +| readCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, transactionId: string) | read device characteristic | Promise | yes | iOS/Android | yes | +| readCharacteristicForService(serviceIdentifier: number, characteristicUUID: string,transactionId: string) | read service charcteristic | Promise | yes | iOS/Android | yes | +| readCharacteristic(characteristicIdentifier: number, transactionId: string) | read identifier characteristic | Promise | yes | iOS/Android | yes | +| writeCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, valueBase64: string,response: boolean, transactionId: string) | write device characteristic | Promise | yes | iOS/Android | yes | +| writeCharacteristicForService(serviceIdentifier: number, characteristicUUID: string, valueBase64: string,response: boolean, transactionId: string) | write service characteristic | Promise | yes | iOS/Android | yes | +| writeCharacteristic(characteristicIdentifier: number, valueBase64: string, response: boolean,transactionId: string) | write identifier characteristic | Promise | yes | iOS/Android | yes | +| monitorCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string,transactionId: string) | monitor device characteristic | Promise | yes | iOS/Android | yes | +| monitorCharacteristicForDevice3.5.0+(deviceIdentifier: DeviceId,serviceUUID: UUID,characteristicUUID: UUID,transactionId: TransactionId, subscriptionType: ?CharacteristicSubscriptionType): Promise | monitor device characteristic | Promise | yes | iOS/Android | yes | +| monitorCharacteristicForService(serviceIdentifier: number, characteristicUUID: string,transactionId: string) | monitor service characteristic | Promise | yes | iOS/Android | yes | +| monitorCharacteristicForService3.5.0+(serviceIdentifier: Identifier, characteristicUUID: UUID, transactionId: TransactionId,subscriptionType: ?CharacteristicSubscriptionType): Promise | monitor service characteristic | Promise | yes | iOS/Android | yes | +| monitorCharacteristic(characteristicIdentifier: number, transactionId: string) | monitor identifier characteristic | Promise | yes | iOS/Android | yes | +| monitorCharacteristic3.5.0+(characteristicIdentifier: Identifier, transactionId: TransactionId,subscriptionType:?CharacteristicSubscriptionType): Promise | monitor identifier characteristic | Promise | yes | iOS/Android | yes | +| readDescriptorForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string,transactionId: string) | read device descriptor | Promise | yes | iOS/Android | yes | +| readDescriptorForService(serviceIdentifier: number, characteristicUUID: string, descriptorUUID: string,transactionId: string) | read service descriptor | Promise | yes | iOS/Android | yes | +| readDescriptorForCharacteristic(characteristicIdentifier: number, descriptorUUID: string,transactionId: string) | read identifier characteristic descriptor | Promise | yes | iOS/Android | yes | +| readDescriptor(descriptorIdentifier: number, transactionId: string) | read identifier descriptor | Promise | yes | iOS/Android | yes | +| writeDescriptorForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, descriptorUUID: string,valueBase64: string, transactionId: string) | write device descriptor | Promise | yes | iOS/Android | yes | +| writeDescriptorForService(serviceIdentifier: number, characteristicUUID: string, descriptorUUID: string,valueBase64: string, transactionId: string) | write service descriptor | Promise | yes | iOS/Android | yes | +| writeDescriptorForCharacteristic(characteristicIdentifier: number, descriptorUUID: string, valueBase64: string,transactionId: string) | write identifier characteristic descriptor | Promise | yes | iOS/Android | yes | +| writeDescriptor(descriptorIdentifier: number, valueBase64: string, transactionId: string) | write identifier descriptor | Promise | yes | iOS/Android | yes | + +## 遗留问题 + +- [ ] cancelTransaction(transactionId: string)接口harmony暂不支持: [issue#2](https://github.com/react-native-oh-library/react-native-ble-plx/issues/2) +- [ ] setLogLevel(logLevel: string)接口harmony暂不支持: [issue#3](https://github.com/react-native-oh-library/react-native-ble-plx/issues/3) +- [ ] logLevel()接口harmony暂不支持: [issue#4](https://github.com/react-native-oh-library/react-native-ble-plx/issues/4) +- [ ] requestConnectionPriorityForDevice(deviceId: string, connectionPriority: number,transactionId: string)接口harmony暂不支持: [issue#5](https://github.com/react-native-oh-library/react-native-ble-plx/issues/5) + +## 其他 + +## 开源协议 + +本项目基于 [Apache License 2.0](https://github.com/dotintent/react-native-ble-plx/blob/master/LICENSE) ,请自由地享受和参与开源。 diff --git a/zh-cn/react-native-clipboard-clipboard.md b/zh-cn/react-native-clipboard-clipboard.md index 4167d2a89648ccd395269561e549108142f4d1c2..66ec58a83bed923b8cc09f33628769018ca62ef1 100644 --- a/zh-cn/react-native-clipboard-clipboard.md +++ b/zh-cn/react-native-clipboard-clipboard.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/clipboard Releases](https://github.com/react-native-oh-library/clipboard/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.13.2 | [@react-native-oh-tpl/clipboard Releases](https://github.com/react-native-oh-library/clipboard/releases) | 0.72 | +| 1.16.2 | [@react-native-ohos/clipboard Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,21 @@ #### **npm** ```bash +# V1.13.2 npm install @react-native-oh-tpl/clipboard + +# V1.16.2 +npm install @react-native-ohos/clipboard ``` #### **yarn** ```bash +# V1.13.2 yarn add @react-native-oh-tpl/clipboard + +# V1.16.2 +yarn add @react-native-ohos/clipboard ``` @@ -40,6 +55,8 @@ yarn add @react-native-oh-tpl/clipboard > [!WARNING] 使用时 import 的库名不变。 +#### **For RN0.72** + ```js import Clipboard from "@react-native-clipboard/clipboard"; @@ -72,6 +89,55 @@ const App = () => { export default App; ``` +**For RN0.77** + +```js +import React, { useState } from 'react'; +import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; +import Clipboard from "@react-native-clipboard/clipboard"; + +const App = () => { + const [copiedText, setCopiedText] = useState(""); + + const copyToClipboard = () => { + Clipboard.setString("hello world"); + }; + + const fetchCopiedText = async () => { + const text = await Clipboard.getString(); + setCopiedText(text); + }; + + return ( + + + Click here to copy to Clipboard + + + View copied text + + + {copiedText} + + ); +}; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + padding: 20, + }, + copiedText: { + marginTop: 20, + fontSize: 18, + }, +}); + +export default App; +``` + ## Link 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -102,6 +168,8 @@ export default App; 打开 `entry/oh-package.json5`,添加以下依赖 +- V1.13.2 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -110,6 +178,16 @@ export default App; } ``` +- V1.16.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + + "@react-native-ohos/clipboard": "file:../../node_modules/@react-native-ohos/clipboard/harmony/clipboard.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -145,7 +223,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V1.13.2 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/clipboard/src/main/cpp" ./clipboard) + +# V1.16.2 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/clipboard/src/main/cpp" ./clipboard) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -189,8 +273,13 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff import type {RNPackageContext, RNPackage} from 'rnoh/ts'; import {SamplePackage} from 'rnoh-sample-package/ts'; + +// V1.13.2 + import {ClipboardPackage} from '@react-native-oh-tpl/clipboard/ts'; +// V1.16.2 ++ import {ClipboardPackage} from '@react-native-ohos/clipboard/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -219,7 +308,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/clipboard Releases](https://github.com/react-native-oh-library/clipboard/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.13.2 | [@react-native-oh-tpl/clipboard Releases](https://github.com/react-native-oh-library/clipboard/releases) | 0.72 | +| 1.16.2 | [@react-native-ohos/clipboard Releases]() | 0.77 | ### 权限要求 diff --git a/zh-cn/react-native-code-push.md b/zh-cn/react-native-code-push.md index c9a3f271ea80598c055c321f185b4491c2ed5e8c..82431004d228f97f6a5142a501d4493223bbd321 100644 --- a/zh-cn/react-native-code-push.md +++ b/zh-cn/react-native-code-push.md @@ -47,7 +47,14 @@ code-push release "<版本号>" --description " "<版本号>" --description " @@ -183,6 +198,8 @@ export default CodePush(codePushOptions)(App); 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 +**注意:** V9.0.1 不需要执行 Codegen。 + ## Link 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -213,6 +230,8 @@ export default CodePush(codePushOptions)(App); 打开 `entry/oh-package.json5`,添加以下依赖 +- V8.0.2 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -220,6 +239,15 @@ export default CodePush(codePushOptions)(App); } ``` +- V9.0.1 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-code-push": "file:../../node_modules/@react-native-ohos/react-native-code-push/harmony/codePush.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -233,14 +261,75 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 CodePushPackage +### 3.配置 CMakeLists 和引入 CodePushPackage + +> V9.0.1 需要配置 CMakeLists 和引入CodePushPackage。 + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") +set(LOG_VERBOSITY_LEVEL 1) +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use +add_compile_definitions(WITH_HITRACE_SYSTRACE) + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULE_DIR}/@react-native-ohos/react-native-code-push/src/main/cpp" ./codePush) +# RNOH_END: manual_package_linking_1 + +file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") + +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++ target_link_libraries(rnoh_app PUBLIC rnoh_code_push) +# RNOH_END: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "CodePushPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx) + }; +} +``` + +### 4.在 ArkTs 侧引入 CodePushPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... +// V8.0.2 + import { CodePushPackage } from "@react-native-oh-tpl/react-native-code-push/ts"; +// V9.0.1 ++ import { CodePushPackage } from "@react-native-ohos/react-native-code-push/ts"; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -249,13 +338,17 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.在 ArkTs 侧引入 comparingVersion 方法 +### 5.在 ArkTs 侧引入 comparingVersion 方法 打开 `entry/src/main/ets/pages/index.ets`,调用 comparingVersion 方法比对code-push版本号,用于覆盖安装时清除沙箱历史资源 ```diff +// V8.0.2 + import { comparingVersion } from "@react-native-oh-tpl/react-native-code-push"; +// V9.0.1 ++ import { comparingVersion } from "@react-native-ohos/react-native-code-push"; + @Entry @Component struct Index { @@ -267,7 +360,7 @@ struct Index { ``` -### 5.运行 +### 6.运行 点击右上角的 `sync` 按钮 @@ -374,7 +467,12 @@ build() { 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-code-push Releases](https://github.com/react-native-oh-library/react-native-code-push/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 8.0.2 | [@react-native-oh-tpl/react-native-code-push Releases](https://github.com/react-native-oh-library/react-native-code-push/releases) | 0.72 | +| 9.0.1 | [@react-native-ohos/react-native-code-push Releases]() | 0.77 | ## API diff --git a/zh-cn/react-native-color-matrix-image-filters.md b/zh-cn/react-native-color-matrix-image-filters.md index d3d8e5ceead9e73e27fc1c735f292cae2eb6c6d2..1cbb9f4c802995e31f208de120c3f301093aa9a0 100644 --- a/zh-cn/react-native-color-matrix-image-filters.md +++ b/zh-cn/react-native-color-matrix-image-filters.md @@ -1,285 +1,333 @@ -> 模板版本:v0.2.0 - -

-

react-native-color-matrix-image-filters

-

-

- - Supported platforms - - - License - -

- -> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-color-matrix-image-filters) - -## 安装与使用 - -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-color-matrix-image-filters Releases](https://github.com/react-native-oh-library/react-native-color-matrix-image-filters/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 - -进入到工程目录并输入以下命令: - - - -#### **npm** - -```bash -npm install @react-native-oh-tpl/react-native-color-matrix-image-filters -``` - -#### **yarn** - -```bash -yarn add @react-native-oh-tpl/react-native-color-matrix-image-filters -``` - - - -下面的代码展示了这个库的基本使用场景: - -> [!WARNING] 使用时 import 的库名不变。 - -```js -import { - Achromatomaly, - Achromatopsia, - Brightness -} from 'react-native-color-matrix-image-filters'; -import React from 'react'; -import { View, StyleSheet, Image } from 'react-native'; - -export const ColorMatrixImageFiltersTest = () => { - - return ( - - - - - - - - - - ) -} - -const styles = StyleSheet.create({ - image: { - width: 150, - height: 100, - justifyContent: 'center', - alignItems: 'center' - } -}) -``` - -## Link - -目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 - -首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony` - -### 在工程根目录的 `oh-package.json5` 添加 overrides字段 - -```json -{ - ... - "overrides": { - "@rnoh/react-native-openharmony" : "./react_native_openharmony" - } -} -``` - -### 2.引入原生端代码 - -目前有两种方法: - -1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法); -2. 直接链接源码。 - -方法一:通过 har 包引入 - -> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。 - -打开 `entry/oh-package.json5`,添加以下依赖 - -```json -"dependencies": { - "@rnoh/react-native-openharmony": "file:../react_native_openharmony", - "@react-native-oh-tpl/react-native-color-matrix-image-filters": "file:../../node_modules/@react-native-oh-tpl/react-native-color-matrix-image-filters/harmony/color_matrix_image_filters.har" - } -``` - -点击右上角的 `sync` 按钮 - -或者在终端执行: - -```bash -cd entry -ohpm install -``` - -方法二:直接链接源码 - -> [!TIP] 源码位于三方库安装路径的 `harmony` 文件夹下。 - -打开 `entry/oh-package.json5`,添加以下依赖 - -```json -"dependencies": { -"@rnoh/react-native-openharmony": "file:../react_native_openharmony", -"@react-native-oh-tpl/react-native-color-matrix-image-filters": "file:../../node_modules/@react-native-oh-tpl/react-native-color-matrix-image-filters/harmony/color_matrix_image_filters" - } -``` - -打开终端,执行: - -```bash -cd entry -ohpm install --no-link -``` - -### 3.配置 CMakeLists 和引入 ColorMatrixImageFiltersPackage - -打开 `entry/src/main/cpp/CMakeLists.txt`,添加: - -```diff -project(rnapp) -cmake_minimum_required(VERSION 3.4.1) -set(CMAKE_SKIP_BUILD_RPATH TRUE) -set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") -set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") -+ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") -set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") -set(LOG_VERBOSITY_LEVEL 1) -set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") -set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") -set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use -add_compile_definitions(WITH_HITRACE_SYSTRACE) - -add_subdirectory("${RNOH_CPP_DIR}" ./rn) - -# RNOH_BEGIN: manual_package_linking_1 -add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) -+ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-color-matrix-image-filters/src/main/cpp" ./color_matrix_image_filters) -# RNOH_END: manual_package_linking_1 - -file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") - -add_library(rnoh_app SHARED - ${GENERATED_CPP_FILES} - "./PackageProvider.cpp" - "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" -) -target_link_libraries(rnoh_app PUBLIC rnoh) - -# RNOH_BEGIN: manual_package_linking_2 -target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) -+ target_link_libraries(rnoh_app PUBLIC rnoh_color_matrix_image_filters ) -# RNOH_END: manual_package_linking_2 -``` - -打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: - -```diff -#include "RNOH/PackageProvider.h" -#include "generated/RNOHGeneratedPackage.h" -#include "SamplePackage.h" -+ #include "ColorMatrixImageFiltersPackage.h" - -using namespace rnoh; - -std::vector> PackageProvider::getPackages(Package::Context ctx) { - return { - std::make_shared(ctx), - std::make_shared(ctx), -+ std::make_shared(ctx) - }; -} -``` - - -### 4.运行 - -点击右上角的 `sync` 按钮 - -或者在终端执行: - -```bash -cd entry -ohpm install -``` - -然后编译、运行即可。 - -## 约束与限制 - -### 兼容性 - -要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 - -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-color-matrix-image-filters Releases](https://github.com/react-native-oh-library/react-native-color-matrix-image-filters/releases) - - -## 属性 - -> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。 - -> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 - -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| matrix | Matrix parameter transfer for image filter settings | number[] | yes | iOS/Android | yes | - - -### Supported filters - -| Component | Additional props | function | -| ---------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| ColorMatrix | matrix: Matrix | - | -| Normal | - | normal(): Matrix | -| RGBA | red: number = 1, green: number = 1, blue: number = 1, alpha: number = 1 | rgba(red: number = 1, green: number = 1, blue: number = 1, alpha: number = 1): Matrix | -| Saturate | amount: number = 1 | saturate(amount: number = 1): Matrix | -| HueRotate | amount: number = 0 | hueRotate(amount: number = 0): Matrix | -| LuminanceToAlpha | - | luminanceToAlpha(): Matrix | -| Invert | - | invert(): Matrix | -| Grayscale | amount: number = 1 | grayscale(amount: number = 1): Matrix | -| Sepia | amount: number = 1 | sepia(amount: number = 1): Matrix | -| Nightvision | - | nightvision(): Matrix | -| Warm | - | warm(): Matrix | -| Cool | - | cool(): Matrix | -| Brightness | amount: number = 1 | brightness(amount: number = 1): Matrix | -| Contrast | amount: number = 1 | contrast(amount: number = 1): Matrix | -| Temperature | amount: number = 1 | temperature(amount: number = 1): Matrix | -| Tint | amount: number = 0 | tint(amount: number = 0): Matrix | -| Threshold | amount: number = 0 | threshold(amount: number = 0): Matrix | -| Technicolor | - | technicolor(): Matrix | -| Polaroid | - | polaroid(): Matrix | -| ToBGR | - | toBGR(): Matrix | -| Kodachrome | - | kodachrome(): Matrix | -| Browni | - | browni(): Matrix | -| Vintage | - | vintage(): Matrix | -| Night | amount: number = 0.1 | night(amount: number = 0.1): Matrix | -| Predator | amount: number = 1 | predator(amount: number = 1): Matrix | -| Lsd | - | lsd(): Matrix | -| ColorTone | desaturation: number = 0.2, toned: number = 0.15, lightColor: string = "#FFE580", darkColor: string = "#338000" | colorTone(desaturation: number = 0.2, toned: number = 0.15, lightColor: string = "#FFE580", darkColor: string = "#338000"): Matrix | -| DuoTone | firstColor: string = "#FFE580", secondColor: string = "#338000" | duoTone(firstColor: string = "#FFE580", secondColor: string = "#338000"): Matrix | -| Protanomaly | - | protanomaly(): Matrix | -| Deuteranomaly | - | deuteranomaly(): Matrix | -| Tritanomaly | - | tritanomaly(): Matrix | -| Protanopia | - | protanopia(): Matrix | -| Deuteranopia | - | deuteranopia(): Matrix | -| Tritanopia | - | tritanopia(): Matrix | -| Achromatopsia | - | achromatopsia(): Matrix | -| Achromatomaly | - | achromatomaly(): Matrix - - -## 遗留问题 - -## 其他 - -## 开源协议 - -本项目基于 [The MIT License (MIT)](https://github.com/iyegoroff/react-native-color-matrix-image-filters/blob/master/LICENSE) ,请自由地享受和参与开源。 - +> 模板版本:v0.2.0 + +

+

react-native-color-matrix-image-filters

+

+

+ + Supported platforms + + + License + +

+ +> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-color-matrix-image-filters) + +## 安装与使用 + +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 6.0.5 | [@react-native-oh-tpl/react-native-color-matrix-image-filters Releases](https://github.com/react-native-oh-library/react-native-color-matrix-image-filters/releases) | 0.72 | +| 7.0.2 | [@react-native-ohos/react-native-color-matrix-image-filters Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 + +进入到工程目录并输入以下命令: + + + +#### **npm** + +```bash +# V6.0.5 +npm install @react-native-oh-tpl/react-native-color-matrix-image-filters + +# V7.0.2 +npm install @react-native-ohos/react-native-color-matrix-image-filters +``` + +#### **yarn** + +```bash +# V6.0.5 +yarn add @react-native-oh-tpl/react-native-color-matrix-image-filters + +# V7.0.2 +yarn add @react-native-ohos/react-native-color-matrix-image-filters +``` + + + +下面的代码展示了这个库的基本使用场景: + +> [!WARNING] 使用时 import 的库名不变。 + +```js +import { + Achromatomaly, + Achromatopsia, + Brightness +} from 'react-native-color-matrix-image-filters'; +import React from 'react'; +import { View, StyleSheet, Image } from 'react-native'; + +export const ColorMatrixImageFiltersTest = () => { + + return ( + + + + + + + + + + ) +} + +const styles = StyleSheet.create({ + image: { + width: 150, + height: 100, + justifyContent: 'center', + alignItems: 'center' + } +}) +``` + +## Link + +目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 + +首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony` + +### 在工程根目录的 `oh-package.json5` 添加 overrides字段 + +```json +{ + ... + "overrides": { + "@rnoh/react-native-openharmony" : "./react_native_openharmony" + } +} +``` + +### 2.引入原生端代码 + +目前有两种方法: + +1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法); +2. 直接链接源码。 + +方法一:通过 har 包引入 + +> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。 + +打开 `entry/oh-package.json5`,添加以下依赖 + +- V6.0.5 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-color-matrix-image-filters": "file:../../node_modules/@react-native-oh-tpl/react-native-color-matrix-image-filters/harmony/color_matrix_image_filters.har" + } +``` + +- V7.0.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-color-matrix-image-filters": "file:../../node_modules/@react-native-ohos/react-native-color-matrix-image-filters/harmony/color_matrix_image_filters.har" + } +``` + +点击右上角的 `sync` 按钮 + +或者在终端执行: + +```bash +cd entry +ohpm install +``` + +方法二:直接链接源码 + +> [!TIP] 源码位于三方库安装路径的 `harmony` 文件夹下。 + +打开 `entry/oh-package.json5`,添加以下依赖 + +- V6.0.5 + +```json +"dependencies": { +"@rnoh/react-native-openharmony": "file:../react_native_openharmony", +"@react-native-ohos/react-native-color-matrix-image-filters": "file:../../node_modules/@react-native-oh-tpl/react-native-color-matrix-image-filters/harmony/color_matrix_image_filters" + } +``` + +- V7.0.2 + +```json +"dependencies": { +"@rnoh/react-native-openharmony": "file:../react_native_openharmony", +"@react-native-ohos/react-native-color-matrix-image-filters": "file:../../node_modules/@react-native-ohos/react-native-color-matrix-image-filters/harmony/color_matrix_image_filters" + } +``` + +打开终端,执行: + +```bash +cd entry +ohpm install --no-link +``` + +### 3.配置 CMakeLists 和引入 ColorMatrixImageFiltersPackage + +打开 `entry/src/main/cpp/CMakeLists.txt`,添加: + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") +set(LOG_VERBOSITY_LEVEL 1) +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use +add_compile_definitions(WITH_HITRACE_SYSTRACE) + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V6.0.5 ++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-color-matrix-image-filters/src/main/cpp" ./color_matrix_image_filters) + +# V7.0.2 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-color-matrix-image-filters/src/main/cpp" ./color_matrix_image_filters) + +# RNOH_END: manual_package_linking_1 + +file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") + +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++ target_link_libraries(rnoh_app PUBLIC rnoh_color_matrix_image_filters ) +# RNOH_END: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "generated/RNOHGeneratedPackage.h" +#include "SamplePackage.h" ++ #include "ColorMatrixImageFiltersPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), + std::make_shared(ctx), ++ std::make_shared(ctx) + }; +} +``` + + +### 4.运行 + +点击右上角的 `sync` 按钮 + +或者在终端执行: + +```bash +cd entry +ohpm install +``` + +然后编译、运行即可。 + +## 约束与限制 + +### 兼容性 + +要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 + +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 6.0.5 | [@react-native-oh-tpl/react-native-color-matrix-image-filters Releases](https://github.com/react-native-oh-library/react-native-color-matrix-image-filters/releases) | 0.72 | +| 7.0.2 | [@react-native-ohos/react-native-color-matrix-image-filters Releases]() | 0.77 | + + +## 属性 + +> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。 + +> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 + +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ---- | ----------- | ---- | -------- | -------- | ------------------ | +| matrix | Matrix parameter transfer for image filter settings | number[] | yes | iOS/Android | yes | + + +### Supported filters + +| Component | Additional props | function | +| ---------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| ColorMatrix | matrix: Matrix | - | +| Normal | - | normal(): Matrix | +| RGBA | red: number = 1, green: number = 1, blue: number = 1, alpha: number = 1 | rgba(red: number = 1, green: number = 1, blue: number = 1, alpha: number = 1): Matrix | +| Saturate | amount: number = 1 | saturate(amount: number = 1): Matrix | +| HueRotate | amount: number = 0 | hueRotate(amount: number = 0): Matrix | +| LuminanceToAlpha | - | luminanceToAlpha(): Matrix | +| Invert | - | invert(): Matrix | +| Grayscale | amount: number = 1 | grayscale(amount: number = 1): Matrix | +| Sepia | amount: number = 1 | sepia(amount: number = 1): Matrix | +| Nightvision | - | nightvision(): Matrix | +| Warm | - | warm(): Matrix | +| Cool | - | cool(): Matrix | +| Brightness | amount: number = 1 | brightness(amount: number = 1): Matrix | +| Contrast | amount: number = 1 | contrast(amount: number = 1): Matrix | +| Temperature | amount: number = 1 | temperature(amount: number = 1): Matrix | +| Tint | amount: number = 0 | tint(amount: number = 0): Matrix | +| Threshold | amount: number = 0 | threshold(amount: number = 0): Matrix | +| Technicolor | - | technicolor(): Matrix | +| Polaroid | - | polaroid(): Matrix | +| ToBGR | - | toBGR(): Matrix | +| Kodachrome | - | kodachrome(): Matrix | +| Browni | - | browni(): Matrix | +| Vintage | - | vintage(): Matrix | +| Night | amount: number = 0.1 | night(amount: number = 0.1): Matrix | +| Predator | amount: number = 1 | predator(amount: number = 1): Matrix | +| Lsd | - | lsd(): Matrix | +| ColorTone | desaturation: number = 0.2, toned: number = 0.15, lightColor: string = "#FFE580", darkColor: string = "#338000" | colorTone(desaturation: number = 0.2, toned: number = 0.15, lightColor: string = "#FFE580", darkColor: string = "#338000"): Matrix | +| DuoTone | firstColor: string = "#FFE580", secondColor: string = "#338000" | duoTone(firstColor: string = "#FFE580", secondColor: string = "#338000"): Matrix | +| Protanomaly | - | protanomaly(): Matrix | +| Deuteranomaly | - | deuteranomaly(): Matrix | +| Tritanomaly | - | tritanomaly(): Matrix | +| Protanopia | - | protanopia(): Matrix | +| Deuteranopia | - | deuteranopia(): Matrix | +| Tritanopia | - | tritanopia(): Matrix | +| Achromatopsia | - | achromatopsia(): Matrix | +| Achromatomaly | - | achromatomaly(): Matrix + + +## 遗留问题 + +## 其他 + +## 开源协议 + +本项目基于 [The MIT License (MIT)](https://github.com/iyegoroff/react-native-color-matrix-image-filters/blob/master/LICENSE) ,请自由地享受和参与开源。 + diff --git a/zh-cn/react-native-community-geolocation.md b/zh-cn/react-native-community-geolocation.md index 7774b0ae5d981948aa8acdcedb3ae460dd6dfead..8545039e750219571c7b4c7a17c2fb96420952c9 100644 --- a/zh-cn/react-native-community-geolocation.md +++ b/zh-cn/react-native-community-geolocation.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/geolocation Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.0 | [@react-native-oh-tpl/geolocation Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases) | 0.72 | +| 3.4.0 | [@react-native-ohos/geolocation Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,21 @@ #### **npm** ```bash +# V3.1.0 npm install @react-native-oh-tpl/geolocation + +# V3.4.0 +npm install @react-native-ohos/geolocation ``` #### **yarn** ```bash +# V3.1.0 yarn add @react-native-oh-tpl/geolocation + +# V3.4.0 +yarn add @react-native-ohos/geolocation ``` @@ -90,6 +105,8 @@ export function GeolocationDemo(): JSX.Element { 打开 `entry/oh-package.json5`,添加以下依赖 +- V3.1.0 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -97,6 +114,15 @@ export function GeolocationDemo(): JSX.Element { } ``` +- V3.4.0 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/geolocation": "file:../../node_modules/@react-native-ohos/geolocation/harmony/geolocation.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -132,7 +158,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V3.1.0 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/geolocation/src/main/cpp" ./geolocation) + +# V3.4.0 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/geolocation/src/main/cpp" ./geolocation) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -174,8 +206,12 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... +// V3.1.0 + import {GeoLocationPackage} from '@react-native-oh-tpl/geolocation/ts'; +// V3.4.0 ++ import {GeoLocationPackage} from '@react-native-ohos/geolocation/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -203,7 +239,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/geolocation Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.0 | [@react-native-oh-tpl/geolocation Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases) | 0.72 | +| 3.4.0 | [@react-native-ohos/geolocation Releases]() | 0.77 | ### 权限要求 diff --git a/zh-cn/react-native-config.md b/zh-cn/react-native-config.md index c6bea5e260461bd713d696b31b8ea2d437779ed0..fd28357c6f3dca4e88c96ec62afe1fd7034a68cb 100644 --- a/zh-cn/react-native-config.md +++ b/zh-cn/react-native-config.md @@ -30,20 +30,35 @@ Config.GOOGLE_MAPS_API_KEY; // 'abcdefgh' ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-library/react-native-config Releases](https://github.com/react-native-oh-library/react-native-config/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.5.3 | [@react-native-oh-library/react-native-config Releases](https://github.com/react-native-oh-library/react-native-config/releases) | 0.72 | +| 1.5.5 | [@react-native-oh-library/react-native-config Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: #### npm ```bash +# V1.5.3 npm install @react-native-oh-tpl/react-native-config + +# V1.5.5 +npm install @react-native-ohos/react-native-config ``` #### yarn ```bash +# V1.5.3 yarn add @react-native-oh-tpl/react-native-config + +# V1.5.5 +yarn add @react-native-ohos/react-native-config ``` @@ -51,7 +66,7 @@ yarn add @react-native-oh-tpl/react-native-config > [!WARNING] 使用时 import 的库名不变。 -``` +```js import React, {Component} from 'react'; import {StyleSheet, Text, View} from 'react-native'; @@ -86,6 +101,8 @@ const styles = StyleSheet.create({ 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 +**注意**: V1.5.5 不需要执行Codegen。 + ## Link 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -113,7 +130,7 @@ const styles = StyleSheet.create({ > [!TIP] 源码位于三方库安装路径的 `harmony` 文件夹下。 -把`/node_modules/@react-native-oh-tpl/react-native-config/harmony/`目录下的源码``复制到`harmony`工程根目录下 +把`/node_modules/@react-native-oh-tpl/react-native-config/harmony/` (V1.5.3)或 `/node_modules/@react-native-ohos/react-native-config/harmony/`(V1.5.5)目录下的源码``复制到`harmony`工程根目录下 在`harmony`工程根目录的 `build-profile.template.json5`(若存在)和`build-profile.json5` 添加以下模块 @@ -129,6 +146,8 @@ modules:[ 打开 `entry/oh-package.json5`,添加以下依赖 +- V1.5.3 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -136,6 +155,17 @@ modules:[ } ``` +- V1.5.5 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-config": "file:../config" + } +``` + + + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -145,15 +175,85 @@ cd entry ohpm install ``` -### 3.在 ArkTs 侧引入 RNConfigPackage +### 3.配置CMakeLists和引入RNConfigPackage + +>注:仅这个V1.5.5需要配置CMakeLists和引入RNConfigPackage + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") +set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp") +set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated") +set(LOG_VERBOSITY_LEVEL 1) +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") +set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") + +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use +add_compile_definitions(WITH_HITRACE_SYSTRACE) + +# (VM) Define a variable and assign it to the current module's cpp directory +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +# Add the Header File directory, including cpp, cpp/include, and tell cmake to find the Header Files introduced by the code here +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-config/src/main/cpp" ./config) +file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) +target_link_libraries(rnoh_app PUBLIC rnoh) ++ target_link_libraries(rnoh_app PUBLIC rnoh_config) +``` + +打开`entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" ++ #include"RNConfigPackage.h" +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) +{ + return { ++ std::make_shared(ctx) + }; +} +``` + +在工程目录下打开`hvigorfile.ts` ,替换为: + +```diff +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, + plugins: [] +} +``` + +### 4.在 ArkTs 侧引入 RNConfigPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff import type { RNPackageContext, RNPackage } from 'rnoh/ts'; ... +// V1.5.3 + import { RNConfigPackage } from '@react-native-oh-tpl/react-native-config/ts'; +// V1.5.5 ++ import { RNConfigPackage } from '@react-native-ohos/react-native-config/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -162,7 +262,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -226,7 +326,12 @@ set ENVFILE=.env.staging&&"D:\DevEcoStudio\tools\node\node.exe" "D:\DevEcoStudio 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-library/react-native-config Releases](https://github.com/react-native-oh-library/react-native-config/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.5.3 | [@react-native-oh-library/react-native-config Releases](https://github.com/react-native-oh-library/react-native-config/releases) | 0.72 | +| 1.5.5 | [@react-native-oh-library/react-native-config Releases]() | 0.77 | ## 属性 diff --git a/zh-cn/react-native-document-picker.md b/zh-cn/react-native-document-picker.md index 5e1198ab8e2e609e16e4aa9cecf629d64ad67e72..c3eefe674df1f13bae160ad9b0c581f5f667751d 100644 --- a/zh-cn/react-native-document-picker.md +++ b/zh-cn/react-native-document-picker.md @@ -9,10 +9,11 @@ 该第三方库的仓库已迁移至 Gitee,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-document-picker`,具体版本所属关系如下: -| Version | Package Name | Repository | Release | -| ------------------------------ | ---------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| <= 9.2.0@deprecated | @react-native-oh-tpl/react-native-document-picker | [Github(deprecated)](https://github.com/react-native-oh-library/document-picker) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/document-picker/releases) | -| > 9.2.0 | @react-native-ohos/react-native-document-picker | [Gitcode](https://gitcode.com/openharmony-sig/rntpc_react-native-document-picker) | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-document-picker/releases) | +| Version | Package Name | Repository | Release | Support RN Version | +| ------------------------------ | ---------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| <= 9.2.0@deprecated | @react-native-oh-tpl/react-native-document-picker | [Github(deprecated)](https://github.com/react-native-oh-library/document-picker) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/document-picker/releases) | 0.72 | +| > 9.2.0 | @react-native-ohos/react-native-document-picker | [Gitcode](https://gitcode.com/openharmony-sig/rntpc_react-native-document-picker) | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-document-picker/releases) | 0.72 | +| 9.3.1 | @react-native-ohos/react-native-document-picker | [Gitcode](https://gitcode.com/openharmony-sig/rntpc_react-native-document-picker) | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-document-picker/releases) | 0.77 | ## 1. 安装与使用 diff --git a/zh-cn/react-native-image-gallery.md b/zh-cn/react-native-image-gallery.md index b3b86628dfc33cce42423768a3b73e3db3321fa5..d0131f7ef9ca0bccc5d412c193e86c55de709501 100644 --- a/zh-cn/react-native-image-gallery.md +++ b/zh-cn/react-native-image-gallery.md @@ -18,7 +18,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-image-gallery Releases](https://github.com/react-native-oh-library/react-native-image-gallery/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.1.5 | [@react-native-oh-tpl/react-native-image-gallery Releases](https://github.com/react-native-oh-library/react-native-image-gallery/releases) | 0.72 | +| 2.1.5 | [@react-native-ohos/react-native-image-gallery Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -27,13 +34,21 @@ #### **npm** ```bash +# V2.1.5 for RN0.72 npm i @react-native-oh-tpl/react-native-image-gallery + +# V2.1.5 for RN0.77 +npm i @react-native-ohos/react-native-image-gallery ``` #### **yarn** ```bash +# V2.1.5 for RN0.72 yarn add @react-native-oh-tpl/react-native-image-gallery + +# V2.1.5 for RN0.77 +yarn add @react-native-ohos/react-native-image-gallery ``` @@ -65,24 +80,29 @@ import Gallery from 'react-native-image-gallery'; 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-image-gallery Releases](https://github.com/react-native-oh-library/react-native-image-gallery/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.1.5 | [@react-native-oh-tpl/react-native-image-gallery Releases](https://github.com/react-native-oh-library/react-native-image-gallery/releases) | 0.72 | +| 2.1.5 | [@react-native-ohos/react-native-image-gallery Releases]() | 0.77 | #### 属性 -| Prop | Description | Type | Default | Platform | HarmonyOS Support | -| --------------------- | --------------------- | -------- | -------- |----------|-------------------| -`images` | Your array of images | `array` | Required | all | yes | -`initialPage` | Image displayed first | `number` | `0`| all | yes | -`imageComponent` | Custom function to render your images, 1st param is the image props, 2nd is its dimensions | `function` | `` component| all | yes | -`errorComponent` | Custom function to render the page of an image that couldn't be displayed | `function` | A `` with a stylized error| all | yes | -`flatListProps` | Props to be passed to the underlying `FlatList` | `object` | `{windowSize: 3}`| all | yes | -`pageMargin` | Blank space to show between images | `number` | `0`| all | yes | -`onPageSelected` | Fired with the index of page that has been selected | `function`| | all | yes | -`onPageScrollStateChanged` | Called when page scrolling state has changed, see [scroll state and events](#scroll-state-and-events) | `function`| | all | yes | -`onPageScroll` | Scroll event, see [scroll state and events](#scroll-state-and-events) | `function`| | all | yes | -`scrollViewStyle` | Custom style for the `FlatList` component | `object` | `{}`| all | yes | -`onSingleTapConfirmed` | Fired after a single tap | `function`| | all | yes | -`onLongPress` | Fired after a long press | `function`| | all | yes | +| Prop | Description | Type | Default | Platform | HarmonyOS Support | +| -------------------------- | ------------------------------------------------------------ | ---------- | -------------------------------- | -------- | ----------------- | +| `images` | Your array of images | `array` | Required | all | yes | +| `initialPage` | Image displayed first | `number` | `0` | all | yes | +| `imageComponent` | Custom function to render your images, 1st param is the image props, 2nd is its dimensions | `function` | `` component | all | yes | +| `errorComponent` | Custom function to render the page of an image that couldn't be displayed | `function` | A `` with a stylized error | all | yes | +| `flatListProps` | Props to be passed to the underlying `FlatList` | `object` | `{windowSize: 3}` | all | yes | +| `pageMargin` | Blank space to show between images | `number` | `0` | all | yes | +| `onPageSelected` | Fired with the index of page that has been selected | `function` | | all | yes | +| `onPageScrollStateChanged` | Called when page scrolling state has changed, see [scroll state and events](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-image-gallery.md#scroll-state-and-events) | `function` | | all | yes | +| `onPageScroll` | Scroll event, see [scroll state and events](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-image-gallery.md#scroll-state-and-events) | `function` | | all | yes | +| `scrollViewStyle` | Custom style for the `FlatList` component | `object` | `{}` | all | yes | +| `onSingleTapConfirmed` | Fired after a single tap | `function` | | all | yes | +| `onLongPress` | Fired after a long press | `function` | | all | yes | ## 遗留问题 diff --git a/zh-cn/react-native-image-header-scroll-view.md b/zh-cn/react-native-image-header-scroll-view.md index 98c8ed744726aeecacd39b5ae59e96f443c17da8..01124428a739887352c2e368db6300230fa8d25e 100644 --- a/zh-cn/react-native-image-header-scroll-view.md +++ b/zh-cn/react-native-image-header-scroll-view.md @@ -20,7 +20,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-image-header-scroll-view Releases](https://github.com/react-native-oh-library/react-native-image-header-scroll-view/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 0.10.3 | [@react-native-oh-tpl/react-native-image-header-scroll-view Releases](https://github.com/react-native-oh-library/react-native-image-header-scroll-view/releases) | 0.72 | +| 1.0.0 | [@react-native-ohos/react-native-image-header-scroll-view Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -30,13 +37,21 @@ #### **npm** ```bash +# V0.10.3 npm install @react-native-oh-tpl/react-native-image-header-scroll-view + +# V1.0.0 +npm install @react-native-ohos/react-native-image-header-scroll-view ``` #### **yarn** ```bash +# V0.10.3 yarn add @react-native-oh-tpl/react-native-image-header-scroll-view + +# V1.0.0 +yarn add @react-native-ohos/react-native-image-header-scroll-view ``` @@ -231,7 +246,12 @@ export default HeaderImageExample; 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-image-header-scroll-view Releases](https://github.com/react-native-oh-library/react-native-image-header-scroll-view/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 0.10.3 | [@react-native-oh-tpl/react-native-image-header-scroll-view Releases](https://github.com/react-native-oh-library/react-native-image-header-scroll-view/releases) | 0.72 | +| 1.0.0 | [@react-native-ohos/react-native-image-header-scroll-view Releases]() | 0.77 | ## API diff --git a/zh-cn/react-native-iphone-screen-helper.md b/zh-cn/react-native-iphone-screen-helper.md index 008f47098f1b8282eff47e598d8bb4983c72014c..eb07489ffc490cacfe99e729f7e947ab1a2c4e80 100644 --- a/zh-cn/react-native-iphone-screen-helper.md +++ b/zh-cn/react-native-iphone-screen-helper.md @@ -21,7 +21,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-iphone-screen-helper Releases](https://github.com/react-native-oh-library/react-native-iphone-screen-helper/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.1.1 | [@react-native-oh-tpl/react-native-iphone-screen-helper Releases](https://github.com/react-native-oh-library/react-native-iphone-screen-helper/releases) | 0.72 | +| 2.1.2 | [@react-native-ohos/react-native-iphone-screen-helper Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -30,13 +37,21 @@ #### **npm** ```bash +# V2.1.1 npm install @react-native-oh-tpl/react-native-iphone-screen-helper + +# V2.1.2 +npm install @react-native-ohos/react-native-iphone-screen-helper ``` #### **yarn** ```bash +# V2.1.1 yarn add @react-native-oh-tpl/react-native-iphone-screen-helper + +# V2.1.2 +yarn add @react-native-ohos/react-native-iphone-screen-helper ``` @@ -74,7 +89,12 @@ export default ScreenHelperDemo; 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-iphone-screen-helper Releases](https://github.com/react-native-oh-library/react-native-iphone-screen-helper/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.1.1 | [@react-native-oh-tpl/react-native-iphone-screen-helper Releases](https://github.com/react-native-oh-library/react-native-iphone-screen-helper/releases) | 0.72 | +| 2.1.2 | [@react-native-ohos/react-native-iphone-screen-helper Releases]() | 0.77 | ## API diff --git a/zh-cn/react-native-localization-settings.md b/zh-cn/react-native-localization-settings.md index 2935eb390744f84e56ba97bc9650688f14c544f9..569cfc495df9642e2d2bacade305608c5aaaf909 100644 --- a/zh-cn/react-native-localization-settings.md +++ b/zh-cn/react-native-localization-settings.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-localization-settings Releases](https://github.com/react-native-oh-library/react-native-localization-settings/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.0.2 | [@react-native-oh-tpl/react-native-localization-settings Releases](https://github.com/react-native-oh-library/react-native-localization-settings/releases) | 0.72 | +| 1.2.0 | [@react-native-ohos/react-native-localization-settings Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -26,13 +33,21 @@ #### **npm** ```bash +# V1.0.2 npm install @react-native-oh-tpl/react-native-localization-settings + +# V1.2.0 +npm install @react-native-ohos/react-native-localization-settings ``` #### **yarn** ```bash +# V1.0.2 yarn add @react-native-oh-tpl/react-native-localization-settings + +# V1.2.0 +yarn add @react-native-ohos/react-native-localization-settings ``` @@ -46,12 +61,25 @@ yarn add @react-native-oh-tpl/react-native-localization-settings ```js import * as React from "react"; import { StyleSheet, View, Text, Button } from "react-native"; + +// V1.0.2 import { ReactNativeLanguageDetector } from "react-native-localization-settings"; + +// V1.2.0 +import { createLanguageDetector } from "react-native-localization-settings"; + import i18next from "i18next"; import { initReactI18next, useTranslation } from "react-i18next"; +// V1.2.0 +const detector = createLanguageDetector({ async: true, cacheCurrentLanguage: false }); i18next + // V1.0.2 + .use(ReactNativeLanguageDetector) + + // V1.2.0 .use(ReactNativeLanguageDetector) + .use(initReactI18next) .init({ resources: { @@ -119,6 +147,8 @@ const styles = StyleSheet.create({ 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 +**注意:** V1.2.0 不需要执行Codegen。 + ## Link 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -149,6 +179,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +- V1.0.2 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -156,6 +188,15 @@ const styles = StyleSheet.create({ } ``` +- V1.2.0 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-localization-settings": "file:../../node_modules/@react-native-ohos/react-native-localization-settings/harmony/localization_settings.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -169,14 +210,65 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 RNLocalizationSettingsPackage +### 3. 配置 CMakeLists 和引入 RNLocalizationSettingsPackage + +> V1.2.0 需要配置 CMakeLists 和引入 RNLocalizationSettingsPackage。 + +```diff +... + +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_END: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-localization-settings/src/main/cpp" ./localization-settings) +# RNOH_END: manual_package_linking_1 + +add_library(rnoh_app SHARED + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) + +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++target_link_libraries(rnoh_app PUBLIC rnoh_localization_settings) +# RNOH_BEGIN: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" ++ #include "LocalizationSettingsPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { ++ std::make_shared(ctx) +} +``` + +### 4.在 ArkTs 侧引入 RNLocalizationSettingsPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... +// V1.0.2 + import {RNLocalizationSettingsPackage} from '@react-native-oh-tpl/react-native-localization-settings/ts'; +// V1.2.0 ++ import {RNLocalizationSettingsPackage} from '@react-native-ohos/react-native-localization-settings/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -185,7 +277,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -204,7 +296,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-localization-settings Releases](https://github.com/react-native-oh-tpl/react-native-localization-settings/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.0.2 | [@react-native-oh-tpl/react-native-localization-settings Releases](https://github.com/react-native-oh-tpl/react-native-localization-settings/releases) | 0.72 | +| 1.2.0 | [@react-native-ohos/react-native-localization-settings Releases]() | 0.77 | ## 静态方法 @@ -214,11 +311,13 @@ ohpm install > [!TIP] 在设置改变语言之前,确保手机系统添加相应语言 -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| -------------------------- | ------------------------------------- | -------- | -------- | ----------- | ----------------- | -| I18nLanguageDetectorModule | i18next language detector | function | no | iOS/Android | yes | -| getLanguage() | Function to get current language. | function | no | iOS/Android | yes | -| setLanguage() | Function to set the current language. | function | no | iOS/Android | yes | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ---------------------------------------------------------- | ------------------------------------- | -------- | -------- | ----------- | ----------------- | +| I18nLanguageDetectorModuledeprecated from 1.2.0 | i18next language detector | function | no | iOS/Android | yes | +| getLanguage() | Function to get current language. | function | no | iOS/Android | yes | +| setLanguage() | Function to set the current language. | function | no | iOS/Android | yes | +| createLanguageDetector()1.2.0+ | i18next language detector generator. | function | no | all | yes | +| getLanguageAsync()1.2.0+ | Function to get current language. | function | no | all | yes | ## 遗留问题 diff --git a/zh-cn/react-native-localize.md b/zh-cn/react-native-localize.md index a76cb978f832b935503dc3777cea48df321b786e..2914909dd39c82d78e2a0cff71747deae517a3e4 100644 --- a/zh-cn/react-native-localize.md +++ b/zh-cn/react-native-localize.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-localize Releases](https://github.com/react-native-oh-library/react-native-localize/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.0 | [@react-native-oh-tpl/react-native-localize Releases](https://github.com/react-native-oh-library/react-native-localize/releases) | 0.72 | +| 3.4.1 | [@react-native-ohos/react-native-localize Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -27,13 +34,21 @@ #### **npm** ```bash +# V3.1.0 npm install @react-native-oh-tpl/react-native-localize + +# V3.4.1 +npm install @react-native-ohos/react-native-localize ``` #### **yarn** ```bash +# V3.1.0 yarn add @react-native-oh-tpl/react-native-localize + +# V3.4.1 +yarn add @react-native-ohos/react-native-localize ``` @@ -117,6 +132,8 @@ export default LocalizeDemo; 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 +**注意:** V3.4.1 不需要执行 Codegen。 + ## Link 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -147,6 +164,8 @@ export default LocalizeDemo; 打开 `entry/oh-package.json5`,添加以下依赖 +- V3.1.0 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -154,6 +173,15 @@ export default LocalizeDemo; } ``` +- V3.4.1 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-localize": "file:../../node_modules/@react-native-ohos/react-native-localize/harmony/rn_localize.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -167,15 +195,63 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 RNLocalizePackage +### 3. 配置 CMakeLists 和引入 RNLocalizePackage(仅V3.4.1 需要) + +```diff +... + +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_END: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-localize/src/main/cpp" ./rn_localize) +# RNOH_END: manual_package_linking_1 + +add_library(rnoh_app SHARED + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) + +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++ target_link_libraries(rnoh_app PUBLIC rnoh_localize) +# RNOH_BEGIN: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" ++ #include "RNLocalizePackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { ++ std::make_shared(ctx) +} +``` + +### 4.在 ArkTs 侧引入 RNLocalizePackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... - +// V3.1.0 + import { RNLocalizePackage } from '@react-native-oh-tpl/react-native-localize/ts'; +// V3.4.1 ++ import { RNLocalizePackage } from '@react-native-ohos/react-native-localize/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -184,7 +260,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -203,7 +279,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-localize Releases](https://github.com/react-native-oh-library/react-native-localize/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.0 | [@react-native-oh-tpl/react-native-localize Releases](https://github.com/react-native-oh-library/react-native-localize/releases) | 0.72 | +| 3.4.1 | [@react-native-ohos/react-native-localize Releases]() | 0.77 | ## API @@ -212,20 +293,21 @@ ohpm install > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 -| Name | Description | Required | Platform | HarmonyOS Support | -|---------------------------| ---------------------------------------------- | -------- |----------|-------------------| -| getLocales() | Returns the user preferred locales, in order. | No | All | yes | -| getNumberFormatSettings() | Returns number formatting settings. | No | All | yes | -| getCurrencies() | Returns the user preferred currency codes, in order. | No | All | yes | -| getCountry() | Returns the user current country code (based on its device locale, not on its position). | No | All | yes | -| getCalendar() | Returns the user preferred calendar format. | No | All | yes | -| getTemperatureUnit() | Returns the user preferred temperature unit. | No | All | No | -| getTimeZone() | Returns the user preferred timezone (based on its device settings, not on its position). | No | All | yes | -| uses24HourClock() | Returns true if the user prefers 24h clock format, false if they prefer 12h clock format. | No | All | yes | -| usesMetricSystem() | Returns true if the user prefers metric measure system, false if they prefer imperial. | No | All | No | -| usesAutoDateAndTime() | Tells if the automatic date & time setting is enabled on the phone. Android only | No | Android | No | -| usesAutoTimeZone() | Tells if the automatic time zone setting is enabled on the phone. Android only | No | Android | No | -| findBestLanguageTag() | Returns the best language tag possible and its reading direction | No | All | yes | +| Name | Description | Required | Platform | HarmonyOS Support | +| ---------------------------------------- | ------------------------------------------------------------ | -------- | -------- | ----------------- | +| getLocales() | Returns the user preferred locales, in order. | No | All | yes | +| getNumberFormatSettings() | Returns number formatting settings. | No | All | yes | +| getCurrencies() | Returns the user preferred currency codes, in order. | No | All | yes | +| getCountry() | Returns the user current country code (based on its device locale, not on its position). | No | All | yes | +| getCalendar() | Returns the user preferred calendar format. | No | All | yes | +| getTemperatureUnit() | Returns the user preferred temperature unit. | No | All | No | +| getTimeZone() | Returns the user preferred timezone (based on its device settings, not on its position). | No | All | yes | +| uses24HourClock() | Returns true if the user prefers 24h clock format, false if they prefer 12h clock format. | No | All | yes | +| usesMetricSystem() | Returns true if the user prefers metric measure system, false if they prefer imperial. | No | All | No | +| usesAutoDateAndTime() | Tells if the automatic date & time setting is enabled on the phone. Android only | No | Android | No | +| usesAutoTimeZone() | Tells if the automatic time zone setting is enabled on the phone. Android only | No | Android | No | +| findBestLanguageTag() | Returns the best language tag possible and its reading direction | No | All | yes | +| openAppLanguageSettings3.4.1+ | Opens the app language settings. | No | Android | No | ## 遗留问题 - [ ] HarmonyOS 侧无法获取温度及长度单位[issue#2](https://github.com/react-native-oh-library/react-native-localize/issues/2) diff --git a/zh-cn/react-native-mmkv-storage.md b/zh-cn/react-native-mmkv-storage.md index 93e436260e957990e23b3ad3c8b39e328fc68dea..cd92828420b331cdd50122cb9f7a2ad2fab6170c 100644 --- a/zh-cn/react-native-mmkv-storage.md +++ b/zh-cn/react-native-mmkv-storage.md @@ -19,7 +19,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-mmkv-storage Releases](https://github.com/react-native-oh-library/react-native-mmkv-storage/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 0.10.3 | [@react-native-oh-tpl/react-native-mmkv-storage Releases](https://github.com/react-native-oh-library/react-native-mmkv-storage/releases) | 0.72 | +| 0.11.2 | [@react-native-ohos/react-native-mmkv-storage Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -28,13 +35,21 @@ #### **npm** ```bash +# V0.10.3 npm install @react-native-oh-tpl/react-native-mmkv-storage + +# V0.11.2 +npm install @react-native-ohos/react-native-mmkv-storage ``` #### **yarn** ```bash +# V0.10.3 yarn add @react-native-oh-tpl/react-native-mmkv-storage + +# V0.11.2 +yarn add @react-native-ohos/react-native-mmkv-storage ``` @@ -223,6 +238,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +- V0.10.3 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -230,6 +247,15 @@ const styles = StyleSheet.create({ } ``` +- V0.11.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-mmkv-storage": "file:../../node_modules/@react-native-ohos/react-native-mmkv-storage/harmony/mmkv_storage.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -265,7 +291,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V0.10.3 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-mmkv-storage/src/main/cpp" ./mmkv-storage) + +# V0.11.2 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-mmkv-storage/src/main/cpp" ./mmkv-storage) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -312,8 +344,12 @@ std::vector> PackageProvider::getPackages(Package::Cont 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff +// V0.10.3 + import {RNMMKVStoragePackage} from '@react-native-oh-tpl/react-native-mmkv-storage' +// V0.11.2 ++ import {RNMMKVStoragePackage} from '@react-native-ohos/react-native-mmkv-storage' + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -342,7 +378,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-mmkv-storage Releases](https://github.com/react-native-oh-library/react-native-mmkv-storage/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 0.10.3 | [@react-native-oh-tpl/react-native-mmkv-storage Releases](https://github.com/react-native-oh-library/react-native-mmkv-storage/releases) | 0.72 | +| 0.11.2 | [@react-native-ohos/react-native-mmkv-storage Releases]() | 0.77 | ### 权限要求 diff --git a/zh-cn/react-native-pdf.md b/zh-cn/react-native-pdf.md index 342fb589640b8955d4d4beaf641e2b7d59542372..1327c684fb88e67544954826905b7f9efec23eab 100644 --- a/zh-cn/react-native-pdf.md +++ b/zh-cn/react-native-pdf.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-pdf Releases](https://github.com/react-native-oh-library/react-native-pdf/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 6.7.4 | [@react-native-oh-tpl/react-native-pdf Releases](https://github.com/react-native-oh-library/react-native-pdf/releases) | 0.72 | +| 6.7.6 | [@react-native-ohos/react-native-pdf Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,21 @@ #### **npm** ```bash +# V6.7.4 npm install @react-native-oh-tpl/react-native-pdf + +# V6.7.6 +npm install @react-native-ohos/react-native-pdf ``` #### **yarn** ```bash +# V6.7.4 yarn add @react-native-oh-tpl/react-native-pdf + +# V6.7.6 +yarn add @react-native-ohos/react-native-pdf ``` @@ -115,6 +130,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +- V6.7.4 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -122,6 +139,15 @@ const styles = StyleSheet.create({ } ``` +- V6.7.6 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-pdf": "file:../../node_modules/@react-native-ohos/react-native-pdf/harmony/pdfview.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -157,7 +183,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V6.7.4 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-pdf/src/main/cpp" ./pdfview) + +# V6.7.6 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-pdf/src/main/cpp" ./pdfview) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -198,8 +230,12 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... +// V6.7.4 + import { RTNPdfView, PDF_VIEW_TYPE } from '@react-native-oh-tpl/react-native-pdf'; +// V6.7.6 ++ import { RTNPdfView, PDF_VIEW_TYPE } from '@react-native-ohos/react-native-pdf'; + @Builder export function buildCustomRNComponent(ctx: ComponentBuilderContext) { ... @@ -247,7 +283,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-pdf Releases](https://github.com/react-native-oh-library/react-native-pdf/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 6.7.4 | [@react-native-oh-tpl/react-native-pdf Releases](https://github.com/react-native-oh-library/react-native-pdf/releases) | 0.72 | +| 6.7.6 | [@react-native-ohos/react-native-pdf Releases]() | 0.77 | ## 属性 @@ -255,36 +296,38 @@ ohpm install > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- | -------- | ------------- |-------------------| -| source | PDF source like {uri:xxx, cache:false}. see the following for detail. | object | YES | iOS / Android | yes | -| page | initial page index | number | NO | iOS / Android | yes | -| scale | should minScale<=scale<=maxScale | number | NO | iOS / Android | yes | -| minScale | min scale | number | NO | iOS / Android | yes | -| maxScale | max scale | number | NO | iOS / Android | yes | -| horizontal | draw page direction, if you want to listen the orientation change, you can use [[react-native-orientation-locker\]](https://github.com/react-native-oh-library/react-native-orientation-locker) | bool | NO | iOS / Android | no | -| showsHorizontalScrollIndicator | shows or hides the horizontal scroll bar indicator on iOS | bool | NO | iOS | no | -| showsVerticalScrollIndicator | shows or hides the vertical scroll bar indicator on iOS | bool | NO | iOS | no | -| fitWidth | if true fit the width of view, can not use fitWidth=true together with scale | bool | NO | iOS / Android | no | -| fitPolicy | 0:fit width, 1:fit height, 2:fit both(default) | number | NO | iOS / Android | yes | -| spacing | the breaker size between pages | number | NO | iOS / Android | yes | -| password | pdf password, if password error, will call OnError() with message "Password required or incorrect password." | string | NO | iOS / Android | yes | -| style | support normal view style, you can use this to set border/spacing color... | object | NO | iOS / Android | yes | -| renderActivityIndicator | when loading show it as an indicator, you can use your component | (progress) => Component | NO | iOS / Android | no | -| enableAntialiasing | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch | bool | NO | iOS / Android | no | -| enablePaging | only show one page in screen | bool | NO | iOS / Android | no | -| enableRTL | scroll page as "page3, page2, page1" | bool | NO | iOS / Android | no | -| enableAnnotationRendering | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing | bool | NO | iOS | no | -| enableDoubleTapZoom | Enable double tap to zoom gesture | bool | NO | iOS / Android | no | -| trustAllCerts | Allow connections to servers with self-signed certification | bool | NO | iOS / Android | no | -| singlePage | Only show first page, useful for thumbnail views | bool | NO | iOS / Android | no | -| onLoadProgress | callback when loading, return loading progress (0-1) | function(percent) | NO | iOS / Android | yes | -| onLoadComplete | callback when pdf load completed, return total page count, pdf local/cache path, {width,height} and table of contents | function(numberOfPages, path, {width, height}, tableContents) | NO | iOS / Android | partially | -| onPageChanged | callback when page changed ,return current page and total page count | function(page,numberOfPages) | NO | iOS / Android | yes | -| onError | callback when error happened | function(error) | NO | iOS / Android | yes | -| onPageSingleTap | callback when page was single tapped | function(page) | NO | iOS / Android | no | -| onScaleChanged | callback when scale page | function(scale) | NO | iOS / Android | yes | -| onPressLink | callback when link tapped | function(uri) | NO | iOS / Android | yes | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| --------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | ------------- | ----------------- | +| source | PDF source like {uri:xxx, cache:false}. see the following for detail. | object | YES | iOS / Android | yes | +| page | initial page index | number | NO | iOS / Android | yes | +| scale | should minScale<=scale<=maxScale | number | NO | iOS / Android | yes | +| minScale | min scale | number | NO | iOS / Android | yes | +| maxScale | max scale | number | NO | iOS / Android | yes | +| horizontal | draw page direction, if you want to listen the orientation change, you can use [[react-native-orientation-locker\]](https://github.com/react-native-oh-library/react-native-orientation-locker) | bool | NO | iOS / Android | no | +| showsHorizontalScrollIndicator | shows or hides the horizontal scroll bar indicator on iOS | bool | NO | iOS | no | +| showsVerticalScrollIndicator | shows or hides the vertical scroll bar indicator on iOS | bool | NO | iOS | no | +| fitWidth | if true fit the width of view, can not use fitWidth=true together with scale | bool | NO | iOS / Android | no | +| fitPolicy | 0:fit width, 1:fit height, 2:fit both(default) | number | NO | iOS / Android | yes | +| spacing | the breaker size between pages | number | NO | iOS / Android | yes | +| password | pdf password, if password error, will call OnError() with message "Password required or incorrect password." | string | NO | iOS / Android | yes | +| style | support normal view style, you can use this to set border/spacing color... | object | NO | iOS / Android | yes | +| renderActivityIndicator | when loading show it as an indicator, you can use your component | (progress) => Component | NO | iOS / Android | no | +| enableAntialiasing | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch | bool | NO | iOS / Android | no | +| enablePaging | only show one page in screen | bool | NO | iOS / Android | no | +| enableRTL | scroll page as "page3, page2, page1" | bool | NO | iOS / Android | no | +| enableAnnotationRendering | enable rendering annotation, notice:iOS only support initial setting,not support realtime changing | bool | NO | iOS | no | +| enableDoubleTapZoom | Enable double tap to zoom gesture | bool | NO | iOS / Android | no | +| trustAllCerts | Allow connections to servers with self-signed certification | bool | NO | iOS / Android | no | +| singlePage | Only show first page, useful for thumbnail views | bool | NO | iOS / Android | no | +| onLoadProgress | callback when loading, return loading progress (0-1) | function(percent) | NO | iOS / Android | yes | +| onLoadComplete | callback when pdf load completed, return total page count, pdf local/cache path, {width,height} and table of contents | function(numberOfPages, path, {width, height}, tableContents) | NO | iOS / Android | partially | +| onPageChanged | callback when page changed ,return current page and total page count | function(page,numberOfPages) | NO | iOS / Android | yes | +| onError | callback when error happened | function(error) | NO | iOS / Android | yes | +| onPageSingleTap | callback when page was single tapped | function(page) | NO | iOS / Android | no | +| onScaleChanged | callback when scale page | function(scale) | NO | iOS / Android | yes | +| onPressLink | callback when link tapped | function(uri) | NO | iOS / Android | yes | +| scrollEnabled6.7.6+ | enable or disable scroll | bool | NO | iOS | yes | +| progressContainerStyle6.7.6+ | support normal view style, you can use this to set border/spacing color | object | NO | iOS / Android | no | #### Source @@ -320,6 +363,7 @@ ohpm install - [ ] onLoadComplete 回调函数参数返回目前仅支持 numberOfPages, path参数:[issue#47](https://github.com/react-native-oh-library/react-native-pdf/issues/47) - [ ] 原库部分接口在 HarmonyOS 中没有对应属性及接口处理相关逻辑: [issue#48](https://github.com/react-native-oh-library/react-native-pdf/issues/48) +- [ ] V6.7.6 部分属性未实现 HarmonyOS 化: [issue#1](https://gitcode.com/openharmony-sig/rntpc_react-native-pdf/issues/1) ## 其他 diff --git a/zh-cn/react-native-permissions.md b/zh-cn/react-native-permissions.md index 1544904d8e629ac9008aa076d34296cd7f73adee..e5de44dd81a61d89392f05513899f7b85ce67a93 100644 --- a/zh-cn/react-native-permissions.md +++ b/zh-cn/react-native-permissions.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-permissions Releases](https://github.com/react-native-oh-library/react-native-permissions/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 4.1.2 | [@react-native-oh-tpl/react-native-permissions Releases](https://github.com/react-native-oh-library/react-native-permissions/releases) | 0.72 | +| 5.3.0 | [@react-native-ohos/react-native-permissions Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,21 @@ #### **npm** ```bash +# V4.1.2 npm install @react-native-oh-tpl/react-native-permissions + +# V5.3.0 +npm install @react-native-ohos/react-native-permissions ``` #### **yarn** ```bash +# V4.1.2 yarn add @react-native-oh-tpl/react-native-permissions + +# V5.3.0 +yarn add @react-native-ohos/react-native-permissions ``` @@ -43,8 +58,13 @@ yarn add @react-native-oh-tpl/react-native-permissions ```js import { ScrollView, StyleSheet, View, Text, Button } from "react-native"; import React from "react"; + +// V4.1.2 import RTNPermissions, { Permission } from "@react-native-oh-tpl/react-native-permissions"; +// V5.3.0 +import RTNPermissions, { Permission } from "@react-native-ohos/react-native-permissions"; + const permissionNormal: Permission[] = [ "ohos.permission.APPROXIMATELY_LOCATION", "ohos.permission.CAMERA", @@ -144,6 +164,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +- V4.1.2 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -152,6 +174,16 @@ const styles = StyleSheet.create({ } ``` +- V5.3.0 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + + "@react-native-ohos/react-native-permissions": "file:../../node_modules/@react-native-ohos/react-native-permissions/harmony/permissions.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -187,7 +219,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V4.1.2 ++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-permissions/src/main/cpp" ./permissions) + +# V5.3.0 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-permissions/src/main/cpp" ./permissions) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -204,12 +242,8 @@ target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) + target_link_libraries(rnoh_app PUBLIC rnoh_permissions) # RNOH_END: manual_package_linking_2 - - ``` - - 打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: ```diff @@ -233,8 +267,12 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... +// V4.1.2 + import {PermissionsPackage} from '@react-native-oh-tpl/react-native-permissions/ts'; +// V5.3.0 ++ import {PermissionsPackage} from '@react-native-ohos/react-native-permissions/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ + new PermissionsPackage(ctx), @@ -261,7 +299,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-permissions Releases](https://github.com/react-native-oh-library/react-native-permissions/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 4.1.2 | [@react-native-oh-tpl/react-native-permissions Releases](https://github.com/react-native-oh-library/react-native-permissions/releases) | 0.72 | +| 5.3.0 | [@react-native-ohos/react-native-permissions Releases]() | 0.77 | ### 权限申请使用的工作流程 @@ -344,9 +387,9 @@ ohpm install reason 字段的内容写作规范及建议如下: 保持句子简洁、不要加入多余的分割符号。 - + 建议句式:用于某事。 - + 示例:用于扫码拍照。 ``` @@ -441,6 +484,7 @@ ohos.permission.LOCATION_IN_BACKGROUND 允许应用在后台运行时获取设 | checkLocationAccuracy | 检查设备位置权限 | Function | no | iOS | no(使用 check()查询权限) | | requestLocationAccuracy | 请求访问设备位置的权限 | Function | no | iOS | no(使用 request()设置权限) | | openPhotoPicker | 打开图片选择 | Function | no | iOS | yes( iOS 需要在`PhotoLibrary`权限为`limited`才能调用,HarmonyOS不需要任何权限直接调用) | +| canScheduleExactAlarms5.3.0+ | 检查您的应用程序是否能够设置精确的闹钟。 | Function | no | Android | no(ACTION_REQUEST_SCHEDULE_EXACT_ALARM(应用后台闹钟和提醒),对应鸿蒙的ohos.permission.PUBLISH_AGENT_REMINDER权限,授权模式:为system_grant,这种权限模式不会触发用户授权对话框,也不会在设置中显示权限开关,系统在应用安装或首次使用时自动授予) | ## 遗留问题 diff --git a/zh-cn/react-native-sensors.md b/zh-cn/react-native-sensors.md index 8af4ffa85561c99f1add68e833620d82aa24391c..699c9490e45bbdd1cac29470934afcba79c47c7a 100644 --- a/zh-cn/react-native-sensors.md +++ b/zh-cn/react-native-sensors.md @@ -8,10 +8,11 @@ 该第三方库的仓库已迁移至 Gitee,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-sensors`,具体版本所属关系如下: -| Version | Package Name | Repository | Release | -| ------------------------------ | --------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| <= 7.2.1-rc.2-0.0.1@deprecated | @react-native-oh-library/react-native-sensors | [Github(deprecated)](https://github.com/react-native-oh-library/react-native-sensors) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/react-native-sensors/releases) | -| > 7.2.1 | @react-native-ohos/react-native-sensors | [GitCode](https://gitcode.com/openharmony-sig/rntpc_react-native-sensors) | [GitCode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-sensors/releases) | +| Version | Package Name | Repository | Release | Support RN Version | +| ------------------------------ | --------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------ | +| <= 7.2.1-rc.2-0.0.1@deprecated | @react-native-oh-library/react-native-sensors | [Github(deprecated)](https://github.com/react-native-oh-library/react-native-sensors) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/react-native-sensors/releases) | 0.72 | +| > 7.2.1 | @react-native-ohos/react-native-sensors | [GitCode](https://gitcode.com/openharmony-sig/rntpc_react-native-sensors) | [GitCode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-sensors/releases) | 0.72 | +| 7.3.6 | @react-native-ohos/react-native-sensors | [GitCode](https://gitcode.com/openharmony-sig/rntpc_react-native-sensors) | [GitCode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-sensors/releases) | 0.77 | ## 1. 安装与使用 @@ -173,7 +174,7 @@ export default App; ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", - "@react-native-ohos/react-native-sensors": "file:../../node_modules/react-native-ohos/react-native-sensors/harmony/sensors.har" + "@react-native-ohos/react-native-sensors": "file:../../node_modules/@react-native-ohos/react-native-sensors/harmony/sensors.har" } ``` @@ -229,7 +230,7 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... -+ import {SensorsPackage} from '@react-native-oh-tpl/react-native-sensors/ts'; ++ import {SensorsPackage} from '@react-native-ohos/react-native-sensors/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ diff --git a/zh-cn/react-native-share.md b/zh-cn/react-native-share.md index e16d5c01731bfc47429e935d3fd8be2af30fb1fb..ebe9e8f46ebe7ec322f34f9ef920475ed987f4de 100644 --- a/zh-cn/react-native-share.md +++ b/zh-cn/react-native-share.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-share Releases](https://github.com/react-native-oh-library/react-native-share/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 10.2.1 | [@react-native-oh-tpl/react-native-share Releases](https://github.com/react-native-oh-library/react-native-share/releases) | 0.72 | +| 12.1.0 | [@react-native-ohos/react-native-share Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -26,13 +33,21 @@ #### **npm** ```bash +# V10.2.1 npm install @react-native-oh-tpl/react-native-share + +# V12.1.0 +npm install @react-native-ohos/react-native-share ``` #### **yarn** ```bash +# V10.2.1 yarn add @react-native-oh-tpl/react-native-share + +# V12.1.0 +yarn add @react-native-ohos/react-native-share ``` @@ -81,6 +96,8 @@ yarn add @react-native-oh-tpl/react-native-share 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 +**注意:**V10.2.1 不需要执行 Codegen。 + ## Link 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -112,6 +129,8 @@ yarn add @react-native-oh-tpl/react-native-share 打开 `entry/oh-package.json5`,添加以下依赖 +- V10.2.1 + ```json "dependencies": { @@ -121,6 +140,17 @@ yarn add @react-native-oh-tpl/react-native-share ``` +- V12.1.0 + +```json + +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-share": "file:../../node_modules/@react-native-ohos/react-native-share/harmony/react_native_share.har" + } + +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -134,13 +164,76 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 RNSharePackage +### 3.配置CMakeLists和引入RNSharePackage + +>注:仅这个V12.1.0需要配置CMakeLists和引入RNConfigPackage + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") +set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp") +set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated") +set(LOG_VERBOSITY_LEVEL 1) +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") +set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") + +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use +add_compile_definitions(WITH_HITRACE_SYSTRACE) + +# (VM) Define a variable and assign it to the current module's cpp directory +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +# Add the Header File directory, including cpp, cpp/include, and tell cmake to find the Header Files introduced by the code here +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-share/src/main/cpp" ./share) + +file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1 + +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) +target_link_libraries(rnoh_app PUBLIC rnoh) ++ target_link_libraries(rnoh_app PUBLIC rnoh_share) + +``` + +打开`entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" ++ #include "RNSharePackage.h" +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) +{ + return { ++ std::make_shared(ctx) + }; +} +``` + +### 4.在 ArkTs 侧引入 RNSharePackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff +// V10.2.1 + import {RNSharePackage} from '@react-native-oh-tpl/react-native-share/ts'; +// V12.1.0 ++ import {RNSharePackage} from '@react-native-ohos/react-native-share/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -149,7 +242,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -169,7 +262,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-share Releases](https://github.com/react-native-oh-library/react-native-share/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 10.2.1 | [@react-native-oh-tpl/react-native-share Releases](https://github.com/react-native-oh-library/react-native-share/releases) | 0.72 | +| 12.1.0 | [@react-native-ohos/react-native-share Releases]() | 0.77 | ## 属性 diff --git a/zh-cn/react-native-simple-toast.md b/zh-cn/react-native-simple-toast.md index 02d9de5274633b3187b404ae919b2db388792135..5ca3a87d57bec286fc90a6b9cb2b3ae77f21a3c6 100644 --- a/zh-cn/react-native-simple-toast.md +++ b/zh-cn/react-native-simple-toast.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-simple-toast Releases](https://github.com/react-native-oh-library/react-native-simple-toast/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.3.1 | [@react-native-oh-tpl/react-native-simple-toast Releases](https://github.com/react-native-oh-library/react-native-simple-toast/releases) | 0.72 | +| 3.3.2 | [@react-native-ohos/react-native-simple-toast Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -26,13 +33,21 @@ #### **npm** ```bash +# V3.3.1 npm install @react-native-oh-tpl/react-native-simple-toast + +# V3.3.2 +npm install @react-native-ohos/react-native-simple-toast ``` #### **yarn** ```bash +# V3.3.1 yarn add @react-native-oh-tpl/react-native-simple-toast + +# V3.3.2 +yarn add @react-native-ohos/react-native-simple-toast ``` @@ -198,15 +213,16 @@ RNOH:0.72.23; SDK:HarmonyOS NEXT Developer Beta1; IDE:DevEco Studio 5.0.3. > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 -| Name | Description | Type | Required | HarmonyOS Support | -| ---- |------------------|------------------| -------- | ------------------ | -LONG | toast显示时间:LONG | number | / | yes -SHORT | toast显示时间:SHORT | number | / | yes -TOP | toast显示位置:TOP | number | / | no -BOTTOM | toast显示位置:BOTTOM | number | / | no -CENTER | toast显示位置:CENTER | number | / | no +| Name | Description | Type | Required | HarmonyOS Support | +| ------ | -------------------- | ------ | -------- | ----------------- | +| LONG | toast显示时间:LONG | number | / | yes | +| SHORT | toast显示时间:SHORT | number | / | yes | +| TOP | toast显示位置:TOP | number | / | no | +| BOTTOM | toast显示位置:BOTTOM | number | / | no | +| CENTER | toast显示位置:CENTER | number | / | no | ## 遗留问题 + - [ ] HarmonyOS toast不支持修改字体,背景色等样式[issue#3](https://github.com/react-native-oh-library/react-native-simple-toast/issues/3) - [ ] HarmonyOS rn框架toast组件不支持设置位置及偏移[issue#2](https://github.com/react-native-oh-library/react-native-simple-toast/issues/2) diff --git a/zh-cn/react-native-ssl-pinning.md b/zh-cn/react-native-ssl-pinning.md index 0c19101c31e6ca2294c990cf9f09ad1039f49b12..f38594d925de014a44c118ef218ef68d249106be 100644 --- a/zh-cn/react-native-ssl-pinning.md +++ b/zh-cn/react-native-ssl-pinning.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-ssl-pinning Releases](https://github.com/react-native-oh-library/react-native-ssl-pinning/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.5.7 | [@react-native-oh-tpl/react-native-ssl-pinning Releases](https://github.com/react-native-oh-library/react-native-ssl-pinning/releases) | 0.72 | +| 1.5.9 | [@react-native-ohos/react-native-ssl-pinning Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,21 @@ #### **npm** ```bash +# V1.5.7 npm install @react-native-oh-tpl/react-native-ssl-pinning + +# V1.5.9 +npm install @react-native-ohos/react-native-ssl-pinning ``` #### **yarn** ```bash +# V1.5.7 yarn add @react-native-oh-tpl/react-native-ssl-pinning + +# V1.5.9 +yarn add @react-native-ohos/react-native-ssl-pinning ``` @@ -46,148 +61,167 @@ yarn add @react-native-oh-tpl/react-native-ssl-pinning import React from 'react'; import { - SafeAreaView, - StyleSheet, - ScrollView, - View, - Text, - StatusBar, - Button, - Alert, + SafeAreaView, + StyleSheet, + ScrollView, + View, + Text, + StatusBar, + Button, + Alert, + Platform, + TextInput, + } from 'react-native'; -import {Colors} from 'react-native/Libraries/NewAppScreen'; +import {Header, Colors} from 'react-native/Libraries/NewAppScreen'; import {getCookies, fetch, removeCookieByName} from 'react-native-ssl-pinning'; import FileSelector from '@react-native-oh-tpl/react-native-file-selector'; + +let filePath: string[] = [] function SslPingDemo() : React.JSX.Element{ - return ( - <> - - - - - - fetch bY Public Key - - + + + @@ -86,7 +103,12 @@ export const E_ReactNativeTranslucentModal: React.FC = (): JSX.Element => { 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-translucent-modal Releases](https://github.com/react-native-oh-library/react-native-translucent-modal/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.1.0 | [@react-native-oh-tpl/react-native-translucent-modal Releases](https://github.com/react-native-oh-library/react-native-translucent-modal/releases) | 0.72 | +| 1.1.2 | [@react-native-ohos/react-native-translucent-modal Releases]() | 0.77 | ## 属性 @@ -98,10 +120,10 @@ export const E_ReactNativeTranslucentModal: React.FC = (): JSX.Element => { | Name | Description | Type | Required | Platform | HarmonyOS Support | | ----------------------------- | --------------------------------------------------- | -------- | -------- | -------- | ----------------- | -| `animationType` | Animation type of modal. | string | No | All | yes | -| `transparent` | Whether the background of the modal is transparent. | boolean | No | All | yes | -| `visible` | Controls whether the modal is displayed. | boolean | No | All | yes | -| `onRequestClose?: () => void` | Called when the model request close. | function | No | ALL | yes | +| `animationType` | Animation type of modal. | string | yes | All | yes | +| `transparent` | Whether the background of the modal is transparent. | boolean | yes | All | yes | +| `visible` | Controls whether the modal is displayed. | boolean | yes | All | yes | +| `onRequestClose?: () => void` | Called when the model request close. | function | yes | ALL | yes | ## 遗留问题 diff --git a/zh-cn/react-native-user-agent.md b/zh-cn/react-native-user-agent.md index 0181d062c859158b9362617a02b6d5798f71a837..1c57ab842c2e5ccd27e7b0c29b5d740d9ee83faa 100644 --- a/zh-cn/react-native-user-agent.md +++ b/zh-cn/react-native-user-agent.md @@ -18,7 +18,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-user-agent Releases](https://github.com/react-native-oh-library/react-native-user-agent/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.3.1 | [@react-native-oh-tpl/react-native-user-agent Releases](https://github.com/react-native-oh-library/react-native-user-agent/releases) | 0.72 | +| 2.3.1 | [@react-native-ohos/react-native-user-agent Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -27,13 +34,21 @@ #### **npm** ```bash +# V2.3.1 for RN0.72 npm install @react-native-oh-tpl/react-native-user-agent + +# V2.3.1 for RN0.77 +npm install @react-native-ohos/react-native-user-agent ``` #### **yarn** ```bash +# V2.3.1 for RN0.72 yarn add @react-native-oh-tpl/react-native-user-agent + +# V2.3.1 for RN0.77 +yarn add @react-native-ohos/react-native-user-agent ``` @@ -87,6 +102,8 @@ export default function UserAgentExample() { 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 +**注意:** V2.3.1 for RN0.77 不需要执行 Codegen。 + ## Link 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -117,6 +134,8 @@ export default function UserAgentExample() { 打开 `entry/oh-package.json5`,添加以下依赖 +- V2.3.1 for RN0.72 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -124,6 +143,15 @@ export default function UserAgentExample() { } ``` +- V2.3.1 for RN0.77 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-user-agent": "file:../../node_modules/@react-native-ohos/react-native-user-agent/harmony/user_agent.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -137,15 +165,66 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 RNUserAgentPackage +### 3.配置 CMakeLists + +>注:V2.3.1 for RN0.77 不需要配置 CMakeLists 。 + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") +set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp") ++ set(USER_AGENT_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@react-native-ohos/react-native-user-agent/src/main/cpp") +set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated") +set(LOG_VERBOSITY_LEVEL 1) +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") +set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") + +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use +add_compile_definitions(WITH_HITRACE_SYSTRACE) + +# (VM) Define a variable and assign it to the current module's cpp directory +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +# Add the Header File directory, including cpp, cpp/include, and tell cmake to find the Header Files introduced by the code here +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include ++ ${USER_AGENT_CPP_DIR}) + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_BEGIN: manual_package_linking_1 +#add_subdirectory("${OH_MODULES}/@react-native-ohos/push-notification-ios/src/main/cpp" ./push_notification) +# RNOH_END: manual_package_linking_1 + +# file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1 ++ file(GLOB USER_AGENT_GENERATED_CPP_FILES "${USER_AGENT_CPP_DIR}/generated/*.cpp") # this line is needed by codegen v1 + +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} ++ ${USER_AGENT_GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) +target_link_libraries(rnoh_app PUBLIC rnoh) +``` + +### 4.在 ArkTs 侧引入 RNUserAgentPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... - +// V2.3.1 for RN0.72 + import { RNUserAgentPackage } from '@react-native-oh-tpl/react-native-user-agent/ts'; +// V2.3.1 for RN0.77 ++ import { RNUserAgentPackage } from '@react-native-ohos/react-native-user-agent/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ + new RNUserAgentPackage(ctx) @@ -153,7 +232,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -172,7 +251,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-user-agent Releases](https://github.com/react-native-oh-library/react-native-user-agent/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.3.1 | [@react-native-oh-tpl/react-native-user-agent Releases](https://github.com/react-native-oh-library/react-native-user-agent/releases) | 0.72 | +| 2.3.1 | [@react-native-ohos/react-native-user-agent Releases]() | 0.77 | ## 属性 diff --git a/zh-cn/react-native-worklets-core.md b/zh-cn/react-native-worklets-core.md index ba753eae193d8432fdc09ee76d85f353c9682cca..55a512cef8c5b7cc9aed75e7b747db175c5b13f0 100644 --- a/zh-cn/react-native-worklets-core.md +++ b/zh-cn/react-native-worklets-core.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-worklets-core Releases](https://github.com/react-native-oh-library/react-native-worklets-core/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.3.3 | [@react-native-oh-tpl/react-native-worklets-core Releases](https://github.com/react-native-oh-library/react-native-worklets-core/releases) | 0.72 | +| 1.5.0 | [@react-native-ohos/react-native-worklets-core Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,17 +32,27 @@ #### **npm** ```bash +# V1.3.3 npm i @react-native-oh-tpl/react-native-worklets-core + +# V1.5.0 +npm i @react-native-ohos/react-native-worklets-core ``` #### **yarn** ```bash +# V1.3.3 yarn add @react-native-oh-tpl/react-native-worklets-core + +# V1.5.0 +yarn add @react-native-ohos/react-native-worklets-core ``` 在项目根目录下的 `babel.config.js` 中添加 `babel` 插件 +- V1.3.3 + ```js module.exports = { plugins: [ @@ -46,6 +63,18 @@ module.exports = { }; ``` +- V1.5.0 + +```js +module.exports = { + plugins: [ + ["@react-native-ohos/react-native-worklets-core/plugin"], + // ... + ], + // ... +}; +``` + 重置缓存重启项目 ```bash @@ -123,6 +152,8 @@ export default App; 打开 `entry/oh-package.json5`,添加以下依赖 +- V1.3.3 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -130,6 +161,15 @@ export default App; } ``` +- V1.5.0 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-worklets-core": "file:../../node_modules/@react-native-ohos/react-native-worklets-core/harmony/rn_worklets.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -164,8 +204,13 @@ add_compile_definitions(WITH_HITRACE_SYSTRACE) add_subdirectory("${RNOH_CPP_DIR}" ./rn) add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V1.3.3 + add_subdirectory("${OH_MODULE_DIR}/@react-native-oh-tpl/react-native-worklets-core/src/main/cpp" ./worklets) +# V1.5.0 ++ add_subdirectory("${OH_MODULE_DIR}/@react-native-ohos/react-native-worklets-core/src/main/cpp" ./worklets) + file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") add_library(rnoh_app SHARED @@ -204,8 +249,12 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... +// V1.3.3 + import { WorkletsPackage } from "@react-native-oh-tpl/react-native-worklets-core/ts"; +// V1.5.0 ++ import { WorkletsPackage } from "@react-native-ohos/react-native-worklets-core/ts"; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -233,7 +282,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-library/react-native-worklets-core Releases](https://github.com/react-native-oh-library/react-native-worklets-core/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.3.3 | [@react-native-oh-library/react-native-worklets-core Releases](https://github.com/react-native-oh-library/react-native-worklets-core/releases) | 0.72 | +| 1.5.0 | [@react-native-oh-library/react-native-worklets-core Releases]() | 0.77 | ### API diff --git a/zh-cn/react-native-zip-archive.md b/zh-cn/react-native-zip-archive.md index 91e7f4b3756ab7618b4db3601726dbf75686ed6d..eb67e301939d5ee7dd245d8ca36eeb8dd352c3ff 100644 --- a/zh-cn/react-native-zip-archive.md +++ b/zh-cn/react-native-zip-archive.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-zip-archive Releases](https://github.com/react-native-oh-library/react-native-zip-archive/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 7.0.0 | [@react-native-oh-tpl/react-native-zip-archive Releases](https://github.com/react-native-oh-library/react-native-zip-archive/releases) | 0.72 | +| 7.0.2 | [@react-native-ohos/react-native-zip-archive Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -26,13 +33,21 @@ #### **npm** ```bash +# V7.0.0 npm install @react-native-oh-tpl/react-native-zip-archive + +# V7.0.2 +npm install @react-native-ohos/react-native-zip-archive ``` #### **yarn** ```bash +# V7.0.0 yarn add @react-native-oh-tpl/react-native-zip-archive + +# V7.0.2 +yarn add @react-native-ohos/react-native-zip-archive ``` @@ -404,6 +419,8 @@ const styles = StyleSheet.create({ 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 +**注意:** V7.0.0不需要执行Codegen。 + ## Link 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -434,6 +451,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +- V7.0.0 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -441,6 +460,15 @@ const styles = StyleSheet.create({ } ``` +- V7.0.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", ++ "@react-native-ohos/react-native-zip-archive": "file:../../node_modules/@react-native-ohos/react-native-zip-archive/harmony/zipArchive_package.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -466,6 +494,10 @@ set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") + set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") + +# V7.0.2 ++ set(ZIP_ARCHIVE_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@react-native-ohos/react-native-zip-archive/src/main/cpp") + set(LOG_VERBOSITY_LEVEL 1) set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") @@ -476,16 +508,31 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V7.0.0 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-zip-archive/src/main/cpp" ./zipArchive-package) + +# V7.0.2 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-zip-archive/src/main/cpp" ./zipArchive-package) + # RNOH_END: manual_package_linking_1 +# V7.0.0 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") +# V7.0.2 ++ file(GLOB ZIP_ARCHIVE_GENERATED_CPP_FILES "${ZIP_ARCHIVE_CPP_DIR}/generated/*.cpp") + add_library(rnoh_app SHARED ${GENERATED_CPP_FILES} ++ ${ZIP_ARCHIVE_GENERATED_CPP_FILES} "./PackageProvider.cpp" "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" ) + +# V7.0.2 ++ target_include_directories(rnoh_app PUBLIC ${ZIP_ARCHIVE_CPP_DIR}) + target_link_libraries(rnoh_app PUBLIC rnoh) # RNOH_BEGIN: manual_package_linking_2 @@ -499,8 +546,12 @@ target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff +// V7.0.0 + import {ZipArchivePackage} from '@react-native-oh-tpl/react-native-zip-archive/ts'; +// V7.0.2 ++ import {ZipArchivePackage} from '@react-native-ohos/react-native-zip-archive/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -528,7 +579,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-library/react-native-zip-archive Releases](https://github.com/react-native-oh-library/react-native-zip-archive/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 7.0.0 | [@react-native-oh-library/react-native-zip-archive Releases](https://github.com/react-native-oh-library/react-native-zip-archive/releases) | 0.72 | +| 7.0.2 | [@react-native-oh-library/react-native-zip-archive Releases]() | 0.77 | ## API diff --git a/zh-cn/realm-js.md b/zh-cn/realm-js.md index 531265cd45eac3c5cb20b07a50cc2cd45f23bb4d..594eac32986ba7d9c8015c3423c80ae519139af7 100644 --- a/zh-cn/realm-js.md +++ b/zh-cn/realm-js.md @@ -19,22 +19,39 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/realm-js Releases](https://github.com/react-native-oh-library/realm-js/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 12.13.1 | [@react-native-oh-tpl/realm-js Releases](https://github.com/react-native-oh-library/realm-js/releases) | 0.72 | +| 12.14.2 | [@react-native-ohos/realm-js Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: #### **npm** ```bash +# V12.13.1 npm install @react-native-oh-tpl/realm npm install @react-native-oh-tpl/realm-react + +# V12.14.2 +npm install @react-native-ohos/realm +npm install @react-native-ohos/realm-react ``` #### **yarn** ```bash +# V12.13.1 yarn add @react-native-oh-tpl/realm yarn add @react-native-oh-tpl/realm-react + +# V12.14.2 +yarn add @react-native-ohos/realm +yarn add @react-native-ohos/realm-react ``` 下面的代码展示了这个库的基本使用场景: @@ -153,6 +170,8 @@ function TaskApp() { 打开 `entry/oh-package.json5`,添加以下依赖 +- V12.13.1 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -160,6 +179,15 @@ function TaskApp() { } ``` +- V12.14.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/realm": "file:../../node_modules/@react-native-ohos/realm/binding/harmony/realm.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -196,7 +224,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V12.13.1 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/realm/src/main/cpp" ./realm) + +# V12.14.2 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/realm/src/main/cpp" ./realm) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -239,8 +273,12 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... +// V12.13.1 + import {RNRealmPackage} from '@react-native-oh-tpl/realm/ts'; +// V12.14.2 ++ import {RNRealmPackage} from '@react-native-ohos/realm/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -268,7 +306,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/realm-js Releases](https://github.com/react-native-oh-library/realm-js/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 12.13.1 | [@react-native-oh-tpl/realm-js Releases](https://github.com/react-native-oh-library/realm-js/releases) | 0.72 | +| 12.14.2 | [@react-native-ohos/realm-js Releases]() | 0.77 | ## API diff --git a/zh-cn/victory-native-xl.md b/zh-cn/victory-native-xl.md index 49abaf365bd5565e94146df06f165eebf301f1b1..2c39f491091093aaad2ce26057210c79f71730f8 100644 --- a/zh-cn/victory-native-xl.md +++ b/zh-cn/victory-native-xl.md @@ -17,20 +17,35 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/victory-native-xl Releases](https://github.com/react-native-oh-library/victory-native-xl/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 41.1.0 | [@react-native-oh-tpl/victory-native-xl Releases](https://github.com/react-native-oh-library/victory-native-xl/releases) | 0.72 | +| 41.17.4 | [@react-native-ohos/victory-native-xl Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: #### **npm** ```bash +# V41.1.0 npm install @react-native-oh-tpl/victory-native-xl + +# V41.17.4 +npm install @react-native-ohos/victory-native-xl ``` #### **yarn** ```bash +# V41.1.0 yarn add @react-native-oh-tpl/victory-native-xl + +# V41.17.4 +yarn add @react-native-ohos/victory-native-xl ``` 下面的代码展示了这个库的基本使用场景: @@ -95,7 +110,12 @@ export default function LineChartExample() { 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/victory-native-xl Releases](https://github.com/react-native-oh-library/victory-native-xl/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 41.1.0 | [@react-native-oh-tpl/victory-native-xl Releases](https://github.com/react-native-oh-library/victory-native-xl/releases) | 0.72 | +| 41.17.4 | [@react-native-ohos/victory-native-xl Releases]() | 0.77 | ## 属性 @@ -107,114 +127,122 @@ export default function LineChartExample() { ### Cartesian Chart -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| data | An array of objects to be used as data points for the chart | array[] | yes | all | yes -| xKey | A string value indicating the key of each data[number] object to be used on the independent (x) axis for charting. E.g. "day" if you want to use the "day" field of the data points for the x-axis | string | yes | all | yes -| yKeys | A string[] array of string indicating the keys of each data[number] object to be used on the dependent (y) axis for charting. E.g. yKeys={["lowTmp", "highTmp"]} if you want to chart both high and low temperatures on the y-axis and those values have keys of lowTmp and highTmp respectively | string[] | yes | all | yes -| children | The children prop is a render function whose sole argument is an object that exposes transformed data for you to use in your drawing operations. For example, the children render function's argument has a points field that exposes a version of your input data that's transformed to be plotted on the Canvas (see the Example section above for an example of this)| function | yes | all | yes -| padding | A number or an object of shape { left?: number; right?: number; top?: number; bottom?: number; } that specifies that padding between the outer bounds of the Skia canvas and where the charting bounds will occur | number | no | all | yes -| domain | An object of shape { x?: [number] \| [number, number]; y?: [number] \| [number, number] } that can be specified to control the upper and lower bounds of each axis. It defaults to the min and max of each range respectively | object | no | all | yes -| domainPadding | A number or an object of shape { left?: number; right?: number; top?: number; bottom?: number; } that specifies that padding between the outer bounds of the charting area (e.g. where the axes lie) and where chart elements will be plotted | object | no | all | yes -| axisOptions | The axisOptions is an optional prop allows you to configure the axes and grid of the chart. If it is not present then the chart will not render any axes or grid | object | no | all | yes -| chartPressState | The chartPressState prop allows you to pass in Reanimated SharedValues that will be used to track the user's "press" gesture on the chart. This is generally used for creating some sort of tooltip/active value indicator. See the Chart Gestures page for more in-depth information on how to use this prop | object | no | all | yes -| renderOutside | The renderOutside prop is identical to the children prop in form, but it will render elements at the root of the Skia canvas (not inside of a clipping group). This allows you to render elements outside of the bounds of any axes that you have configured | object | no | all | yes -| onChartBoundsChange | The onChartBoundsChange prop is a function of the shape onChartBoundsChange?: (bounds: ChartBounds) => void; that exposes the chart bounds, useful if you need access to the chart's bounds for your own custom drawing purposes | function | no | all | yes -| gestureLongPressDelay | The gestureLongPressDelay prop allows you to set the delay in milliseconds before the pan gesture is activated. Defaults to 100 | number | no | all | yes - +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| --------------------------------------- | ------------------------------------------------------------ | -------- | -------- | -------- | ----------------- | +| data | An array of objects to be used as data points for the chart | array[] | yes | all | yes | +| xKey | A string value indicating the key of each data[number] object to be used on the independent (x) axis for charting. E.g. "day" if you want to use the "day" field of the data points for the x-axis | string | yes | all | yes | +| yKeys | A string[] array of string indicating the keys of each data[number] object to be used on the dependent (y) axis for charting. E.g. yKeys={["lowTmp", "highTmp"]} if you want to chart both high and low temperatures on the y-axis and those values have keys of lowTmp and highTmp respectively | string[] | yes | all | yes | +| children | The children prop is a render function whose sole argument is an object that exposes transformed data for you to use in your drawing operations. For example, the children render function's argument has a points field that exposes a version of your input data that's transformed to be plotted on the Canvas (see the Example section above for an example of this) | function | yes | all | yes | +| padding | A number or an object of shape { left?: number; right?: number; top?: number; bottom?: number; } that specifies that padding between the outer bounds of the Skia canvas and where the charting bounds will occur | number | no | all | yes | +| domain | An object of shape { x?: [number] \| [number, number]; y?: [number] \| [number, number] } that can be specified to control the upper and lower bounds of each axis. It defaults to the min and max of each range respectively | object | no | all | yes | +| domainPadding | A number or an object of shape { left?: number; right?: number; top?: number; bottom?: number; } that specifies that padding between the outer bounds of the charting area (e.g. where the axes lie) and where chart elements will be plotted | object | no | all | yes | +| axisOptions | The axisOptions is an optional prop allows you to configure the axes and grid of the chart. If it is not present then the chart will not render any axes or grid | object | no | all | yes | +| chartPressState | The chartPressState prop allows you to pass in Reanimated SharedValues that will be used to track the user's "press" gesture on the chart. This is generally used for creating some sort of tooltip/active value indicator. See the Chart Gestures page for more in-depth information on how to use this prop | object | no | all | yes | +| renderOutside | The renderOutside prop is identical to the children prop in form, but it will render elements at the root of the Skia canvas (not inside of a clipping group). This allows you to render elements outside of the bounds of any axes that you have configured | object | no | all | yes | +| onChartBoundsChange | The onChartBoundsChange prop is a function of the shape onChartBoundsChange?: (bounds: ChartBounds) => void; that exposes the chart bounds, useful if you need access to the chart's bounds for your own custom drawing purposes | function | no | all | yes | +| gestureLongPressDelay | The gestureLongPressDelay prop allows you to set the delay in milliseconds before the pan gesture is activated. Defaults to 100 | number | no | all | yes | +| viewport41.17.4+ | An object of shape { x?: [number, number]; y?: [number, number] } that controls the visible range of the chart. Unlike domain which sets the absolute bounds of the data, viewport determines what portion of the data is currently visible in the chart window. | object | no | all | yes | +| xAxis41.17.4+ | The xAxis is an optional prop allows you to configure the X axis of the chart. If it is not present then the chart will not render any X axis. | object | no | all | yes | +| yAxis41.17.4+ | The yAxis is an optional prop allows you to configure the Y axes of the chart. If it is not present then the chart will not render any Y-axis. To render multiple Y axes, pass in multiple Y axis objects to the array. | object | no | all | yes | +| frame41.17.4+ | The frame is an optional prop allows you to configure the frame of the chart. If it is not present then the chart will not render any frame. | object | no | all | yes | +| chartPressConfig41.17.4+ | The chartPressConfig prop allows you to configure the pan gesture handler used for chart interactions. | object | no | all | | +| transformState41.17.4+ | The transformState prop allows you to pass in a transform state object that enables pan and zoom interactions with the chart. | object | no | all | | +| transformConfig41.17.4+ | An optional configuration object for customizing transform behavior when transformState is provided. | object | no | all | yes | +| customGestures41.17.4+ | The customGestures prop allows you to provide custom gesture handlers that will work alongside (or instead of) the default chart press gestures. It accepts a ComposedGesture from react-native-gesture-handler. | object | no | all | | +| actionsRef41.17.4+ | The actionsRef prop allows you to get programmatic access to certain chart actions. It accepts a ref object that will be populated with methods to control chart behavior. | object | no | all | | +| onScaleChange41.17.4+ | A callback 60function that is called whenever the chart's scales change, either due to data updates or zoom/pan transformations. The function receives two parameters: · xScale: The current x-axis scale (a d3 linear scale) · yScale: The current y-axis scale (a d3 linear scale). | function | no | all | yes | +| gestureHandlerConfig41.17.4+ | The gestureHandlerConfig prop allows you to configure the underlying React Native Gesture Handler instance. This is useful for fine-tuning gesture interactions, such as enabling/disabling context menus or adjusting touch behavior on web platforms. | object | no | all | | ### Line Chart -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| points | A PointsArray array that comes from a field of the points object exposed the children render function of CartesianChart, as illustrated in the example above | array[] | no | all | yes -| animate | The animate prop takes a PathAnimationConfig object and will animate the path when the points changes | object | no | all | yes -| curveType | A CurveType value that indicates the type of curve should be drawn (e.g. linear or natural) | string | no | all | yes -| connectMissingData | The connectMissingData: boolean value that indicates whether missing data should be interpolated for the resulting Path. If set to true, the output will be a single, connected line chart path (even if there are missing data values). If set to false, if there is missing data values – the path will consist of multiple disconnected "parts"| boolean | no | all | yes -| children | A children pass-thru that will be rendered inside of the Skia Path element, useful if you'd like to make e.g. a gradient path | object | no | all | yes -| strokeWidth| Set the width of the line | number| no | all | yes -| color| Set the color of the line | string| no | all | yes - +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ------------------ | ------------------------------------------------------------ | ------- | -------- | -------- | ----------------- | +| points | A PointsArray array that comes from a field of the points object exposed the children render function of CartesianChart, as illustrated in the example above | array[] | no | all | yes | +| animate | The animate prop takes a PathAnimationConfig object and will animate the path when the points changes | object | no | all | yes | +| curveType | A CurveType value that indicates the type of curve should be drawn (e.g. linear or natural) | string | no | all | yes | +| connectMissingData | The connectMissingData: boolean value that indicates whether missing data should be interpolated for the resulting Path. If set to true, the output will be a single, connected line chart path (even if there are missing data values). If set to false, if there is missing data values – the path will consist of multiple disconnected "parts" | boolean | no | all | yes | +| children | A children pass-thru that will be rendered inside of the Skia Path element, useful if you'd like to make e.g. a gradient path | object | no | all | yes | +| strokeWidth | Set the width of the line | number | no | all | yes | +| color | Set the color of the line | string | no | all | yes | ### Area Chart -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| points | A PointsArray array that comes from a field of the points object exposed the children render function of CartesianChart, as illustrated in the example above | array[] | no | all | yes -| y0 | A number that indicates where the "bottom" of the area path should run. This number should be in canvas coordinates | number | no | all | yes -| animate | The animate prop takes a PathAnimationConfig object and will animate the path when the points changes | object | no | all | yes -| curveType | A CurveType value that indicates the type of curve should be drawn (e.g. linear or natural) | string | no | all | yes -| connectMissingData | The connectMissingData: boolean value that indicates whether missing data should be interpolated for the resulting Path. If set to true, the output will be a single, connected area chart path (even if there are missing data values). If set to false, if there is missing data values – the path will consist of multiple disconnected "parts" | boolean | no | all | yes -| children | A children pass-thru that will be rendered inside of the Skia Path element, useful if you'd like to make e.g. a gradient path | object | no | all | yes -| color| Set the color of the area | string| no | all | yes - +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ------------------ | ------------------------------------------------------------ | ------- | -------- | -------- | ----------------- | +| points | A PointsArray array that comes from a field of the points object exposed the children render function of CartesianChart, as illustrated in the example above | array[] | no | all | yes | +| y0 | A number that indicates where the "bottom" of the area path should run. This number should be in canvas coordinates | number | no | all | yes | +| animate | The animate prop takes a PathAnimationConfig object and will animate the path when the points changes | object | no | all | yes | +| curveType | A CurveType value that indicates the type of curve should be drawn (e.g. linear or natural) | string | no | all | yes | +| connectMissingData | The connectMissingData: boolean value that indicates whether missing data should be interpolated for the resulting Path. If set to true, the output will be a single, connected area chart path (even if there are missing data values). If set to false, if there is missing data values – the path will consist of multiple disconnected "parts" | boolean | no | all | yes | +| children | A children pass-thru that will be rendered inside of the Skia Path element, useful if you'd like to make e.g. a gradient path | object | no | all | yes | +| color | Set the color of the area | string | no | all | yes | ### Bar Chart -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| points | A PointsArray array that comes from a field of the points object exposed the children render function of CartesianChart, as illustrated in the example above | array[] | no | all | yes -| chartBounds | A ChartBounds object needed to appropriately draw the bars. This generally comes from the chartBounds render argument of CartesianChart | object | no | all | yes -| innerPadding | An optional number between 0 and 1 that represents what fraction of the horizontal space between the first and last bars should be "white space". Defaults to 0.2. Use 0 for no gap between bars, and values closer to 1 to make bars increasingly narrow | number | no | all | yes -| animate | The animate prop takes a PathAnimationConfig object and will animate the path when the points change | object | no | all | yes -| roundedCorners | The roundedCorners prop allows you to customize the roundedness of each corner of the Bar component. It's an object type that defines the radii for the top-left, top-right, bottom-right, and bottom-left corners | object | no | all | yes -| barWidth | The barWidth prop takes a number and sets the width of the bar to that number. If not provided, the default is determined by the chartBounds and number of data points. Takes precendence over the barCount prop. Use this for the most fine grained control of bar width | number | no | all | yes -| barCount | The barCount prop takes a number and sets the width of the bar as if there X data points. If not provided, the default is determined by the chartBounds and number of data points. Useful for getting a fixed bar width regardless of the number of data points. Use this for a more general control of bar width | number | no | all | yes -| children | A children pass-thru that will be rendered inside of the Skia Path element, useful if you'd like to make e.g. a gradient path | object | no | all | yes -| color| Set the color of the bar| string| no | all | yes - +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ------------------------- | ------------------------------------------------------------ | ------- | -------- | -------- | ----------------- | +| points | A PointsArray array that comes from a field of the points object exposed the children render function of CartesianChart, as illustrated in the example above | array[] | no | all | yes | +| chartBounds | A ChartBounds object needed to appropriately draw the bars. This generally comes from the chartBounds render argument of CartesianChart | object | no | all | yes | +| innerPadding | An optional number between 0 and 1 that represents what fraction of the horizontal space between the first and last bars should be "white space". Defaults to 0.2. Use 0 for no gap between bars, and values closer to 1 to make bars increasingly narrow | number | no | all | yes | +| animate | The animate prop takes a PathAnimationConfig object and will animate the path when the points change | object | no | all | yes | +| roundedCorners | The roundedCorners prop allows you to customize the roundedness of each corner of the Bar component. It's an object type that defines the radii for the top-left, top-right, bottom-right, and bottom-left corners | object | no | all | yes | +| barWidth | The barWidth prop takes a number and sets the width of the bar to that number. If not provided, the default is determined by the chartBounds and number of data points. Takes precendence over the barCount prop. Use this for the most fine grained control of bar width | number | no | all | yes | +| barCount | The barCount prop takes a number and sets the width of the bar as if there X data points. If not provided, the default is determined by the chartBounds and number of data points. Useful for getting a fixed bar width regardless of the number of data points. Use this for a more general control of bar width | number | no | all | yes | +| children | A children pass-thru that will be rendered inside of the Skia Path element, useful if you'd like to make e.g. a gradient path | object | no | all | yes | +| color | Set the color of the bar | string | no | all | yes | +| labels41.17.4+ | The labels prop allows you to enable and customize the data label of the Bar component. The data label text is the Y-axis value associated with the Bar component. | object | no | all | yes | ### BarGroup Chart -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| chartBounds | A ChartBounds object needed to appropriately draw the bars. This generally comes from the chartBounds render argument of CartesianChart | object | no | all | yes -| betweenGroupPadding | An optional number between 0 and 1 that represents what fraction of the horizontal space between the first and last bar groups should be "white space". Defaults to 0.2. Use 0 for no gap between groups, and values closer to 1 to make bars increasingly narrow | number | no | all | yes -| withinGroupPadding | An optional number between 0 and 1 that represents what fraction of the horizontal space between the first and last bars within a group should be "white space". Defaults to 0.2. Use 0 for no gap between bars within a group, and values closer to 1 to make bars increasingly narrow | number | no | all | yes -| barWidth | The barWidth prop takes a number and sets the width of the bar to that number. If not provided, the default is determined by a combination of the total available width for the group of bars, the number of bars in the group, and the padding between the bars within the group. Takes precedence over barCount prop. Use this for the most fine grained control of bar width | number | no | all | yes -| barCount | The barCount prop takes a number and sets the width of the bar as if there X data points. If not provided, the default is determined by the chartBounds and number of data points. Useful for getting a fixed bar width regardless of the number of data points. Use this for a more general control of bar width | number | no | all | yes -| onBarSizeChange | That alerts the consumer when the size of the bars/groups changes, useful for if you're building a custom tooltip and need to know the size of the groups/bars | function | no | all | yes -| roundedCorners | The roundedCorners prop allows you to customize the roundedness of each corner of a BarGroup.Bar component. It's an object type that defines the radii for the top-left, top-right, bottom-right, and bottom-left corners | object | no | all | yes -| children | An array of BarGroup.Bar elements (see below) that represent the bars to add to the bar group | object | no | all | yes -| color| Set the color of the bar | string| no | all | yes - +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ------------------- | ------------------------------------------------------------ | -------- | -------- | -------- | ----------------- | +| chartBounds | A ChartBounds object needed to appropriately draw the bars. This generally comes from the chartBounds render argument of CartesianChart | object | no | all | yes | +| betweenGroupPadding | An optional number between 0 and 1 that represents what fraction of the horizontal space between the first and last bar groups should be "white space". Defaults to 0.2. Use 0 for no gap between groups, and values closer to 1 to make bars increasingly narrow | number | no | all | yes | +| withinGroupPadding | An optional number between 0 and 1 that represents what fraction of the horizontal space between the first and last bars within a group should be "white space". Defaults to 0.2. Use 0 for no gap between bars within a group, and values closer to 1 to make bars increasingly narrow | number | no | all | yes | +| barWidth | The barWidth prop takes a number and sets the width of the bar to that number. If not provided, the default is determined by a combination of the total available width for the group of bars, the number of bars in the group, and the padding between the bars within the group. Takes precedence over barCount prop. Use this for the most fine grained control of bar width | number | no | all | yes | +| barCount | The barCount prop takes a number and sets the width of the bar as if there X data points. If not provided, the default is determined by the chartBounds and number of data points. Useful for getting a fixed bar width regardless of the number of data points. Use this for a more general control of bar width | number | no | all | yes | +| onBarSizeChange | That alerts the consumer when the size of the bars/groups changes, useful for if you're building a custom tooltip and need to know the size of the groups/bars | function | no | all | yes | +| roundedCorners | The roundedCorners prop allows you to customize the roundedness of each corner of a BarGroup.Bar component. It's an object type that defines the radii for the top-left, top-right, bottom-right, and bottom-left corners | object | no | all | yes | +| children | An array of BarGroup.Bar elements (see below) that represent the bars to add to the bar group | object | no | all | yes | +| color | Set the color of the bar | string | no | all | yes | ### Scatter Chart -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| points | TA PointsArray array that comes from a field of the points object exposed the children render function of CartesianChart, as illustrated in the example above | array[] | no | all | yes -| radius | radius of the circle, half the width of the square | number | no | all | yes -| shape | One of the following ScatterShape values that determines the shape of each point to be drawn | ScatterShape | no | all | yes -| animate | The animate prop takes a PathAnimationConfig object and will animate the path when the points change | object | no | all | yes -| children | An array of BarGroup.Bar elements (see below) that represent the bars to add to the bar group | object | no | all | yes -| style| set style stroke or fill | string| no | all | yes -| strokeWidth| Set the width of the line | number| no | all | yes -| color| Set the color of the bar| string| no | all | yes +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ----------- | ------------------------------------------------------------ | ------------ | -------- | -------- | ----------------- | +| points | TA PointsArray array that comes from a field of the points object exposed the children render function of CartesianChart, as illustrated in the example above | array[] | no | all | yes | +| radius | radius of the circle, half the width of the square | number | no | all | yes | +| shape | One of the following ScatterShape values that determines the shape of each point to be drawn | ScatterShape | no | all | yes | +| animate | The animate prop takes a PathAnimationConfig object and will animate the path when the points change | object | no | all | yes | +| children | An array of BarGroup.Bar elements (see below) that represent the bars to add to the bar group | object | no | all | yes | +| style | set style stroke or fill | string | no | all | yes | +| strokeWidth | Set the width of the line | number | no | all | yes | +| color | Set the color of the bar | string | no | all | yes | ### Polar Chart -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| data | An array of objects to be used as data points for the chart | array[] | yes | all | yes -| labelKey | A string value indicating the key of each data[number] object to be used. Currently only used on the legend part of the chart. In the future we may add support for a variety of labels within the chart | string | yes | all | yes -| valueKey | A string value indicating the key of each data[number] object to be used to draw a slice of the Pie | string | yes | all | yes -| colorKey | A string value indicating the key of each data[number] object to be used to draw a slice of the Pie | string | yes | all | yes -| children | The only supported children of a PolarChart is currently a Pie.Chart See the Pie Chart for more details | object | no | all | yes -| containerStyle | A StyleProp that styles the View which wraps the Canvas of the Polar chart | object | no | all | yes -| canvasStyle | A StyleProp that styles the Canvas upon which the Polar chart is drawn | object | no | all | yes +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| -------------- | ------------------------------------------------------------ | ------- | -------- | -------- | ----------------- | +| data | An array of objects to be used as data points for the chart | array[] | yes | all | yes | +| labelKey | A string value indicating the key of each data[number] object to be used. Currently only used on the legend part of the chart. In the future we may add support for a variety of labels within the chart | string | yes | all | yes | +| valueKey | A string value indicating the key of each data[number] object to be used to draw a slice of the Pie | string | yes | all | yes | +| colorKey | A string value indicating the key of each data[number] object to be used to draw a slice of the Pie | string | yes | all | yes | +| children | The only supported children of a PolarChart is currently a Pie.Chart See the Pie Chart for more details | object | no | all | yes | +| containerStyle | A StyleProp that styles the View which wraps the Canvas of the Polar chart | object | no | all | yes | +| canvasStyle | A StyleProp that styles the Canvas upon which the Polar chart is drawn | object | no | all | yes | ### Pie.Chart **Bar related props for making Capped Bar chart** -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---- | ----------- | ---- | -------- | -------- | ------------------ | -| innerRadius | A number or string (as a percentage) which turns the Pie chart into a Donut chart. The innerRadius prop is the radius of the inner circle of the donut chart. If not provided, the chart will remain a Pie chart | number | no | all | yes -| circleSweepDegrees | A number which defines how many degrees of the chart should be drawn. The default is 360 which will draw a full circle. If you want to draw a partial circle, you can set this prop to a value between 0 and 360 | number | no | all | yes -| startAngle | A number which defines the starting angle of the chart. Changing this prop will rotate the chart | number | no | all | yes -| children | The children prop is a render function which maps through the data and whose sole argument is each individual slice of the pie, allowing you to customize each slice as needed. E.g. this slice will have all the data needed to render a Pie.Slice | function | no | all | yes -| angularStrokeWidth | A number which turns width of the Pie chart slice | number | no | all | yes -| angularStrokeColor | A string which turns color of the Pie chart slice | string | no | all | yes + +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ------------------ | ------------------------------------------------------------ | -------- | -------- | -------- | ----------------- | +| innerRadius | A number or string (as a percentage) which turns the Pie chart into a Donut chart. The innerRadius prop is the radius of the inner circle of the donut chart. If not provided, the chart will remain a Pie chart | number | no | all | yes | +| circleSweepDegrees | A number which defines how many degrees of the chart should be drawn. The default is 360 which will draw a full circle. If you want to draw a partial circle, you can set this prop to a value between 0 and 360 | number | no | all | yes | +| startAngle | A number which defines the starting angle of the chart. Changing this prop will rotate the chart | number | no | all | yes | +| children | The children prop is a render function which maps through the data and whose sole argument is each individual slice of the pie, allowing you to customize each slice as needed. E.g. this slice will have all the data needed to render a Pie.Slice | function | no | all | yes | +| angularStrokeWidth | A number which turns width of the Pie chart slice | number | no | all | yes | +| angularStrokeColor | A string which turns color of the Pie chart slice | string | no | all | yes | ## 遗留问题