@react-native-ohos/react-native-pager-view 6.7.2-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.OpenSource +11 -0
- package/README.md +15 -0
- package/harmony/pager_view/LICENSE +21 -0
- package/harmony/pager_view/NOTICE +33 -0
- package/harmony/pager_view/OAT.xml +38 -0
- package/harmony/pager_view/README.OpenSource +11 -0
- package/harmony/pager_view/README.md +236 -0
- package/harmony/pager_view/build-profile.json5 +9 -0
- package/harmony/pager_view/consumer-rules.txt +0 -0
- package/harmony/pager_view/hvigorfile.ts +6 -0
- package/harmony/pager_view/index.ets +25 -0
- package/harmony/pager_view/obfuscation-rules.txt +18 -0
- package/harmony/pager_view/oh-package.json5 +21 -0
- package/harmony/pager_view/src/main/cpp/CMakeLists.txt +9 -0
- package/harmony/pager_view/src/main/cpp/RNCViewPagerTurbomodule.cpp +42 -0
- package/harmony/pager_view/src/main/cpp/RNCViewPagerTurbomodule.h +37 -0
- package/harmony/pager_view/src/main/cpp/SwiperNode.cpp +375 -0
- package/harmony/pager_view/src/main/cpp/SwiperNode.h +123 -0
- package/harmony/pager_view/src/main/cpp/ViewPagerComponentInstance.cpp +224 -0
- package/harmony/pager_view/src/main/cpp/ViewPagerComponentInstance.h +104 -0
- package/harmony/pager_view/src/main/cpp/ViewPagerPackage.h +61 -0
- package/harmony/pager_view/src/main/cpp/generated/RNOH/generated/BaseReactNativePagerViewPackage.h +65 -0
- package/harmony/pager_view/src/main/cpp/generated/RNOH/generated/components/BaseRNCViewPagerComponentInstance.h +17 -0
- package/harmony/pager_view/src/main/cpp/generated/RNOH/generated/components/RNCViewPagerJSIBinder.h +38 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/ComponentDescriptors.h +22 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/EventEmitters.cpp +45 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/EventEmitters.h +54 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/Props.cpp +35 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/Props.h +100 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/ShadowNodes.cpp +19 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/ShadowNodes.h +34 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/States.cpp +18 -0
- package/harmony/pager_view/src/main/cpp/generated/react/renderer/components/react_native_pager_view/States.h +36 -0
- package/harmony/pager_view/src/main/ets/Logger.ets +64 -0
- package/harmony/pager_view/src/main/ets/RNCViewPager.ets +281 -0
- package/harmony/pager_view/src/main/ets/RNCViewPagerManager.ets +58 -0
- package/harmony/pager_view/src/main/ets/ViewPagerModule.ts +34 -0
- package/harmony/pager_view/src/main/ets/ViewPagerPackage.ts +46 -0
- package/harmony/pager_view/src/main/module.json5 +7 -0
- package/harmony/pager_view/src/main/resources/base/element/string.json +8 -0
- package/harmony/pager_view/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/pager_view/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/pager_view/ts.ts +26 -0
- package/harmony/pager_view.har +0 -0
- package/lib/commonjs/PagerView.js +145 -0
- package/lib/commonjs/PagerView.js.map +1 -0
- package/lib/commonjs/PagerViewNativeComponent.js +14 -0
- package/lib/commonjs/PagerViewNativeComponent.js.map +1 -0
- package/lib/commonjs/index.js +22 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/usePagerView.js +113 -0
- package/lib/commonjs/usePagerView.js.map +1 -0
- package/lib/commonjs/utils.js +28 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/PagerView.js +138 -0
- package/lib/module/PagerView.js.map +1 -0
- package/lib/module/PagerViewNativeComponent.js +7 -0
- package/lib/module/PagerViewNativeComponent.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/usePagerView.js +107 -0
- package/lib/module/usePagerView.js.map +1 -0
- package/lib/module/utils.js +20 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/PagerView.d.ts +69 -0
- package/lib/typescript/PagerViewNativeComponent.d.ts +36 -0
- package/lib/typescript/index.d.ts +9 -0
- package/lib/typescript/usePagerView.d.ts +39 -0
- package/lib/typescript/utils.d.ts +2 -0
- package/package.json +139 -0
- package/src/PagerView.tsx +171 -0
- package/src/PagerViewNativeComponent.ts +68 -0
- package/src/index.tsx +27 -0
- package/src/usePagerView.ts +148 -0
- package/src/utils.tsx +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Callstack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-pager-view",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": " LICENSE ",
|
|
6
|
+
"Version Number": "6.7.1",
|
|
7
|
+
"Owner" : "xiafeng@huawei.com",
|
|
8
|
+
"Upstream URL": "https://github.com/callstack/react-native-pager-view",
|
|
9
|
+
"Description": "React Native wrapper for the Android ViewPager and iOS UIPageViewController."
|
|
10
|
+
}
|
|
11
|
+
]
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @react-native-ohos/react-native-pager-view
|
|
2
|
+
|
|
3
|
+
This project is based on [react-native-pager-view](https://github.com/callstack/react-native-pager-view)
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
[中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-pager-view.md)
|
|
8
|
+
|
|
9
|
+
[English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-pager-view.md)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## License
|
|
13
|
+
|
|
14
|
+
This library is licensed under [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-pager-view/blob/sig/LICENSE).
|
|
15
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Callstack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
OPEN SOURCE SOFTWARE NOTICE
|
|
2
|
+
|
|
3
|
+
Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders.
|
|
4
|
+
|
|
5
|
+
Warranty Disclaimer
|
|
6
|
+
THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
|
7
|
+
|
|
8
|
+
Copyright Notice and License Texts
|
|
9
|
+
|
|
10
|
+
----------------------------------------------------------------------
|
|
11
|
+
Software: react-native-pager-view V6.7.1
|
|
12
|
+
|
|
13
|
+
MIT License
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2021 Callstack
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
in the Software without restriction, including without limitation the rights
|
|
20
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
furnished to do so, subject to the following conditions:
|
|
23
|
+
|
|
24
|
+
The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
copies or substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
SOFTWARE.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<configuration>
|
|
3
|
+
<oatconfig>
|
|
4
|
+
<licensefile>LICENSE</licensefile>
|
|
5
|
+
<filefilterlist>
|
|
6
|
+
<filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
7
|
+
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加版权头"/>
|
|
8
|
+
<filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加版权头"/>
|
|
9
|
+
<filteritem type="filename" name="*.proto" desc="资源文件,不需要添加版权头"/>
|
|
10
|
+
<filteritem type="filename" name="*.json" desc="资源文件,不需要添加版权头"/>
|
|
11
|
+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
12
|
+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
13
|
+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
14
|
+
<filteritem type="filename" name="LICENSE" desc="工程文件,不修改版权头"/>
|
|
15
|
+
</filefilter>
|
|
16
|
+
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
17
|
+
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
18
|
+
<filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
19
|
+
<filteritem type="filename" name="LICENSE" desc="原三方库证书文件无需更改,因此添加过滤"/>
|
|
20
|
+
<filteritem type="filename" name="*.proto" desc="资源文件,不需要添加许可证头"/>
|
|
21
|
+
<filteritem type="filename" name="*.json" desc="资源文件,不需要添加许可证头"/>
|
|
22
|
+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
23
|
+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
24
|
+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
25
|
+
</filefilter>
|
|
26
|
+
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for resources files policies">
|
|
27
|
+
<filteritem type="filename" name="icon.png" desc="应用图标"/>
|
|
28
|
+
<filteritem type="filename" name="app_icon.png" desc="应用图标"/>
|
|
29
|
+
<filteritem type="filename" name="warn.png" desc="页面展示图标"/>
|
|
30
|
+
</filefilter>
|
|
31
|
+
</filefilterlist>
|
|
32
|
+
<policylist>
|
|
33
|
+
<policy name="projectPolicy" desc="">
|
|
34
|
+
<policyitem type="license" name="MIT" path="*.*" desc="license under the MIT"/>
|
|
35
|
+
</policy>
|
|
36
|
+
</policylist>
|
|
37
|
+
</oatconfig>
|
|
38
|
+
</configuration>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-pager-view",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": "https://github.com/callstack/react-native-pager-view/blob/master/LICENSE",
|
|
6
|
+
"Version Number": "6.7.1",
|
|
7
|
+
"Owner" : "troZee <hello@callstack.com>",
|
|
8
|
+
"Upstream URL": "https://github.com/callstack/react-native-pager-view",
|
|
9
|
+
"Description": "React Native wrapper for Android, iOS, Harmony ViewPager"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
> 模板版本:v0.0.1
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<h1 align="center"> <code>react-native-pager-view</code> </h1>
|
|
5
|
+
</p>
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://github.com/callstack/react-native-pager-view">
|
|
8
|
+
<img src="https://img.shields.io/badge/platforms-android%20|%20ios%20|%20harmony%20-lightgrey.svg" alt="Supported platforms" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://github.com/callstack/react-native-pager-view/blob/master/LICENSE">
|
|
11
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" />
|
|
12
|
+
</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
## 安装与使用
|
|
16
|
+
|
|
17
|
+
**正在 npm 发布中,当前请先从仓库[Release](https://github.com/react-native-oh-library/react-native-pager-view/releases)中获取库 tgz,通过使用本地依赖来安装本库。**
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add xxx
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
或者
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install xxx
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
下面的代码展示了这个库的基本使用场景:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import React from "react";
|
|
33
|
+
import { StyleSheet, View, Text } from "react-native";
|
|
34
|
+
import PagerView from "react-native-pager-view";
|
|
35
|
+
|
|
36
|
+
const MyPager = () => {
|
|
37
|
+
return (
|
|
38
|
+
<PagerView style={styles.pagerView} initialPage={0}>
|
|
39
|
+
<View key="1">
|
|
40
|
+
<Text>First page</Text>
|
|
41
|
+
</View>
|
|
42
|
+
<View key="2">
|
|
43
|
+
<Text>Second page</Text>
|
|
44
|
+
</View>
|
|
45
|
+
</PagerView>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const styles = StyleSheet.create({
|
|
50
|
+
pagerView: {
|
|
51
|
+
flex: 1,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Link
|
|
57
|
+
|
|
58
|
+
目前鸿蒙暂不支持 AutoLink,所以 Link 步骤需要手动配置。
|
|
59
|
+
|
|
60
|
+
首先需要使用 DevEco Studio 打开项目里的鸿蒙工程 `harmony`
|
|
61
|
+
|
|
62
|
+
### 引入原生端代码
|
|
63
|
+
|
|
64
|
+
目前有两种方法:
|
|
65
|
+
|
|
66
|
+
1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
|
|
67
|
+
2. 直接链接源码。
|
|
68
|
+
|
|
69
|
+
方法一:通过 har 包引入
|
|
70
|
+
打开 `entry/oh-package.json5`,添加以下依赖
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"rnoh": "file:../rnoh",
|
|
75
|
+
"rnoh-pager-view": "file:../../node_modules/react-native-pager-view/harmony/pager_view.har"
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
点击右上角的 `sync` 按钮
|
|
80
|
+
|
|
81
|
+
或者在终端执行:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
cd entry
|
|
85
|
+
ohpm install
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
方法二:直接链接源码
|
|
89
|
+
打开 `entry/oh-package.json5`,添加以下依赖
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
"dependencies": {
|
|
93
|
+
"rnoh": "file:../rnoh",
|
|
94
|
+
"rnoh-pager-view": "file:../../node_modules/react-native-pager-view/harmony/pager_view"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
打开终端,执行:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
cd entry
|
|
102
|
+
ohpm install --no-link
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 配置 CMakeLists 和引入 ViewPagerPackage
|
|
106
|
+
|
|
107
|
+
打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
|
|
108
|
+
|
|
109
|
+
```diff
|
|
110
|
+
project(rnapp)
|
|
111
|
+
cmake_minimum_required(VERSION 3.4.1)
|
|
112
|
+
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
113
|
+
set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
114
|
+
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
|
|
115
|
+
|
|
116
|
+
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
|
|
117
|
+
|
|
118
|
+
# RNOH_BEGIN: add_package_subdirectories
|
|
119
|
+
add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
|
|
120
|
+
+ add_subdirectory("${OH_MODULE_DIR}/rnoh-pager-view/src/main/cpp" ./pager_view)
|
|
121
|
+
# RNOH_END: add_package_subdirectories
|
|
122
|
+
|
|
123
|
+
add_library(rnoh_app SHARED
|
|
124
|
+
"./PackageProvider.cpp"
|
|
125
|
+
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
target_link_libraries(rnoh_app PUBLIC rnoh)
|
|
129
|
+
|
|
130
|
+
# RNOH_BEGIN: link_packages
|
|
131
|
+
target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
|
|
132
|
+
+ target_link_libraries(rnoh_app PUBLIC rnoh_pager_view )
|
|
133
|
+
# RNOH_END: link_packages
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
|
|
137
|
+
|
|
138
|
+
```diff
|
|
139
|
+
#include "RNOH/PackageProvider.h"
|
|
140
|
+
#include "SamplePackage.h"
|
|
141
|
+
+ #include "ViewPagerPackage.h"
|
|
142
|
+
|
|
143
|
+
using namespace rnoh;
|
|
144
|
+
|
|
145
|
+
std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
|
|
146
|
+
return {
|
|
147
|
+
std::make_shared<SamplePackage>(ctx),
|
|
148
|
+
+ std::make_shared<ViewPagerPackage>(ctx)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 在 ArkTs 侧引入 RNCViewPager 组件
|
|
154
|
+
|
|
155
|
+
打开 `entry/src/main/ets/pages/index.ets`,添加:
|
|
156
|
+
|
|
157
|
+
```diff
|
|
158
|
+
import {
|
|
159
|
+
RNApp,
|
|
160
|
+
ComponentBuilderContext,
|
|
161
|
+
RNAbility,
|
|
162
|
+
AnyJSBundleProvider,
|
|
163
|
+
MetroJSBundleProvider,
|
|
164
|
+
ResourceJSBundleProvider,
|
|
165
|
+
} from 'rnoh'
|
|
166
|
+
import { SampleView, SAMPLE_VIEW_TYPE, PropsDisplayer } from "rnoh-sample-package"
|
|
167
|
+
import { createRNPackages } from '../RNPackagesFactory'
|
|
168
|
+
+ import { RNCViewPager, PAGER_VIEW_TYPE } from "rnoh-pager-view"
|
|
169
|
+
|
|
170
|
+
@Builder
|
|
171
|
+
function CustomComponentBuilder(ctx: ComponentBuilderContext) {
|
|
172
|
+
if (ctx.descriptor.type === SAMPLE_VIEW_TYPE) {
|
|
173
|
+
SampleView({
|
|
174
|
+
ctx: ctx.rnohContext,
|
|
175
|
+
tag: ctx.descriptor.tag,
|
|
176
|
+
buildCustomComponent: CustomComponentBuilder
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
+ else if (ctx.descriptor.type === PAGER_VIEW_TYPE) {
|
|
180
|
+
+ RNCViewPager({
|
|
181
|
+
+ ctx: ctx.rnohContext,
|
|
182
|
+
+ tag: ctx.descriptor.tag,
|
|
183
|
+
+ buildCustomComponent: CustomComponentBuilder
|
|
184
|
+
+ })
|
|
185
|
+
+ }
|
|
186
|
+
...
|
|
187
|
+
}
|
|
188
|
+
...
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 运行
|
|
192
|
+
|
|
193
|
+
点击右上角的 `sync` 按钮
|
|
194
|
+
|
|
195
|
+
或者在终端执行:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
cd entry
|
|
199
|
+
ohpm install
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
然后编译、运行即可。
|
|
203
|
+
|
|
204
|
+
## 兼容性
|
|
205
|
+
|
|
206
|
+
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
|
|
207
|
+
|
|
208
|
+
请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-pager-view Releases](https://github.com/react-native-oh-library/react-native-pager-view/releases)
|
|
209
|
+
|
|
210
|
+
## 属性
|
|
211
|
+
|
|
212
|
+
| 名称 | 说明 | 类型 | 是否必填 | 原库平台 | 鸿蒙支持 |
|
|
213
|
+
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | -------- | ------------ | -------------------------- |
|
|
214
|
+
| initialPage | Index of initial page that should be selected | number | 是 | ios,android | yes |
|
|
215
|
+
| scrollEnabled | Should pager view scroll, when scroll enabled | bool | 是 | ios,android | yes |
|
|
216
|
+
| onPageScroll | Executed when transitioning between pages (ether because the animation for the requested page has changed or when the user is swiping/dragging between pages) | function | 否 | ios,android | yes |
|
|
217
|
+
| onPageScrollStateChanged | Function called when the page scrolling state has changed | function | 否 | ios,android | yes |
|
|
218
|
+
| onPageSelected | This callback will be called once the ViewPager finishes navigating to the selected page | function | 否 | ios,android | yes |
|
|
219
|
+
| pageMargin | Blank space to be shown between pages | number (取值范围:0~屏幕宽度) | 否 | ios,android | 仅支持取 0-368(屏幕宽度) |
|
|
220
|
+
| keyboardDismissMode | Determines whether the keyboard gets dismissed in response to a drag | one of 'none' ,'on-drag' | 否 | ios,droid | yes |
|
|
221
|
+
| orientation | Set horizontal or vertical scrolling orientation (it does not work dynamically) | one of horizontal vertical | 否 | ios,android | yes |
|
|
222
|
+
| overScrollMode | Used to override default value of overScroll mode. Can be auto, always or never. Defaults to auto | one of auto, always ,never | 否 | android | yes |
|
|
223
|
+
| offscreenPageLimit | Set the number of pages that should be retained to either side of the currently visible page(s). Pages beyond this limit will be recreated from the adapter when needed. Defaults to RecyclerView's caching strategy. The given value must either be larger than 0. | number | 否 | android | yes |
|
|
224
|
+
| overdrag | Allows for overscrolling after reaching the end or very beginning or pages. Defaults to false | bool | 否 | ios | yes |
|
|
225
|
+
| layoutDirection | Specifies layout direction. Use ltr or rtl to set explicitly or locale to deduce from the default language script of a locale. Defaults to locale | string | 否 | android,ios | yes |
|
|
226
|
+
| setPage(index: number) | Function to scroll to a specific page in the PagerView. Invalid index is ignored. | function | 否 | android,ios | yes |
|
|
227
|
+
| setPageWithoutAnimation(index: number) | Function to scroll to a specific page in the PagerView. Invalid index is ignored. | function | 否 | android,ios | yes |
|
|
228
|
+
| setScrollEnabled(scrollEnabled: boolean) | FA helper function to enable/disable scroll imperatively. The recommended way is using the scrollEnabled prop, however, there might be a case where a imperative solution is more useful (e.g. for not blocking an animation) | function | 否 | android,ios | yes |
|
|
229
|
+
|
|
230
|
+
## 遗留问题
|
|
231
|
+
|
|
232
|
+
## 其他
|
|
233
|
+
|
|
234
|
+
## 开源协议
|
|
235
|
+
|
|
236
|
+
本项目基于 [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-pager-view/blob/harmony/LICENSE) ,请自由地享受和参与开源。
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export * from './src/main/ets/RNCViewPager'
|
|
25
|
+
export * from './ts'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
+
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"license": "Apache-2.0",
|
|
3
|
+
"devDependencies": {},
|
|
4
|
+
"author": "",
|
|
5
|
+
"name": "@react-native-ohos/react-native-pager-view",
|
|
6
|
+
"description": "React Native wrapper for HarmonyOS ViewPager",
|
|
7
|
+
"main": "index.ets",
|
|
8
|
+
"version": "6.7.2-rc.1",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@rnoh/react-native-openharmony": "file:../../node_modules/@react-native-oh/react-native-harmony/harmony/react_native_openharmony.har"
|
|
11
|
+
},
|
|
12
|
+
"metadata": {
|
|
13
|
+
"sourceRoots": [
|
|
14
|
+
"./src/main"
|
|
15
|
+
],
|
|
16
|
+
"debug": true
|
|
17
|
+
},
|
|
18
|
+
"compatibleSdkVersion": 12,
|
|
19
|
+
"compatibleSdkType": "HarmonyOS",
|
|
20
|
+
"obfuscated": false
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
+
|
|
4
|
+
set(rnoh_pager_view_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
5
|
+
file(GLOB_RECURSE rnoh_pager_view_generated_SRC "${rnoh_pager_view_generated_dir}/**/*.cpp")
|
|
6
|
+
file(GLOB rnoh_pager_view_SRC CONFIGURE_DEPENDS *.cpp)
|
|
7
|
+
add_library(rnoh_pager_view SHARED ${rnoh_pager_view_generated_SRC} ${rnoh_pager_view_SRC})
|
|
8
|
+
target_include_directories(rnoh_pager_view PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_pager_view_generated_dir})
|
|
9
|
+
target_link_libraries(rnoh_pager_view PUBLIC rnoh)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include "RNCViewPagerTurbomodule.h"
|
|
26
|
+
|
|
27
|
+
using namespace rnoh;
|
|
28
|
+
using namespace facebook;
|
|
29
|
+
|
|
30
|
+
static jsi::Value __hostFunction_RNCViewPagerTurbomodule_keyboardDismiss(jsi::Runtime &rt,
|
|
31
|
+
react::TurboModule &turboModule,
|
|
32
|
+
const jsi::Value *args, size_t count)
|
|
33
|
+
{
|
|
34
|
+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "keyboardDismiss", args, count);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
RNCViewPagerTurbomodule::RNCViewPagerTurbomodule(const ArkTSTurboModule::Context ctx,
|
|
38
|
+
const std::string name)
|
|
39
|
+
: ArkTSTurboModule(ctx, name)
|
|
40
|
+
{
|
|
41
|
+
methodMap_["keyboardDismiss"] = MethodMetadata{0, __hostFunction_RNCViewPagerTurbomodule_keyboardDismiss};
|
|
42
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2025 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#pragma once
|
|
26
|
+
|
|
27
|
+
#include <ReactCommon/TurboModule.h>
|
|
28
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
29
|
+
|
|
30
|
+
namespace rnoh {
|
|
31
|
+
|
|
32
|
+
class JSI_EXPORT RNCViewPagerTurbomodule : public ArkTSTurboModule {
|
|
33
|
+
public:
|
|
34
|
+
RNCViewPagerTurbomodule(const ArkTSTurboModule::Context ctx, const std::string name);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace rnoh
|