@react-native-ohos/react-native-pager-view 6.7.2-rc.1 → 6.7.3-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.
Files changed (42) hide show
  1. package/README.OpenSource +10 -10
  2. package/README.md +1 -1
  3. package/harmony/pager_view/oh-package.json5 +1 -1
  4. package/harmony/pager_view/src/main/cpp/ViewPagerComponentInstance.cpp +13 -3
  5. package/harmony/pager_view/src/main/cpp/ViewPagerComponentInstance.h +8 -1
  6. package/harmony/pager_view.har +0 -0
  7. package/lib/commonjs/PagerView.js +23 -1
  8. package/lib/commonjs/PagerView.js.map +1 -1
  9. package/lib/commonjs/PagerViewNativeComponent.js +24 -0
  10. package/lib/commonjs/PagerViewNativeComponent.js.map +1 -1
  11. package/lib/commonjs/index.js +23 -0
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/usePagerView.js +24 -0
  14. package/lib/commonjs/usePagerView.js.map +1 -1
  15. package/lib/commonjs/utils.js +24 -0
  16. package/lib/commonjs/utils.js.map +1 -1
  17. package/lib/module/PagerView.js +23 -0
  18. package/lib/module/PagerView.js.map +1 -1
  19. package/lib/module/PagerViewNativeComponent.js +24 -0
  20. package/lib/module/PagerViewNativeComponent.js.map +1 -1
  21. package/lib/module/index.js +24 -0
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/usePagerView.js +24 -0
  24. package/lib/module/usePagerView.js.map +1 -1
  25. package/lib/module/utils.js +23 -0
  26. package/lib/module/utils.js.map +1 -1
  27. package/lib/typescript/PagerView.d.ts +23 -0
  28. package/lib/typescript/PagerViewNativeComponent.d.ts +23 -0
  29. package/lib/typescript/index.d.ts +23 -0
  30. package/lib/typescript/usePagerView.d.ts +23 -0
  31. package/lib/typescript/utils.d.ts +23 -0
  32. package/package.json +4 -4
  33. package/src/PagerView.tsx +23 -0
  34. package/src/PagerViewNativeComponent.ts +23 -0
  35. package/src/index.tsx +23 -0
  36. package/src/usePagerView.ts +23 -0
  37. package/src/utils.tsx +23 -0
  38. package/harmony/pager_view/LICENSE +0 -21
  39. package/harmony/pager_view/NOTICE +0 -33
  40. package/harmony/pager_view/OAT.xml +0 -38
  41. package/harmony/pager_view/README.OpenSource +0 -11
  42. package/harmony/pager_view/README.md +0 -236
@@ -1,236 +0,0 @@
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) ,请自由地享受和参与开源。