diff --git a/en/react-native-community-progress-bar-android.md b/en/react-native-community-progress-bar-android.md index dc101a7dcb3c84f947a182077907019c0defb481..32666797cf41d8d4bacc20fd9d9018362770c386 100644 --- a/en/react-native-community-progress-bar-android.md +++ b/en/react-native-community-progress-bar-android.md @@ -16,24 +16,35 @@ ## Installation and Usage -Find the matching version information in the release address of a third-party library: [@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases).For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. +Please check the corresponding version information at the third-party library's Releases page: -Go to the project directory and execute the following instruction: +| Library Version | Release Info | Supported RN Version | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.0.4 | [@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) | 0.72 | +| 1.1.0-rc.1 | @react-native-ohos/progress-bar-android Releases | 0.77 | +For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. +Enter the project directory and execute the following command: #### **yarn** ```bash +# 0.72 yarn add @react-native-oh-tpl/progress-bar-android +# 0.77 +yarn add @react-native-ohos/progress-bar-android ``` #### **npm** ```bash +# 0.72 npm install @react-native-oh-tpl/progress-bar-android +# 0.77 +npm install @react-native-ohos/progress-bar-android ``` @@ -83,11 +94,21 @@ Method 1 (recommended): Use the HAR file. Open `entry/oh-package.json5` file and add the following dependencies: +* V1.0.4 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-oh-tpl/progress-bar-android": "file:../../node_modules/@react-native-oh-tpl/progress-bar-android/harmony/progress_bar_android.har" + } +``` - "@react-native-oh-tpl/progress-bar-android": "file:../../node_modules/@react-native-oh-tpl/progress-bar-android/harmony/progress_bar_android.har" +* V1.0.6 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/progress-bar-android": "file:../../node_modules/@react-native-ohos/progress-bar-android/harmony/progress_bar_android.har" } ``` @@ -102,7 +123,7 @@ ohpm install Method 2: Directly link to the source code. -> [!TIP] For details, see [Directly Linking Source Code](/en/link-source-code.md). +> For details, see [Directly Linking Source Code](/en/link-source-code.md). ### 3. Configuring CMakeLists and Introducing ProgressBarAndroidPackage @@ -127,7 +148,10 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) +# 0.72 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/progress-bar-android/src/main/cpp" ./progress-bar-android) +# 0.77 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/progress-bar-android/src/main/cpp" ./progress-bar-android) # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -170,7 +194,10 @@ Find `function buildCustomRNComponent()`, which is usually located in `entry/src ```diff ... +# 0.72 + import { ProgressBarAndroid, PROGRESS_BAR_TYPE } from "@react-native-oh-tpl/progress-bar-android" +# 0.77 ++ import { ProgressBarAndroid, PROGRESS_BAR_TYPE } from "@react-native-ohos/progress-bar-android" @Builder export function buildCustomRNComponent(ctx: ComponentBuilderContext) { @@ -218,7 +245,13 @@ Then build and run the code. To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone. -Check the release version information in the release address of the third-party library: [@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) +please check the release version information in the release address of the third-party library: + +| Library Version | Release Information | Supported RN Version | +| --------------- | ------------------------------------------------------------ | ---------- | +| 1.0.4 | [@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) | 0.72 | +| 1.0.6 | @react-native-ohos/progress-bar-android Releases | 0.77 | + ## Properties @@ -236,7 +269,7 @@ Check the release version information in the release address of the third-party ## Known Issues -- [x] styleAttr 为 Horizontal 时无法铺满全屏 [issues#4](https://github.com/react-native-oh-library/progress-bar-android/issues/4)。 +- [x] When styleAttr is set to Horizontal, the component cannot fill the entire screen.[issues#4](https://github.com/react-native-oh-library/progress-bar-android/issues/4)。 ## Others diff --git a/en/react-native-file-viewer.md b/en/react-native-file-viewer.md index efb77f3a04db025b7a5efb9593af7b6ad5f74594..db76dff624f84e7252ac79cf42cb9cf1cce9b2b1 100644 --- a/en/react-native-file-viewer.md +++ b/en/react-native-file-viewer.md @@ -17,24 +17,37 @@ ## Installation and Usage -Find the matching version information in the release address of a third-party library: [@react-native-oh-tpl/react-native-file-viewer Releases](https://github.com/react-native-oh-library/react-native-file-viewer/releases).For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. +Please check the corresponding version information at the third-party library's Releases page: -Go to the project directory and execute the following instruction: +| Library Version | Release Information | Supported RN Version | +| --------------- | ------------------------------------------------------------ | ---------- | +| 2.1.5 | [@react-native-oh-tpl/react-native-file-viewer Releases](https://github.com/react-native-oh-library/react-native-file-viewer/releases) | 0.72 | +| 2.2.0-rc.1 | [@react-native-ohos/react-native-file-viewer Releases]() | 0.77 | +For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. +Enter the project directory and execute the following command: #### **npm** ```bash +# 0.72 npm install @react-native-oh-tpl/react-native-file-viewer + +# 0.77 +npm install @react-native-ohos/react-native-file-viewer ``` #### **yarn** ```bash +# 0.72 yarn add @react-native-oh-tpl/react-native-file-viewer + +# 0.77 +yarn add @react-native-ohos/react-native-file-viewer ``` @@ -154,6 +167,9 @@ const styles = StyleSheet.create({ ## Use Codegen +> [!TIP] Codegen is not required for RN 0.77 projects. + + If this repository has been adapted to `Codegen`, generate the bridge code of the third-party library by using the `Codegen`. For details, see [Codegen Usage Guide](/en/codegen.md). ## Link @@ -183,6 +199,8 @@ Method 1 (recommended): Use the HAR file. Open `entry/oh-package.json5` file and add the following dependencies: +- V2.1.5 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -190,6 +208,15 @@ Open `entry/oh-package.json5` file and add the following dependencies: } ``` +- V2.2.0-rc.1 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-file-viewer": "file:../../node_modules/@react-native-ohos/react-native-file-viewer/harmony/file_viewer.har" + } +``` + Click the `sync` button in the upper right corner. Alternatively, run the following instruction on the terminal: @@ -201,25 +228,94 @@ ohpm install Method 2: Directly link to the source code. -> [!TIP] For details, see [Directly Linking Source Code](/en/link-source-code.md). +> [!TIP] If you need to use the directly linked source code, please refer to [Directly Linking Source Code](/en/link-source-code.md) + + +### 3.configuring CMakeLists and introducing FileViewerPackage + +> [!TIP] If you are using a RN0.72 project, please skip this chapter. + +Open `entry/src/main/cpp/CMakeLists.txt`,add: + -### 3. Introducing RNFileViewerTurboModule Package to ArkTS +### 3. in ArkTs import RNFileViewerPackage +```cmake +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-ohos/react-native-file-viewer/src/main/cpp" ./file-viewer) +# 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_file_viewer) +# RNOH_END: manual_package_linking_2 +``` + +Open `entry/src/main/cpp/PackageProvider.cpp`,add: + +```c++ +#include "RNOH/PackageProvider.h" +#include "generated/RNOHGeneratedPackage.h" +#include "SamplePackage.h" ++ #include "FileViewerPackage.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.in ArkTs import RNFileViewerPackage + +Open `entry/src/main/ets/RNPackagesFactory.ts`,add: -Open the `entry/src/main/ets/RNPackagesFactory.ts` file and add the following code: ```diff ... +// 0.72 + import { RNFileViewerPackage } from '@react-native-oh-tpl/react-native-file-viewer/ts'; +// 0.77 ++ import { RNFileViewerPackage } from '@react-native-ohos/react-native-file-viewer/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), -+ new RNFileViewerPackage(ctx) - ]; + ] } ``` -### 4. Running +### 5. Running Click the `sync` button in the upper right corner. @@ -238,7 +334,12 @@ Then build and run the code. To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone. -Check the release version information in the release address of the third-party library: [@react-native-oh-tpl/react-native-file-viewer Releases](https://github.com/react-native-oh-library/react-native-file-viewer/releases) +Please check the release version information in the release address of the third-party library: + +| Library Version | Release Information | Supported RN Version | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.1.5 | [@react-native-oh-tpl/react-native-file-viewer Releases](https://github.com/react-native-oh-library/react-native-file-viewer/releases) | 0.72 | +| 2.2.0-rc.1 | [@react-native-ohos/react-native-file-viewer Releases]() | 0.77 | ## API @@ -264,8 +365,8 @@ Check the release version information in the release address of the third-party ## Known Issues -- [x] HarmonyOS 端暂不支持关闭预览窗口的回调函数调用: [issue#1](https://github.com/react-native-oh-library/react-native-file-viewer/issues/4) -- [x] HarmonyOS 端无法直接跳转到应用市场的推荐应用页,目前只能跳转到应用市场首页: [issue#2](https://github.com/react-native-oh-library/react-native-file-viewer/issues/5) +- [x] HarmonyOS not support close preview window callback: [issue#1](https://github.com/react-native-oh-library/react-native-file-viewer/issues/4) +- [x] HarmonyOS not support jump to app market recommended apps page: [issue#2](https://github.com/react-native-oh-library/react-native-file-viewer/issues/5) ## Others diff --git a/en/react-native-network-info.md b/en/react-native-network-info.md index bda56ebaf6902b41251d0e5e4388898ad68ba71c..5f130526662f9d2c420e937c8fb710c83ce11a7b 100644 --- a/en/react-native-network-info.md +++ b/en/react-native-network-info.md @@ -17,7 +17,14 @@ ## Installation and Usage -Find the matching version information in the release address of a third-party library: [@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases).For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. +Please check the corresponding version information at the third-party library's Releases page: + +| Library Version | Release Information | Supported RN Version | +| ---------- | ------------------------------------------------------------ | ---------- | +| 5.2.1 | [@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) | 0.72 | +| 5.3.0-rc.1 | @react-native-ohos/react-native-network-info Releases | 0.77 | + +For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. Go to the project directory and execute the following instruction: @@ -28,13 +35,19 @@ Go to the project directory and execute the following instruction: #### **npm** ```bash +# 0.72 npm install @react-native-oh-tpl/react-native-network-info +# 0.77 +npm install @react-native-ohos/react-native-network-info ``` #### **yarn** ```bash -yarn add @react-native-oh-tpl/react-native-network-info +# 0.72 +yarn install @react-native-oh-tpl/react-native-network-info +# 0.77 +yarn install @react-native-ohos/react-native-network-info ``` @@ -183,6 +196,8 @@ Method 1 (recommended): Use the HAR file. Open `entry/oh-package.json5` file and add the following dependencies: +* V5.2.1 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -190,6 +205,15 @@ Open `entry/oh-package.json5` file and add the following dependencies: } ``` +* V5.2.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-network-info": "file:../../node_modules/@react-native-ohos/react-native-network-info/harmony/rn_network_info.har" + } +``` + Click the `sync` button in the upper right corner. Alternatively, run the following instruction on the terminal: @@ -201,17 +225,73 @@ ohpm install Method 2: Directly link to the source code. -> [!TIP] or details, see [Directly Linking Source Code](/en/link-source-code.md). +> If you need to link the source code directly, please refer to the [Direct Linking Source Code Guide](/en/link-source-code-en.md) + +### 3. Configure CMakeLists and Introduce RNOrientationPackage -### 3. Introducing RNNetworkInfoPackage to ArkTS +> [!TIP] Version `5.2.2` and above require -Open the `entry/src/main/ets/RNPackagesFactory.ts` file and add the following code: +Open `entry/src/main/cpp/CMakeLists.txt`,Add: ```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_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-network-info/src/main/cpp" ./rn_network_info) +# RNOH_END: manual_package_linking_1 + +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_network_info) +# RNOH_END: manual_package_linking_2 +``` + +Open `entry/src/main/cpp/PackageProvider.cpp`,Add: +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "NetworkInfoPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx), + }; +} +``` + +### 4. In ArkTs, Introduce RNNetworkInfoPackage + +Open `entry/src/main/ets/RNPackagesFactory.ts`,Add: + + +```diff + ... + + # 0.72 + import { RNNetworkInfoPackage } from '@react-native-oh-tpl/react-native-network-info/ts'; + # 0.77 ++ import { RNNetworkInfoPackage } from '@react-native-ohos/react-native-network-info/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -220,7 +300,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4. Running +### 5. Running Click the `sync` button in the upper right corner. @@ -239,7 +319,12 @@ Then build and run the code. To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone. -Check the release version information in the release address of the third-party library: [@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) +Please check the release version information in the release address of the third-party library: + +| Library Version | Release Information | Supported RN Versions | +| ---------- | ------------------------------------------------------------ | ---------- | +| 5.2.1 | [@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) | 0.72 | +| 5.2.2 | @react-native-ohos/react-native-network-info Releases | 0.77 | ### Permission Requirements diff --git a/en/react-native-orientation.md b/en/react-native-orientation.md index 303bf7e73712f1ebd4e2e62c151e82288f2a148b..414107e78c6030f66eceb288043130a0bf8a584f 100644 --- a/en/react-native-orientation.md +++ b/en/react-native-orientation.md @@ -16,7 +16,14 @@ ## Installation and Usage -Find the matching version information in the release address of a third-party library: [@react-native-oh-library/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases).For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. +please check the release version information in the release address of the third-party library: + +| Library Version | Release Information | Supported RN Versions | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.3 | [@react-native-oh-tpl/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) | 0.72 | +| 3.2.0-rc.1 | @react-native-ohos/react-native-orientation Releases | 0.77 | + +For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. Go to the project directory and execute the following instruction: @@ -27,13 +34,19 @@ Go to the project directory and execute the following instruction: #### npm ```bash +# 0.72 npm install @react-native-oh-tpl/react-native-orientation +# 0.77 +npm install @react-native-ohos/react-native-orientation ``` #### yarn ```bash -yarn add @react-native-oh-tpl/react-native-orientation +# 0.72 +yarn install @react-native-oh-tpl/react-native-orientation +# 0.77 +yarn install @react-native-ohos/react-native-orientation ``` @@ -181,7 +194,7 @@ const styles = StyleSheet.create({ ## Use Codegen -If this repository has been adapted to `Codegen`, generate the bridge code of the third-party library by using the `Codegen`. For details, see [Codegen Usage Guide](/zh-cn/codegen.md). +If this repository has been adapted to `Codegen`, generate the bridge code of the third-party library by using the `Codegen`. For details, see [Codegen Usage Guide](/en/codegen.md). ## Link @@ -189,7 +202,7 @@ Currently, HarmonyOS does not support AutoLink. Therefore, you need to manually Open the `harmony` directory of the HarmonyOS project in DevEco Studio. -### Adding the overrides Field to oh-package.json5 File in the Root Directory of the Project +### 1. Adding the overrides Field to oh-package.json5 File in the Root Directory of the Project ```json { @@ -210,6 +223,8 @@ Method 1 (recommended): Use the HAR file. Open `entry/oh-package.json5` file and add the following dependencies: +* V3.1.3 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -217,6 +232,15 @@ Open `entry/oh-package.json5` file and add the following dependencies: } ``` +* V3.1.4 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-orientation": "file:../../node_modules/@react-native-ohos/react-native-orientation/harmony/rn_orientation.har", + } +``` + Click the `sync` button in the upper right corner. Alternatively, run the following instruction on the terminal: @@ -228,7 +252,7 @@ ohpm install Method 2: Directly link to the source code. -> [!TIP] For details, see [Directly Linking Source Code](/zh-cn/link-source-code.md). +> For details, see [Directly Linking Source Code](/en/link-source-code.md). run the following instruction on the terminal: @@ -237,13 +261,67 @@ cd entry ohpm install --no-link ``` -### 3. Introducing RNOrientationPackage to ArkTS +### 3. Configuring CMakeLists and Introducing RNOrientationPackage -Open the `entry/src/main/ets/RNPackagesFactory.ts` file and add the following code: +> [!TIP] Version `3.1.4` and above requires + +Open `entry/src/main/cpp/CMakeLists.txt`,add: + +```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_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-orientation/src/main/cpp" ./rn_orientation) +# RNOH_END: manual_package_linking_1 + +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_orientation) +# RNOH_END: manual_package_linking_2 +``` + +Open `entry/src/main/cpp/PackageProvider.cpp`,add: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "RNOritentionPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx), + }; +} +``` + +### 4. In ArkTs, Introduce RNOrientationPackage + +Open `entry/src/main/ets/RNPackagesFactory.ts`,add: ```diff ... + # 0.72 + import { RNOrientationPackage } from '@react-native-oh-tpl/react-native-orientation/ts'; + # 0.77 ++ import { RNOrientationPackage } from '@react-native-ohos/react-native-orientation/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ @@ -253,7 +331,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4. Running +### 5. Running Click the `sync` button in the upper right corner. @@ -272,7 +350,12 @@ Then build and run the code. To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone. -Check the release version information in the release address of the third-party library: [@react-native-oh-library/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) +Please check the release version information in the release address of the third-party library: + +| Library Version | Release Information | Supported RN Version | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.3 | [@react-native-oh-tpl/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) | 0.72 | +| 3.1.4 | @react-native-ohos/react-native-orientation Releases | 0.77 | ## API diff --git a/zh-cn/react-native-community-progress-bar-android.md b/zh-cn/react-native-community-progress-bar-android.md index a1d4543fdea8e6ab4045740dd6a9cefac14c79de..ec7937015835229d467dfff7293237d9483b17b9 100644 --- a/zh-cn/react-native-community-progress-bar-android.md +++ b/zh-cn/react-native-community-progress-bar-android.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.0.4 | [@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) | 0.72 | +| 1.1.0-rc.1 | @react-native-ohos/progress-bar-android Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,19 @@ #### **yarn** ```bash +# 0.72 yarn add @react-native-oh-tpl/progress-bar-android +# 0.77 +yarn add @react-native-ohos/progress-bar-android ``` #### **npm** ```bash +# 0.72 npm install @react-native-oh-tpl/progress-bar-android +# 0.77 +npm install @react-native-ohos/progress-bar-android ``` @@ -84,11 +97,21 @@ export default function ProgressBarExample() { 打开 `entry/oh-package.json5`,添加以下依赖 +* V1.0.4 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-oh-tpl/progress-bar-android": "file:../../node_modules/@react-native-oh-tpl/progress-bar-android/harmony/progress_bar_android.har" + } +``` + +* V1.0.6 - "@react-native-oh-tpl/progress-bar-android": "file:../../node_modules/@react-native-oh-tpl/progress-bar-android/harmony/progress_bar_android.har" +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/progress-bar-android": "file:../../node_modules/@react-native-ohos/progress-bar-android/harmony/progress_bar_android.har" } ``` @@ -103,7 +126,7 @@ ohpm install 方法二:直接链接源码 -> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) +> 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) ### 3.配置 CMakeLists 和引入 ProgressBarAndroidPackage @@ -128,7 +151,10 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) +# 0.72 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/progress-bar-android/src/main/cpp" ./progress-bar-android) +# 0.77 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/progress-bar-android/src/main/cpp" ./progress-bar-android) # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -171,8 +197,10 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... +# 0.72 + import { ProgressBarAndroid, PROGRESS_BAR_TYPE } from "@react-native-oh-tpl/progress-bar-android" - +# 0.77 ++ import { ProgressBarAndroid, PROGRESS_BAR_TYPE } from "@react-native-ohos/progress-bar-android" @Builder export function buildCustomRNComponent(ctx: ComponentBuilderContext) { ... @@ -220,21 +248,26 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.0.4 | [@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) | 0.72 | +| 1.0.6 | @react-native-ohos/progress-bar-android Releases | 0.77 | ## 属性 -> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。 +> [!TIP] "平台"列表示该属性在原三方库上支持的平台。 > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 -| Name | Description | Type | Required | Platform | HarmonyOS Support | +| 名称 | 描述 | Type | 必填项 | 平台 | HarmonyOS Support | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------------- | -| `animating` | Whether to show the ProgressBar (true, the default) or hide it (false). | bool | No | Android | yes | -| `color` | Color of the progress bar. | [color](https://reactnative.dev/docs/colors) | No | Android | yes | -| `indeterminate` | If the progress bar will show indeterminate progress. Note that this can only be false if styleAttr is Horizontal, and requires a `progress` value. | indeterminateType | No | Android | yes | -| `progress` | The progress value (between 0 and 1). | number | No | Android | yes | -| `styleAttr` | Style of the ProgressBar. | One of:
Horizontal
Normal (default)
Small
Large
Inverse
SmallInverse
LargeInverse | No | Android | yes | +| `animating` | 是否显示进度条(true,默认)或隐藏(false)。 | bool | 否 | Android | yes | +| `color` | 进度条的颜色。 | [color](https://reactnative.dev/docs/colors) | 否 | Android | yes | +| `indeterminate` | 如果进度条将显示不确定进度。请注意,这只能在 styleAttr 为 Horizontal 时为 false,并且需要 `progress` 值。 | indeterminateType | 否 | Android | yes | +| `progress` | 进度条的进度值(介于 0 和 1 之间)。 | number | 否 | Android | yes | +| `styleAttr` | 进度条的样式。 | One of:
Horizontal
Normal (default)
Small
Large
Inverse
SmallInverse
LargeInverse | 否 | Android | yes | ## 遗留问题 diff --git a/zh-cn/react-native-file-viewer.md b/zh-cn/react-native-file-viewer.md index cf05fce417e47cd22c8211d31d13127886d5351d..6cf4d8022bb173396e1c2a359d300c815e5691af 100644 --- a/zh-cn/react-native-file-viewer.md +++ b/zh-cn/react-native-file-viewer.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-file-viewer Releases](https://github.com/react-native-oh-library/react-native-file-viewer/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.1.5 | [@react-native-oh-tpl/react-native-file-viewer Releases](https://github.com/react-native-oh-library/react-native-file-viewer/releases) | 0.72 | +| 2.2.0-rc.1 | [@react-native-ohos/react-native-file-viewer Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -26,13 +33,21 @@ #### **npm** ```bash +# 0.72 npm install @react-native-oh-tpl/react-native-file-viewer + +# 0.77 +npm install @react-native-ohos/react-native-file-viewer ``` #### **yarn** ```bash +# 0.72 yarn add @react-native-oh-tpl/react-native-file-viewer + +# 0.77 +yarn add @react-native-ohos/react-native-file-viewer ``` @@ -131,6 +146,8 @@ const styles = StyleSheet.create({ ## 使用 Codegen +> [!TIP] RN0.77工程 不需要执行Codegen + 本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。 ## Link @@ -163,6 +180,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +- V2.1.5 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -170,6 +189,15 @@ const styles = StyleSheet.create({ } ``` +- V2.2.0-rc.1 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-file-viewer": "file:../../node_modules/@react-native-ohos/react-native-file-viewer/harmony/file_viewer.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -181,16 +209,83 @@ ohpm install 方法二:直接链接源码 -> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) +> 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) + + +### 3.配置CMakeLists 和引入 FileViewerPackage + +> [!TIP] 若使用的是 RN0.72工程,请跳过本章 + +打开 `entry/src/main/cpp/CMakeLists.txt`,添加: -### 3.在 ArkTs 侧引入 RNFileViewerTurboModule Package +```cmake +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-ohos/react-native-file-viewer/src/main/cpp" ./file-viewer) +# 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_file_viewer) +# RNOH_END: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```c++ +#include "RNOH/PackageProvider.h" +#include "generated/RNOHGeneratedPackage.h" +#include "SamplePackage.h" ++ #include "FileViewerPackage.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.在 ArkTs 侧引入 RNFileViewerTurboModule Package 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... +// 0.72 + import { RNFileViewerPackage } from '@react-native-oh-tpl/react-native-file-viewer/ts'; +// 0.77 ++ import { RNFileViewerPackage } from '@react-native-ohos/react-native-file-viewer/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -199,7 +294,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -218,7 +313,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-file-viewer Releases](https://github.com/react-native-oh-library/react-native-file-viewer/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.1.5 | [@react-native-oh-tpl/react-native-file-viewer Releases](https://github.com/react-native-oh-library/react-native-file-viewer/releases) | 0.72 | +| 2.2.0-rc.1 | [@react-native-ohos/react-native-file-viewer Releases]() | 0.77 | ## API @@ -228,19 +328,19 @@ ohpm install ### `open(filepath: string, options?: Object): Promise` -| Name | Description | Type | Required | Platform | HarmonyOS Support | +| 名称 | 描述 | 类型 | 是否必填 | 平台 | HarmonyOS 支持 | | --- | --- | --- | --- | --- | --- | -| **filepath** | The absolute path where the file is stored. The file needs to have a valid extension to be successfully detected. Use [react-native-fs constants](https://github.com/itinance/react-native-fs#constants) to determine the absolute path correctly. | string | yes | All | yes | -| **options** (optional) | Some options to customize the behaviour. See below. | Object | no | All | yes | +| **filepath** | 文件存储的绝对路径。文件需要有有效的扩展名才能被成功检测。使用 [react-native-fs constants](https://github.com/itinance/react-native-fs#constants) 来正确确定绝对路径。 | string | 是 | 所有 | yes | +| **options** (optional) | 用于自定义行为的一些选项。详见下文。 | Object | 否 | 所有 | yes | -#### Options +#### 属性 -| Name | Description | Type | Required | Platform | HarmonyOS Support | +| 名称 | 描述 | 类型 | 是否必填 | 平台 | HarmonyOS 支持 | | --- | --- | --- | --- | --- | --- | -| **displayName** (optional) | Customize the QuickLook title. | string | no | iOS | yes | -| **onDismiss** (optional) | Callback invoked when the viewer is being dismissed. | function | no | All | partially | -| **showOpenWithDialog** (optional) | If there is more than one app that can open the file, show an _Open With_ dialogue box. | boolean | no | Android | yes | -| **showAppsSuggestions** (optional) | If there is not an installed app that can open the file, open the Play Store with suggested apps. | boolean | no | Android | partially | +| **displayName** (optional) | 自定义QuickLook标题。 | string | 否 | iOS | yes | +| **onDismiss** (optional) | 当查看器被关闭时调用的回调函数。 | function | 否 | 所有 | partially | +| **showOpenWithDialog** (optional) | 如果有多个应用可以打开文件,显示“打开方式”对话框。 | boolean | 否 | Android | yes | +| **showAppsSuggestions** (optional) | 如果没有安装可以打开文件的应用,打开应用商店并显示推荐应用。 | boolean | 否 | Android | partially | ## 遗留问题 diff --git a/zh-cn/react-native-network-info.md b/zh-cn/react-native-network-info.md index 307b4d8e00d866615048482cd0b6683daecdf717..ae3b42a0263715328e0e68d3b32d8b4ec36b6aea 100644 --- a/zh-cn/react-native-network-info.md +++ b/zh-cn/react-native-network-info.md @@ -18,7 +18,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 5.2.1 | [@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) | 0.72 | +| 5.3.0-rc.1 | @react-native-ohos/react-native-network-info Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -27,13 +34,19 @@ #### **npm** ```bash +# 0.72 npm install @react-native-oh-tpl/react-native-network-info +# 0.77 +npm install @react-native-ohos/react-native-network-info ``` #### **yarn** ```bash -yarn add @react-native-oh-tpl/react-native-network-info +# 0.72 +yarn install @react-native-oh-tpl/react-native-network-info +# 0.77 +yarn install @react-native-ohos/react-native-network-info ``` @@ -185,6 +198,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +* V5.2.1 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -192,6 +207,15 @@ const styles = StyleSheet.create({ } ``` +* V5.2.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-network-info": "file:../../node_modules/@react-native-ohos/react-native-network-info/harmony/rn_network_info.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -203,17 +227,69 @@ ohpm install 方法二:直接链接源码 -> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) +> 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 RNNetworkInfoPackage +### 3.配置 CMakeLists 和引入 RNOrientationPackage + +> [!TIP] 版本 `5.2.2` 及以上需要 + +打开 `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(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_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-network-info/src/main/cpp" ./rn_network_info) +# RNOH_END: manual_package_linking_1 + +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_network_info) +# RNOH_END: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "NetworkInfoPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx), + }; +} +``` + +### 4.在 ArkTs 侧引入 RNNetworkInfoPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... - + # 0.72 + import { RNNetworkInfoPackage } from '@react-native-oh-tpl/react-native-network-info/ts'; - + # 0.77 ++ import { RNNetworkInfoPackage } from '@react-native-ohos/react-native-network-info/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -222,7 +298,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -241,7 +317,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 5.2.1 | [@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) | 0.72 | +| 5.2.2 | @react-native-ohos/react-native-network-info Releases | 0.77 | ### 权限要求 @@ -263,20 +344,20 @@ ohpm install ## 静态方法 -> [!TIP]"Platform"列表示该属性在原三方库上支持的平台。 +> [!TIP]"平台"列表示该属性在原三方库上支持的平台。 > [!TIP]"HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 -Name | Description | Type | Required | Platform | HarmonyOS Support --- | -- | -- | -- | -- | -- -getSSID | Get SSID | Function | no | All | yes -getBSSID | Get BSSID | Function | no | All | yes -getBroadcast | Get Broadcast | Function | no | All | yes -getIPAddress | Get Local IP | Function | no | All | yes -getIPV4Address | Get IPv4 IP (priority: WiFi first, cellular second) | Function | no | All | yes -getSubnet | Get Subnet | Function | no | All | yes -getGatewayIPAddress | Get Default Gateway IP | Function | no | All | yes -getFrequency | Get frequency | Function | no | Android | yes +| 名称 | 描述 | 类型 | 必填项 | 平台 | HarmonyOS Support | +| -- | -- | -- | -- | -- | -- | +getSSID | 获取 SSID | 函数 | 否 | 所有 | yes | +getBSSID | 获取 BSSID | 函数 | 否 | 所有 | yes | +getBroadcast | 获取广播地址 | 函数 | 否 | 所有 | yes | +getIPAddress | 获取本地 IP 地址 | 函数 | 否 | 所有 | yes | +getIPV4Address | 获取 IPv4 IP 地址(优先 WiFi,其次蜂窝网络) | 函数 | 否 | 所有 | yes | +getSubnet | 获取子网掩码 | 函数 | 否 | 所有 | yes | +getGatewayIPAddress | 获取默认网关 IP 地址 | 函数 | 否 | 所有 | yes | +getFrequency | 获取频率 | 函数 | 否 | Android | yes | ## 遗留问题 diff --git a/zh-cn/react-native-orientation.md b/zh-cn/react-native-orientation.md index 8862a51a52c8bfb621e97ed406d7587da582dcf9..d93ad7b3a8f9b34a4c33732a66d9e130fd1a853e 100644 --- a/zh-cn/react-native-orientation.md +++ b/zh-cn/react-native-orientation.md @@ -16,23 +16,35 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-library/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: -进入到工程目录并输入以下命令: +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.3 | [@react-native-oh-tpl/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) | 0.72 | +| 3.2.0-rc.1 | @react-native-ohos/react-native-orientation Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +进入到工程目录并输入以下命令: #### npm ```bash +# 0.72 npm install @react-native-oh-tpl/react-native-orientation +# 0.77 +npm install @react-native-ohos/react-native-orientation ``` #### yarn ```bash -yarn add @react-native-oh-tpl/react-native-orientation +# 0.72 +yarn install @react-native-oh-tpl/react-native-orientation +# 0.77 +yarn install @react-native-ohos/react-native-orientation ``` @@ -183,7 +195,7 @@ const styles = StyleSheet.create({ 首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony` -### 在工程根目录的 `oh-package.json5` 添加 overrides字段 +### 1.在工程根目录的 `oh-package.json5` 添加 overrides字段 ```json { @@ -206,6 +218,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +* V3.1.3 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -213,6 +227,17 @@ const styles = StyleSheet.create({ } ``` +* V3.1.4 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-orientation": "file:../../node_modules/@react-native-ohos/react-native-orientation/harmony/rn_orientation.har", + } +``` + + + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -224,7 +249,7 @@ ohpm install 方法二:直接链接源码 -> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) +> 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) 打开终端,执行: @@ -233,13 +258,67 @@ cd entry ohpm install --no-link ``` -### 3.在 ArkTs 侧引入 RNOrientationPackage +### 3.配置 CMakeLists 和引入 RNOrientationPackage + +> [!TIP] 版本 `3.1.4` 及以上需要 + +打开 `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(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_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-orientation/src/main/cpp" ./rn_orientation) +# RNOH_END: manual_package_linking_1 + +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_orientation) +# RNOH_END: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "RNOritentionPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx), + }; +} +``` + +### 4.在 ArkTs 侧引入 RNOrientationPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... + # 0.72 + import { RNOrientationPackage } from '@react-native-oh-tpl/react-native-orientation/ts'; + # 0.77 ++ import { RNOrientationPackage } from '@react-native-ohos/react-native-orientation/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ @@ -249,7 +328,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -268,7 +347,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-library/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.3 | [@react-native-oh-tpl/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) | 0.72 | +| 3.1.4 | @react-native-ohos/react-native-orientation Releases | 0.77 | ## API @@ -278,15 +362,15 @@ ohpm install 详情请见[react-native-orientation](https://github.com/yamill/react-native-orientation?tab=readme-ov-file#api) -| Name | Description | Type | Required | Platform | HarmonyOS Support | +| 名称 | 描述 | 类型 | 必填项 | 平台 | HarmonyOS Support | | -------------- | ---------------------------------------- | ------ | -------- | ----------- | ----------------- | -| lockToPortrait | Lock the orientation of the application to portrait (portrait) | function | No | IOS/Android | yes | -| lockToLandscape | Lock the orientation of the application to landscape (landscape) | function | No | IOS/Android | yes | -| lockToLandscapeLeft | Lock the orientation of the app to landscape and rotated to the left | function | No | IOS/Android | yes | -| lockToLandscapeRight | Lock the orientation of the app to landscape and rotated to the right | function | No | IOS/Android | yes | -| unlockAllOrientations | Unlocks the orientation of the app, allowing the device to rotate freely | function | No | IOS/Android | yes | -| getOrientation | Get the direction of the current device | callback | No | IOS/Android | yes | -| getSpecificOrientation | Obtains the direction of the current device | callback | No | IOS/Android | yes | +| lockToPortrait | 锁定应用程序的方向为纵向(portrait) | function | 否 | IOS/Android | yes | +| lockToLandscape | 锁定应用程序的方向为横向(landscape) | function | 否 | IOS/Android | yes | +| lockToLandscapeLeft | 锁定应用程序的方向为横向并向左旋转 | function | 否 | IOS/Android | yes | +| lockToLandscapeRight | 锁定应用程序的方向为横向并向右旋转 | function | 否 | IOS/Android | yes | +| unlockAllOrientations | 解锁应用程序的方向,允许设备自由旋转 | function | 否 | IOS/Android | yes | +| getOrientation | 获取当前设备的方向 | callback | 否 | IOS/Android | yes | +| getSpecificOrientation | 获取当前设备的具体方向 | callback | 否 | IOS/Android | yes | ## Events @@ -296,12 +380,12 @@ ohpm install 详情请见[react-native-orientation](https://github.com/yamill/react-native-orientation?tab=readme-ov-file#orientation-events) -| Name | Description | Type | Required | Platform | HarmonyOS Support | +| 名称 | 描述 | 类型 | 必填项 | 平台 | HarmonyOS Support | | -------------- | ---------------------------------------- | ------ | -------- | ----------- | ----------------- | -| addOrientationListener | Enable monitoring of screen orientation changes | callback | No | IOS/Android | yes | -| addSpecificOrientationListener | Start to monitor the change of screen orientation | callback | No | IOS/Android | yes | -| removeOrientationListener | Remove Listen Screen Orientation Change | callback | No | IOS/Android | yes | -| removeSpecificOrientationListener | Remove Monitor Screen Specific Orientation Change | callback | No | IOS/Android | yes | +| addOrientationListener | 启用监听屏幕方向变化事件 | callback | 否 | IOS/Android | yes | +| addSpecificOrientationListener | 开始监听屏幕具体方向变化事件 | callback | 否 | IOS/Android | yes | +| removeOrientationListener | 移除监听屏幕方向变化事件 | callback | 否 | IOS/Android | yes | +| removeSpecificOrientationListener | 移除监听屏幕具体方向变化事件 | callback | 否 | IOS/Android | yes | ## 其他 ## 开源协议