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 (
-
-
-
-
-
-
-
-
-
-
-
-> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-bottom-sheet)
-
-## 安装与使用
-
-请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-library/bottom-sheet Releases](https://github.com/react-native-oh-library/react-native-bottom-sheet/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。
-
-
-
-#### npm
-
-```bash
-npm install @react-native-oh-tpl/bottom-sheet
-```
-
-#### yarn
-
-```bash
-yarn add @react-native-oh-tpl/bottom-sheet
-```
-
-
-
-下面的代码展示了这个库的基本使用场景:
-
->[!WARNING] 使用时 import 的库名不变。
-
-```jsx
-// bottom-sheet组件
-import React, { useCallback, useRef, useMemo } from "react";
-import { StyleSheet, View, Text, Button } from "react-native";
-import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet";
-
-const App = () => {
- // hooks
- const sheetRef = useRef(null);
-
- // variables
- const snapPoints = useMemo(() => ["25%", "50%", "90%"], []);
-
- // callbacks
- const handleSheetChange = useCallback((index) => {
- console.log("handleSheetChange", index);
- }, []);
- const handleSnapPress = useCallback((index) => {
- sheetRef.current?.snapToIndex(index);
- }, []);
- const handleClosePress = useCallback(() => {
- sheetRef.current?.close();
- }, []);
-
- // render
- return (
-
- handleSnapPress(2)} />
- handleSnapPress(1)} />
- handleSnapPress(0)} />
- handleClosePress()} />
-
-
- Awesome 🔥
-
-
-
- );
-};
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- paddingTop: 200,
- },
-});
-
-export default App;
-```
-```jsx
-// bottom-sheet-modal组件
-import React, { useCallback, useMemo, useRef } from 'react';
-import { View, Text, StyleSheet, Button } from 'react-native';
-import {
- BottomSheetModal,
- BottomSheetView,
- BottomSheetModalProvider,
-} from '@gorhom/bottom-sheet';
-
-const App = () => {
- // ref
- const bottomSheetModalRef = useRef(null);
-
- // variables
- const snapPoints = useMemo(() => ['25%', '50%'], []);
-
- // callbacks
- const handlePresentModalPress = useCallback(() => {
- bottomSheetModalRef.current?.present();
- }, []);
- const handleSheetChanges = useCallback((index: number) => {
- console.log('handleSheetChanges', index);
- }, []);
-
- // renders
- return (
-
-
-
-
-
- Awesome 🎉
-
-
-
-
- );
-};
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- padding: 24,
- justifyContent: 'center',
- backgroundColor: 'grey',
- },
- contentContainer: {
- flex: 1,
- alignItems: 'center',
- },
-});
-
-export default App;
-```
-## 使用codegen
-
-本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。
-
-## Link
-
-本库鸿蒙侧实现依赖@react-native-oh-tpl/react-native-reanimated和@react-native-oh-tpl/react-native-gesture-handler的原生端代码,如已在鸿蒙工程中引入过该库,则无需再次引入,可跳过本章节步骤,直接使用。
-
-如未引入请参照[@react-native-oh-tpl/react-native-reanimated 文档](/zh-cn/react-native-reanimated.md)、[@react-native-oh-tpl/react-native-gesture-handler 文档](/zh-cn/react-native-gesture-handler.md)进行引入
-
-## 约束与限制
-
-### 兼容性
-
-本文档内容基于以下版本验证通过:
-
-1.RNOH: 0.72.29; SDK:HarmonyOS-Next-DB1 5.0.0.61; IDE:DevEco Studio 5.0.3.706; ROM:5.0.0.61;
-
-## 属性
-
-> [!Tip] "Platform"列表示该属性在原三方库上支持的平台。
-
-> [!Tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
-### Bottom Sheet
-#### Configuration
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| index | Initial snap index. You also could provide -1 to initiate bottom sheet in closed state. | number | No | Android / iOS | Yes |
-| snapPoints | Points for the bottom sheet to snap to, points should be sorted from bottom to top. It accepts array of number, string or mix. | Array\| SharedValue> | Yes | Android / iOS | Yes |
-| overDragResistanceFactor | Defines how violently sheet has to be stopped while over dragging. | number | No | Android / iOS | Yes |
-| detached | Defines whether the bottom sheet is attached to the bottom or no. | boolean | No | Android / iOS | Yes |
-| enableContentPanningGesture | Enable content panning gesture interaction. | boolean | No | Android / iOS | Yes |
-| enableHandlePanningGesture | Enable handle panning gesture interaction. | boolean | No | Android / iOS | Yes |
-| enableOverDrag | Enable over drag for the sheet. | boolean | No | Android / iOS | Yes |
-| enablePanDownToClose | Enable pan down gesture to close the sheet. | boolean | No | Android / iOS | Yes |
-| enableDynamicSizing | Enable dynamic sizing for content view and scrollable content size. | boolean | No | Android / iOS | Yes |
-| animateOnMount | This will initially mount the sheet closed and when it's mounted and calculated the layout, it will snap to initial snap point index. | boolean | No | Android / iOS | Yes |
-#### Styles
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| style | View style to be applied at the sheet container, it also could be an AnimatedStyle. This is helpful to add shadow to the sheet. | ViewStyle \| AnimatedStyle | No | Android / iOS | Yes |
-| backgroundStyle | View style to be applied to the background component. | ViewStyle | No | Android / iOS | Yes |
-| handleStyle | View style to be applied to the handle indicator component. | ViewStyle | No | Android / iOS | Yes |
-| handleIndicatorStyle | View style to be applied to the handle indicator component. | ViewStyle | No | Android / iOS | Yes |
-#### Layout Configuration
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| handleHeight | Handle height helps to calculate the internal container and sheet layouts. If handleComponent is provided, the library internally will calculate its layout, unless handleHeight is provided too. | number | No | Android / iOS | Yes |
-| containerHeight | Container height helps to calculate the internal sheet layouts. If containerHeight not provided, the library internally will calculate it, however this will cause an extra re-rendering. | number | No | Android / iOS | Yes |
-| contentHeight | Content height helps dynamic snap points calculation. | number \| Animated.SharedValue\ | No | Android / iOS | Yes |
-| containerOffset | Container offset helps to accurately detect container offsets. | Animated.SharedValue\ | No | Android / iOS | Yes |
-| topInset | Top inset to be added to the bottom sheet container, usually it comes from @react-navigation/stack hook useHeaderHeight or from react-native-safe-area-context hook useSafeArea. | number | No | Android / iOS | Yes |
-| bottomInset | Bottom inset to be added to the bottom sheet container. | number | No | Android / iOS | Yes |
-| maxDynamicContentSize | Max dynamic content size height to limit the bottom sheet height from exceeding a provided size. | number | No | Android / iOS | Yes |
-#### Keyboard Configuration
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| keyboardBehavior | Defines the keyboard appearance behavior;`extend:` extend the sheet to its maximum snap point;`fillParent:` extend the sheet to fill the parent view;`interactive: `offset the sheet by the size of the keyboard. | 'extend' \| 'fillParent' \| 'interactive' | No | Android / iOS | Yes |
-| keyboardBlurBehavior | Defines the keyboard blur behavior;none: do nothing;restore: restore sheet position | 'none' \| 'restore' | No | Android / iOS | Yes |
-| android_keyboardInputMode | Defines keyboard input mode for Android only. | 'adjustPan' \| 'adjustResize' | No | Android | No |
-#### Animation Configuration
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| animationConfigs | Animation configs. | function | No | Android/iOS | Yes |
-#### Gesture Configuration
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| waitFor | - | React.Ref \| React.Ref[] | No | Android/iOS | Yes |
-| simultaneousHandlers | - | React.Ref \| React.Ref[] | No | Android/iOS | Yes |
-| activeOffsetX | - | number[] | No | Android/iOS | Yes |
-| activeOffsetY | - | number[] | No | Android/iOS | Yes |
-| failOffsetX | - | number[] | No | Android/iOS | Yes |
-| failOffsetY | - | number[] | No | Android/iOS | Yes |
-| gestureEventsHandlersHook | Custom hook to provide pan gesture events handler, which will allow advance and customize handling for pan gesture. | GestureEventsHandlersHookType | No | Android/iOS | Yes |
-
-#### Animated Nodes
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| animatedIndex | Animated value to be used as a callback for the index node internally. | Animated.SharedValue\ | No | Android/iOS | Yes |
-| animatedPosition | Animated value to be used as a callback for the position node internally. | Animated.SharedValue\ | No | Android/iOS | Yes |
-
-#### Callbacks
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| onChange | Callback when the sheet position changed. | function | No | Android/iOS | Yes |
-| onAnimate | Callback when the sheet about to animate to a new position. | function | No | Android/iOS | Yes |
-
-#### Components
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| handleComponent | Component to be placed as a sheet handle. | React.FC\ | No | Android/iOS | Yes |
-| backdropComponent | Component to be placed as a sheet backdrop, by default is set to null, however the library also provide a default implementation BottomSheetBackdrop of a backdrop but you will need to provide it manually. | React.FC\ | No | Android/iOS | Yes |
-| backgroundComponent | Component to be placed as a sheet background. | React.FC\ | No | Android/iOS | Yes |
-| footerComponent | Component to be placed as a sheet footer. | React.FC\ | No | Android/iOS | Yes |
-| children | Scrollable node or react node to be places as a sheet content. | () => React.ReactNode \| React.ReactNode[] \| React.ReactNode | No | Android/iOS | Yes |
-### Bottom Sheet Modal
-> [!Tip]Bottom Sheet Modal inherits all [Bottom Sheet props](https://ui.gorhom.dev/components/bottom-sheet/props) except for animateOnMount & containerHeight and also it introduces its own props
-
-| Name | Description | Type | Required | Platform | HarmonyOS Support |
-|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
-| name | Modal name to help identify the modal for later on. | string | No | Android/iOS | Yes |
-| stackBehavior | Defines the stack behavior when modal mounts. | 'push' \| 'replace' | No | Android/iOS | Yes |
-| enableDismissOnClose | Dismiss the modal when it is closed, this will unmount the modal. | boolean | No | Android/iOS | Yes |
-| onDismiss | Callback when the modal dismissed (unmounted). | function | No | Android/iOS | Yes |
-| containerComponent | Component to be placed as a bottom sheet container, this is to place the bottom sheet at the very top layer of your application when using FullWindowOverlay from React Native Screens. | React.ReactNode | No | Android/iOS | Yes |
-## 遗留问题
-- [ ] BottomSheetFlatList组件手势滑动存在冲突 [issue#6](https://github.com/react-native-oh-library/react-native-bottom-sheet/issues/6)
-## 其他
-
-## 开源协议
-
-本项目基于 [The MIT License (MIT)](hhttps://github.com/gorhom/react-native-bottom-sheet/blob/master/LICENSE) ,请自由地享受和参与开源。
+> 模板版本:v0.2.2
+
+
+
@gorhom/bottom-sheet
+
+
+
+
+
+
+
+
+
+
+> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-bottom-sheet)
+
+## 安装与使用
+
+请到三方库的 Releases 发布地址查看配套的版本信息:
+
+| 三方库版本 | 发布信息 | 支持RN版本 |
+| ---------- | ------------------------------------------------------------ | ---------- |
+| 4.6.4 | [@react-native-oh-library/bottom-sheet Releases](https://github.com/react-native-oh-library/react-native-bottom-sheet/releases) | 0.72 |
+| 5.1.6 | [@react-native-oh-library/bottom-sheet Releases]() | 0.77 |
+
+对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。
+
+
+
+#### npm
+
+```bash
+# V4.6.4
+npm install @react-native-oh-tpl/bottom-sheet
+
+# V5.1.6
+npm install @react-native-ohos/bottom-sheet
+```
+
+#### yarn
+
+```bash
+# V4.6.4
+yarn add @react-native-oh-tpl/bottom-sheet
+
+# V5.1.6
+yarn add @react-native-ohos/bottom-sheet
+```
+
+
+
+下面的代码展示了这个库的基本使用场景:
+
+>[!WARNING] 使用时 import 的库名不变。
+
+```jsx
+// bottom-sheet组件
+import React, { useCallback, useRef, useMemo } from "react";
+import { StyleSheet, View, Text, Button } from "react-native";
+import { GestureHandlerRootView } from 'react-native-gesture-handler';
+import BottomSheet, { BottomSheetView } from "@gorhom/bottom-sheet";
+
+const App = () => {
+ // hooks
+ const sheetRef = useRef(null);
+
+ // variables
+ const snapPoints = useMemo(() => ["25%", "50%", "90%"], []);
+
+ // callbacks
+ const handleSheetChange = useCallback((index) => {
+ console.log("handleSheetChange", index);
+ }, []);
+ const handleSnapPress = useCallback((index) => {
+ sheetRef.current?.snapToIndex(index);
+ }, []);
+ const handleClosePress = useCallback(() => {
+ sheetRef.current?.close();
+ }, []);
+
+ // render
+ return (
+
+ handleSnapPress(2)} />
+ handleSnapPress(1)} />
+ handleSnapPress(0)} />
+ handleClosePress()} />
+
+
+ Awesome 🔥
+
+
+
+ );
+};
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ paddingTop: 200,
+ backgroundColor: 'grey'
+ },
+ contentContainer: {
+ flex: 1,
+ padding: 36,
+ alignItems: 'center',
+ },
+});
+
+export default App;
+```
+```jsx
+// bottom-sheet-modal组件
+import React, { useCallback, useMemo, useRef } from 'react';
+import { View, Text, StyleSheet, Button } from 'react-native';
+import { GestureHandlerRootView } from 'react-native-gesture-handler';
+import {
+ BottomSheetModal,
+ BottomSheetView,
+ BottomSheetModalProvider,
+} from '@gorhom/bottom-sheet';
+
+const App = () => {
+ // ref
+ const bottomSheetModalRef = useRef(null);
+
+ // callbacks
+ const handlePresentModalPress = useCallback(() => {
+ bottomSheetModalRef.current?.present();
+ }, []);
+ const handleSheetChanges = useCallback((index: number) => {
+ console.log('handleSheetChanges', index);
+ }, []);
+
+ // renders
+ return (
+
+
+
+
+
+ Awesome 🎉
+
+
+
+
+ );
+};
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ padding: 24,
+ justifyContent: 'center',
+ backgroundColor: 'grey',
+ },
+ contentContainer: {
+ flex: 1,
+ alignItems: 'center',
+ height: 200,
+ },
+});
+
+export default App;
+```
+## 使用Codegen
+
+本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](/zh-cn/codegen.md)。
+
+**注意:**V5.1.6不需要执行Codegen。
+
+## Link
+
+本库鸿蒙侧实现依赖@react-native-ohos/react-native-reanimated和@react-native-ohos/react-native-gesture-handler的原生端代码,如已在鸿蒙工程中引入过该库,则无需再次引入,可跳过本章节步骤,直接使用。
+
+如未引入请参照[@react-native-ohos/react-native-reanimated 文档](/zh-cn/react-native-reanimated.md)、[@react-native-ohos/react-native-gesture-handler 文档](/zh-cn/react-native-gesture-handler.md)进行引入
+
+## 约束与限制
+
+### 兼容性
+
+该库是基于react-native-bottom-sheet进行适配,要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
+
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:
+
+| 三方库版本 | 发布信息 | 支持RN版本 |
+| ---------- | ------------------------------------------------------------ | ---------- |
+| 4.6.4 | [@react-native-oh-tpl/bottom-sheet Releases](https://github.com/react-native-oh-library/react-native-bottom-sheet/releases) | 0.72 |
+| 5.1.6 | [@react-native-ohos/bottom-sheet Releases]() | 0.77 |
+
+## 属性
+
+> [!Tip] "Platform"列表示该属性在原三方库上支持的平台。
+
+> [!Tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
+### Bottom Sheet
+#### Configuration
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| index | Initial snap index. You also could provide -1 to initiate bottom sheet in closed state. | number | No | Android / iOS | Yes |
+| snapPoints | Points for the bottom sheet to snap to, points should be sorted from bottom to top. It accepts array of number, string or mix. | Array\| SharedValue> | Yes | Android / iOS | Yes |
+| overDragResistanceFactor | Defines how violently sheet has to be stopped while over dragging. | number | No | Android / iOS | Yes |
+| detached | Defines whether the bottom sheet is attached to the bottom or no. | boolean | No | Android / iOS | Yes |
+| enableContentPanningGesture | Enable content panning gesture interaction. | boolean | No | Android / iOS | Yes |
+| enableHandlePanningGesture | Enable handle panning gesture interaction. | boolean | No | Android / iOS | Yes |
+| enableOverDrag | Enable over drag for the sheet. | boolean | No | Android / iOS | Yes |
+| enablePanDownToClose | Enable pan down gesture to close the sheet. | boolean | No | Android / iOS | Yes |
+| enableDynamicSizing | Enable dynamic sizing for content view and scrollable content size. | boolean | No | Android / iOS | Yes |
+| animateOnMount | This will initially mount the sheet closed and when it's mounted and calculated the layout, it will snap to initial snap point index. | boolean | No | Android / iOS | Yes |
+| overrideReduceMotion | To override the user reduce motion accessibility setting. | booleReduceMotion.System 、 ReduceMotion.Always 、 ReduceMotion.Neveran | No | Android / iOS | Yes |
+| overrideReduceMotion5.1.6+ | To override the user reduce motion accessibility setting. | ReduceMotion..System \| ReduceMotion.Always \| ReduceMotion.Never | No | Android / iOS | Yes |
+#### Styles
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| style | View style to be applied at the sheet container, it also could be an AnimatedStyle. This is helpful to add shadow to the sheet. | ViewStyle \| AnimatedStyle | No | Android / iOS | Yes |
+| backgroundStyle | View style to be applied to the background component. | ViewStyle | No | Android / iOS | Yes |
+| handleStyle | View style to be applied to the handle indicator component. | ViewStyle | No | Android / iOS | Yes |
+| handleIndicatorStyle | View style to be applied to the handle indicator component. | ViewStyle | No | Android / iOS | Yes |
+#### Layout Configuration
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| handleHeight | Handle height helps to calculate the internal container and sheet layouts. If handleComponent is provided, the library internally will calculate its layout, unless handleHeight is provided too. | number | No | Android / iOS | Yes |
+| containerHeight | Container height helps to calculate the internal sheet layouts. If containerHeight not provided, the library internally will calculate it, however this will cause an extra re-rendering. | number | No | Android / iOS | Yes |
+| contentHeight | Content height helps dynamic snap points calculation. | number \| Animated.SharedValue\ | No | Android / iOS | Yes |
+| containerOffset | Container offset helps to accurately detect container offsets. | Animated.SharedValue\ | No | Android / iOS | Yes |
+| topInset | Top inset to be added to the bottom sheet container, usually it comes from @react-navigation/stack hook useHeaderHeight or from react-native-safe-area-context hook useSafeArea. | number | No | Android / iOS | Yes |
+| bottomInset | Bottom inset to be added to the bottom sheet container. | number | No | Android / iOS | Yes |
+| maxDynamicContentSize | Max dynamic content size height to limit the bottom sheet height from exceeding a provided size. | number | No | Android / iOS | Yes |
+#### Keyboard Configuration
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| keyboardBehavior | Defines the keyboard appearance behavior;`extend:` extend the sheet to its maximum snap point;`fillParent:` extend the sheet to fill the parent view;`interactive: `offset the sheet by the size of the keyboard. | 'extend' \| 'fillParent' \| 'interactive' | No | Android / iOS | Yes |
+| keyboardBlurBehavior | Defines the keyboard blur behavior;none: do nothing;restore: restore sheet position | 'none' \| 'restore' | No | Android / iOS | Yes |
+| android_keyboardInputMode | Defines keyboard input mode for Android only. | 'adjustPan' \| 'adjustResize' | No | Android | No |
+| enableBlurKeyboardOnGesture | Enable blurring the keyboard when user start to drag the bottom false. | boolean | No | Android / iOS | Yes |
+| enableBlurKeyboardOnGesture5.1.6+ | Enable blurring the keyboard when user start to drag the bottom false. | boolean | No | Android / iOS | Yes |
+#### Animation Configuration
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| animationConfigs | Animation configs. | function | No | Android/iOS | Yes |
+#### Gesture Configuration
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| waitFor | - | React.Ref \| React.Ref[] | No | Android/iOS | Yes |
+| simultaneousHandlers | - | React.Ref \| React.Ref[] | No | Android/iOS | Yes |
+| activeOffsetX | - | number[] | No | Android/iOS | Yes |
+| activeOffsetY | - | number[] | No | Android/iOS | Yes |
+| failOffsetX | - | number[] | No | Android/iOS | Yes |
+| failOffsetY | - | number[] | No | Android/iOS | Yes |
+| gestureEventsHandlersHook | Custom hook to provide pan gesture events handler, which will allow advance and customize handling for pan gesture. | GestureEventsHandlersHookType | No | Android/iOS | Yes |
+
+#### Animated Nodes
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| animatedIndex | Animated value to be used as a callback for the index node internally. | Animated.SharedValue\ | No | Android/iOS | Yes |
+| animatedPosition | Animated value to be used as a callback for the position node internally. | Animated.SharedValue\ | No | Android/iOS | Yes |
+
+#### Callbacks
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| onChange | Callback when the sheet position changed. | function | No | Android/iOS | Yes |
+| onAnimate | Callback when the sheet about to animate to a new position. | function | No | Android/iOS | Yes |
+
+#### Components
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| handleComponent | Component to be placed as a sheet handle. | React.FC\ | No | Android/iOS | Yes |
+| backdropComponent | Component to be placed as a sheet backdrop, by default is set to null, however the library also provide a default implementation BottomSheetBackdrop of a backdrop but you will need to provide it manually. | React.FC\ | No | Android/iOS | Yes |
+| backgroundComponent | Component to be placed as a sheet background. | React.FC\ | No | Android/iOS | Yes |
+| footerComponent | Component to be placed as a sheet footer. | React.FC\ | No | Android/iOS | Yes |
+| children | Scrollable node or react node to be places as a sheet content. | () => React.ReactNode \| React.ReactNode[] \| React.ReactNode | No | Android/iOS | Yes |
+### Bottom Sheet Modal
+> [!Tip]Bottom Sheet Modal inherits all [Bottom Sheet props](https://ui.gorhom.dev/components/bottom-sheet/props) except for animateOnMount & containerHeight and also it introduces its own props
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+|----------------|-------------------------------| -- | -------- | ----------- | ----------------- |
+| name | Modal name to help identify the modal for later on. | string | No | Android/iOS | Yes |
+| stackBehavior | Defines the stack behavior when modal mounts. | 'push' \| 'replace' | No | Android/iOS | Yes |
+| enableDismissOnClose | Dismiss the modal when it is closed, this will unmount the modal. | boolean | No | Android/iOS | Yes |
+| onDismiss | Callback when the modal dismissed (unmounted). | function | No | Android/iOS | Yes |
+| containerComponent | Component to be placed as a bottom sheet container, this is to place the bottom sheet at the very top layer of your application when using FullWindowOverlay from React Native Screens. | React.ReactNode | No | Android/iOS | Yes |
+## 遗留问题
+- [ ] BottomSheetFlatList组件手势滑动存在冲突 [issue#6](https://github.com/react-native-oh-library/react-native-bottom-sheet/issues/6)
+## 其他
+
+## 开源协议
+
+本项目基于 [The MIT License (MIT)](hhttps://github.com/gorhom/react-native-bottom-sheet/blob/master/LICENSE) ,请自由地享受和参与开源。
diff --git a/zh-cn/jpush-react-native.md b/zh-cn/jpush-react-native.md
index 97e5c6d96c37667fb289ce7c3da8aa3ebdbb12dd..2b554555bcdfcd66a7f95492da6d750c34314f23 100644
--- a/zh-cn/jpush-react-native.md
+++ b/zh-cn/jpush-react-native.md
@@ -17,7 +17,14 @@
## 安装与使用
-请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/jpush-react-native Releases](https://github.com/react-native-oh-library/jpush-react-native/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。
+请到三方库的 Releases 发布地址查看配套的版本信息:
+
+| 三方库版本 | 发布信息 | 支持RN版本 |
+| ---------- | ------------------------------------------------------------ | ---------- |
+| 3.1.1 | [@react-native-oh-tpl/jpush-react-native Releases](https://github.com/react-native-oh-library/jpush-react-native/releases) | 0.72 |
+| 3.1.8 | [@react-native-ohos/jpush-react-native Releases]() | 0.77 |
+
+对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。
进入到工程目录并输入以下命令:
@@ -25,13 +32,21 @@
#### **npm**
```bash
+# V3.1.1
npm install @react-native-oh-tpl/jpush-react-native
+
+# V3.1.8
+npm install @react-native-ohos/jpush-react-native
```
#### **yarn**
```bash
+# V3.1.1
yarn add @react-native-oh-tpl/jpush-react-native
+
+# V3.1.8
+yarn add @react-native-ohos/jpush-react-native
```
@@ -81,6 +96,8 @@ export default App;
本库已经适配了 `Codegen` ,在使用前需要主动执行生成三方库桥接代码,详细请参考[ Codegen 使用文档](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/codegen.md)。
+**注意:** V3.1.1 不需要执行 Codegen。
+
## Link
目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。
@@ -112,13 +129,22 @@ export default App;
打开 `entry/oh-package.json5`,添加以下依赖
-```json
+- V3.1.1
+```json
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
"@react-native-oh-tpl/jpush-react-native": "file:../../node_modules/@react-native-oh-tpl/jpush-react-native/harmony/jpush_react_native.har"
}
+```
+- V3.1.8
+
+```json
+"dependencies": {
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
+ "@react-native-ohos/jpush-react-native": "file:../../node_modules/@react-native-ohos/jpush-react-native/harmony/jpush_react_native.har"
+}
```
点击右上角的 `sync` 按钮
@@ -134,14 +160,64 @@ ohpm install
> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md)
+### 3. 配置 CMakeLists 和引入 RNJPushPackage
+
+> V3.1.8 需要配置 CMakeLists 和引入 RNJPushPackage。
+
+```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/jpush-react-native/src/main/cpp" ./jPushModule)
+# 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`,添加:
-### 3. 在 ArkTs 侧引入 RNJPushPackage
+```diff
+#include "RNOH/PackageProvider.h"
++ #include "JPushModulePackage.h"
+
+using namespace rnoh;
+
+std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {
++ std::make_shared(ctx)
+}
+```
+
+### 4. 在 ArkTs 侧引入 RNJPushPackage
打开 `entry/src/main/ets/RNPackagesFactory.ts`,由于引入的是ets文件,请将RNPackagesFactory.ts文件名后缀 ts 修改为 ets,添加:
```diff
+// V3.1.1
+ import {RNJPushPackage} from "@react-native-oh-tpl/jpush-react-native/ts";
+// V3.1.8
++ import {RNJPushPackage} from "@react-native-ohos/jpush-react-native/ts";
+
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
return [
new SamplePackage(ctx),
@@ -150,7 +226,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
}
```
-### 4. 运行
+### 5. 运行
点击右上角的 `sync` 按钮
@@ -170,7 +246,12 @@ ohpm install
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
-请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/jpush-react-native Releases](https://github.com/react-native-oh-library/jpush-react-native/releases)
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:
+
+| 三方库版本 | 发布信息 | 支持RN版本 |
+| ---------- | ------------------------------------------------------------ | ---------- |
+| 3.1.1 | [@react-native-oh-tpl/jpush-react-native Releases](https://github.com/react-native-oh-library/jpush-react-native/releases) | 0.72 |
+| 3.1.8 | [@react-native-ohos/jpush-react-native Releases]() | 0.77 |
## 静态方法
@@ -231,9 +312,11 @@ ohpm install
| setSmartPushEnable(enable:boolean):void | 是否开启智能推送 |function | no | iOS,Android | no |
| setGeofenceEnable(enable:boolean):void | 是否开启地理围栏 |function | no |Android | no |
| setCollectControl(enable:boolean):void | 是否开启集中控制 |function | no | iOS、Android | no |
+| setDataInsightsEnable()3.1.8+ | 设置应用数据洞察 |function | no | Android | no |
## 遗留问题
- [ ] setProperties、deleteProperties、cleanProperties、pageEnterTo、pageLeave、initCrashHandler、setMaxGeofenceNumber、deleteGeofence、addNotificationListener、addInappMessageListener,setCollectControl、setSmartPushEnable这些方法在极光推送harmonyOS-SDK中暂未支持[issue#1](https://github.com/react-native-oh-library/jpush-react-native/issues/1)
+- [ ] V3.1.8 部分属性未实现 HarmonyOS 化 [issue#1](https://gitcode.com/openharmony-sig/rntpc_jpush-react-native/issues/1)
## 其他
diff --git a/zh-cn/react-native-ble-plx.md b/zh-cn/react-native-ble-plx.md
index 02b9d7268b61b4cdff372fac2dcc8d77def4f2cd..bdb1fd2a1b95a45735916ebcf36fb3e03dda305d 100644
--- a/zh-cn/react-native-ble-plx.md
+++ b/zh-cn/react-native-ble-plx.md
@@ -1,363 +1,401 @@
-> 模板版本:v0.2.2
-
-
-
react-native-ble-plx
-
-
-
-
-
-
-
-
-
-
-> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-ble-plx)
-
-## 安装与使用
-
-请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-ble-plx Releases](https://github.com/react-native-oh-library/react-native-ble-plx/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。
-
-进入到工程目录并输入以下命令:
-
-
-
-#### **npm**
-
-```bash
-npm install @react-native-oh-tpl/react-native-ble-plx
-```
-
-#### **yarn**
-
-```bash
-yarn add @react-native-oh-tpl/react-native-ble-plx
-```
-
-
-
-下面的代码展示了这个库的基本使用场景:
-
-> [!WARNING] 使用时 import 的库名不变。
-
-```js
-import React from 'react';
-import { View, Button, Alert } from 'react-native';
-import {
- BleErrorCode,
- BleManager,
- Device,
- Service,
- Descriptor,
- type DeviceId,
- type UUID,
- type Characteristic,
-} from 'react-native-ble-plx';
-import Toast from 'react-native-simple-toast';
-
-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: any, device: any) => {
- 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: any) => {
- this.device = device
- resolve(device)
- })
- .catch((error: any) => {
- if (error.errorCode === BleErrorCode.DeviceAlreadyConnected && this.device) {
- resolve(this.device)
- } else {
- console.error(error.message)
- reject(error)
- }
- })
- })
-}
-
-class App extends React.Component {
- deviceName: string = 'time'
- serviceUuid: string = '00001820-0000-1000-8000-00805F9B34FB'
- characteristicUuid: string = '00001820-0000-1000-8000-00805F9B34FB'
- descriptorUuid: string = '00002903-0000-1000-8000-00805F9B34FB'
-
- device?: Device;
-
- service?: Service;
-
- characteristic?: Characteristic;
-
- descriptor?: Descriptor;
-
- showLog(text: string) {
- Toast.show(text, Toast.SHORT);
- console.log('bleplx showLog:' + text);
- };
-
- ble = new BLEServiceInstance((text: string) => {
- this.showLog(text);
- });
-
- enable = () => {
- this.ble.manager.enable();
- Toast.show('enable', Toast.SHORT)
- }
-
- disable = () => {
- this.ble.manager.disable();
- Toast.show('disable', Toast.SHORT)
- }
-
- startScan = () => {
- console.log('startScan');
- Toast.show('开始扫描外设', Toast.LONG)
- this.ble.manager.startDeviceScan(null, null, (error: any, device: any) => {
- if (device?.name) {
- console.log('bleplx: startScan result:' + device?.name);
- }
- if (device?.name?.toLocaleLowerCase() == this.deviceName) {
- if (this.device != null) {
- return
- }
- this.device = device;
- this.stopDeviceScan();
- Alert.alert(
- '发现外设:' + device.name,
- '是否连连接?',
- [
- {
- text: '取消',
- style: 'cancel'
- },
- {
- text: '连接',
- onPress: () => {
- this.connectToDevice();
- },
- style: 'destructive'
- }
- ]
- )
- }
- })
- }
-
- stopDeviceScan = () => {
- this.ble.manager.stopDeviceScan();
- Toast.show('stopDeviceScan', Toast.SHORT)
- }
-
- connectToDevice = () => {
- if (this.device == null) {
- console.log('bleplx: 没有找到指定的连接设备');
- return;
- }
-
- console.log('bleplx: 开始连接:' + this.device.id);
- Toast.show('开始连接外设', Toast.LONG)
- this.ble.manager.connectToDevice(this.device.id).then((device: any) => {
- Toast.show('连接成功', Toast.SHORT);
- console.log('bleplx:连接成功:' + JSON.stringify(device));
- }).catch((error: any) => {
- Toast.show('连接失败', Toast.SHORT);
- console.log('bleplx:连接失败:' + error.message);
- });
- }
-
- render() {
- return (
-
- enable
- disable
- startScan
- stopDeviceScan
-
- )
- }
-}
-
-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