diff --git a/en/react-native-swiper-flatlist.md b/en/react-native-swiper-flatlist.md new file mode 100644 index 0000000000000000000000000000000000000000..0828997140ca6404f3ab1117c7d60454a83305c1 --- /dev/null +++ b/en/react-native-swiper-flatlist.md @@ -0,0 +1,160 @@ +> Template version:v0.2.2 + +

+

react-native-swiper-flatlist

+

+

+ + Supported platforms + + + License + +

+ +> [!Tip] [GitHub address](https://github.com/gusgard/react-native-swiper-flatlist) + +## Installation and Usage + +Go to the project directory and execute the following instruction: + + + +#### **npm** + +```bash +npm install react-native-swiper-flatlist@3.2.5 +``` + +#### **yarn** + +```bash +yarn add react-native-swiper-flatlist@3.2.5 +``` + + + +### Example + +The following code demonstrates a use case of this library: + +> [!WARNING] The import name of the library remains the same when in use. + +```javascript +import React from 'react'; +import { Text, Dimensions, StyleSheet, View } from 'react-native'; +import { SwiperFlatList } from 'react-native-swiper-flatlist'; + +const colors = ['tomato', 'thistle', 'skyblue', 'teal']; + +const App = () => ( + + ( + + {item} + + )} + /> + +); + +const { width } = Dimensions.get('window'); +const styles = StyleSheet.create({ + container: { backgroundColor: 'white', height: height * 0.7 }, + child: { width, justifyContent: 'center', height: height * 0.5 }, + text: { fontSize: width * 0.5, textAlign: 'center' }, +}); + +export default App; +``` + +## Link + +The HarmonyOS-side implementation of this library relies on the native code of @react-native-oh-tpl/react-native-safe-area-context and @react-native-oh-tpl/react-native-gesture-handler. If these libraries have already been introduced in your HarmonyOS project, there is no need to reintroduce them. You can skip the steps in this section and proceed directly to usage. + +If you have not introduced react-native-safe-area-context, please refer to the [@react-native-oh-tpl/react-native-safe-area-context documentation](/en/react-native-safe-area-context.md) for installation instructions. + +If you have not introduced react-native-gesture-handler, please refer to the [@react-native-oh-tpl/react-native-gesture-handler documentation](/en/react-native-gesture-handler.md) for installation instructions. + + +## Compatibility + +This document is verified based on the following versions: + +react-native-harmony:0.72.86; SDK:HarmonyOS 5.1.0.125; IDE:DevEco Studio 5.1.0.849; ROM:5.0.0.150; + +react-native-harmony:0.77.18; SDK:HarmonyOS 5.1.0.125; IDE:DevEco Studio 5.1.0.849; ROM:5.0.0.150; + +## Props + +> [!TIP] The "Platform" column indicates the platforms supported by the original third-party library. + +> [!TIP] In the "HarmonyOS Support" column, `Yes` means the prop is supported on the HarmonyOS platform, `no` means it is not supported, and `partially` means it is partially supported. The usage is consistent across platforms, with the effect aiming to match the iOS or Android implementation. + +### SwiperFlatList Props + +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| :--- | :--- | :--- | :--- | :--- | :--- | +| `data` | Data to use in renderItem | array | No | All | Yes | +| `children` | Children elements | node | No | All | Yes | +| `renderItem` | Takes an item from data and renders it into the list | FlatListProps[renderItem] | No | All | Yes | +| `onMomentumScrollEnd` | Called after scroll end and the first parameter is the current index| (item: { index: number }, event: any) | No | All | Yes | +| `vertical` | Show vertical swiper | boolean | No | All | Yes | +| `index` | Index to start | number | No | All | Yes | +| `renderAll` | Edge/Corner's height. Default: 20 | boolean | No | All | Yes | +| `showPagination` | Showpagination | boolean | No | All | Yes | +| `onChangeIndex` | Executed every time the index change, the index change when the user reaches 60% of the next screen | ({ index: number, prevIndex: number}) => void | No | All | Yes | +| `PaginationComponent` | Overwrite Pagination component | node | No | All | Yes | +| `onViewableItemsChanged` | Native visible term changes in RN | FlatListProps['onViewableItemsChanged'] | No | All | Yes | +| `autoplay` | Change index automatically | boolean | No | All | Yes | +| `autoplayDelay` | Delay between every page in seconds | number | No | All | Yes | +| `autoplayLoop` | Continue playing after reach end | boolean | No | All | Yes | +| `autoplayLoopKeepAnimation` | Show animation when reach the end of the list | boolean | No | All | Yes | +| `autoplayInvertDirection` | Invert auto play direction | boolean | No | All | Yes | +| `disableGesture` | Disable swipe gesture | boolean | No | All | Yes | +| `e2eID` | TestID for automation testing | string | No | All | Yes | +| `viewabilityConfig` | TestID for automation testing | ViewabilityConfig | No | All | Yes | +| `useReactNativeGestureHandler` | Use react-native-gesture-handler FlatList instead of the native FlatList | boolean | No | All | Yes | +| `paginationAccessibilityLabels` | Accessibility labels for the pagination items.This is optional and used for screen readers. | string[] | No | All | No | +### Pagination Props +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| :--- | :--- | :--- | :--- | :--- | :--- | +| `paginationDefaultColor` | Pagination Default color | string | No | All | Yes | +| `paginationActiveColor` | Pagination color | string | No | All | Yes | +| `paginationStyle` | Style object for the container | ViewStyle | No | All | Yes | +| `paginationStyleItem` | Style object for the item | ViewStyle | No | All | Yes | +| `paginationStyleItemActive` | Style object for the active item | ViewStyle | No | All | Yes | +| `paginationStyleItemInactive` | Style object for the inactive item | ViewStyle | No | All | Yes | +| `onPaginationSelectedIndex` | Executed when the user presses the pagination index, similar properties onChangeIndex | () => void | No | All | Yes | +| `size` | Size of pagination | number | Yes | All | Yes | +| `paginationIndex` | Selected pagination index | number | No | All | Yes | +| `e2eID` | TestID for automation testing | string | No | All | Yes | +| `paginationAccessibilityLabels` | Accessibility labels for the pagination items.This is optional and used for screen readers. | string[] | No | All | No | +| `paginationTapDisabled` | Prevents tapping pagination dots | boolean | No | All | Yes | +### SwiperFlatList Functions +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| :--- | :--- | :--- | :--- | :--- | :--- | +| `scrollToIndex` | Scroll to the index | ({ item: ScrollToIndex}) => void | No | All | Yes | +| `getCurrentIndex` | Returns the current index | () => number | No | All | Yes | +| `getPrevIndex` | Returns the previous index | () => number | No | All | Yes | +| `goToFirstIndex` | Go to the first index | () => void | No | All | Yes | +| `goToLastIndex` | Go to the last index | () => void | No | All | Yes | +### Pagination Functions +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| :--- | :--- | :--- | :--- | :--- | :--- | +| `scrollToIndex` | Scroll to the index | ({ index: number}) => void | Yes | All | Yes | +## Known Issues + +## Others + +paginationAccessibilityLabels: native platform test has no effect + +## License +This project is licensed under [The MIT License (MIT)](https://github.com/gusgard/react-native-swiper-flatlist/blob/master/LICENSE). \ No newline at end of file diff --git a/zh-cn/react-native-swiper-flatlist.md b/zh-cn/react-native-swiper-flatlist.md new file mode 100644 index 0000000000000000000000000000000000000000..caf20c4370081c7eceeadbbe9237e1d6b55ea000 --- /dev/null +++ b/zh-cn/react-native-swiper-flatlist.md @@ -0,0 +1,166 @@ +> 模板版本:v0.2.2 + +

+

react-native-swiper-flatlist

+

+

+ + 支持的平台 + + + 许可证 + +

+ +> [!提示] [GitHub 地址](https://github.com/gusgard/react-native-swiper-flatlist) + +## 安装与使用 + +进入项目目录并执行以下指令: + + + +#### **npm** + +```bash +npm install react-native-swiper-flatlist@3.2.5 +``` + +#### **yarn** + +```bash +yarn add react-native-swiper-flatlist@3.2.5 +``` + + + +### 示例 + +下面的代码演示了这个库的一个用例: + +> [!警告] 该库在使用时,其导入名称保持不变。 + +```javascript +import React from 'react'; +import { Text, Dimensions, StyleSheet, View } from 'react-native'; +import { SwiperFlatList } from 'react-native-swiper-flatlist'; + +const colors = ['tomato', 'thistle', 'skyblue', 'teal']; + +const App = () => ( + + ( + + {item} + + )} + /> + +); + +const { width } = Dimensions.get('window'); +const styles = StyleSheet.create({ + container: { backgroundColor: 'white', height: height * 0.7 }, + child: { width, justifyContent: 'center', height: height * 0.5 }, + text: { fontSize: width * 0.5, textAlign: 'center' }, +}); + +export default App; +``` +## 链接 + +该库的 HarmonyOS 端实现依赖于 @react-native-oh-tpl/react-native-safe-area-context 和 @react-native-oh-tpl/react-native-gesture-handler 的原生代码。如果您的 HarmonyOS 项目中已经引入了这些库,则无需重新引入。您可以跳过本节中的步骤,直接进入使用环节。 + +如果您尚未引入 react-native-safe-area-context,请参考 [@react-native-oh-tpl/react-native-safe-area-context 文档](/zh-cn/react-native-safe-area-context.md) 进行安装。 + +如果您尚未引入 react-native-gesture-handler,请参考 [@react-native-oh-tpl/react-native-gesture-handler 文档](/zh-cn/react-native-gesture-handler.md) 进行安装。 + +## 兼容性 + +本文档基于以下版本验证: + +react-native-harmony:0.72.86;SDK:HarmonyOS 5.1.0.125;IDE:DevEco Studio 5.1.0.849;ROM:5.0.0.150; + +react-native-harmony:0.77.18;SDK:HarmonyOS 5.1.0.125;IDE:DevEco Studio 5.1.0.849;ROM:5.0.0.150; + +## 属性 + +> [!提示] "平台" 列表示原始第三方库支持的平台。 + +> [!提示] 在 "HarmonyOS 支持" 列中,`是` 表示该属性在 HarmonyOS 平台上受支持,`否` 表示不支持,`部分` 表示部分支持。其用法在各平台间保持一致,效果旨在与 iOS 或 Android 的实现相匹配。 + +### SwiperFlatList 属性 + +| 名称 | 描述 | 类型 | 必填 | 平台 | HarmonyOS 支持 | +| :--- | :--- | :--- | :--- | :--- | :--- | +| `data` | 用于 renderItem 的数据 | 数组 | 否 | 全平台 | 是 | +| `children` | 子元素 | 节点 | 否 | 全平台 | 是 | +| `renderItem` | 从 data 中取出一个项目并将其渲染到列表中 | FlatListProps[renderItem] | 否 | 全平台 | 是 | +| `onMomentumScrollEnd` | 滚动结束后调用,第一个参数是当前索引 | (item: { index: number }, event: any) => void | 否 | 全平台 | 是 | +| `vertical` | 显示垂直轮播 | 布尔值 | 否 | 全平台 | 是 | +| `index` | 起始索引 | 数字 | 否 | 全平台 | 是 | +| `renderAll` | 渲染所有项目 | 布尔值 | 否 | 全平台 | 是 | +| `showPagination` | 显示分页指示器 | 布尔值 | 否 | 全平台 | 是 | +| `onChangeIndex` | 每次索引改变时执行,当用户到达下一个屏幕的 60% 时索引改变 | ({ index: number, prevIndex: number}) => void | 否 | 全平台 | 是 | +| `PaginationComponent` | 覆写分页组件 | 节点 | 否 | 全平台 | 是 | +| `onViewableItemsChanged` | RN 中原生可见项发生变化 | FlatListProps['onViewableItemsChanged'] | 否 | 全平台 | 是 | +| `autoplay` | 自动改变索引 | 布尔值 | 否 | 全平台 | 是 | +| `autoplayDelay` | 每页之间的延迟(秒) | 数字 | 否 | 全平台 | 是 | +| `autoplayLoop` | 到达末尾后继续播放 | 布尔值 | 否 | 全平台 | 是 | +| `autoplayLoopKeepAnimation` | 到达列表末尾时显示动画 | 布尔值 | 否 | 全平台 | 是 | +| `autoplayInvertDirection` | 反转自动播放方向 | 布尔值 | 否 | 全平台 | 是 | +| `disableGesture` | 禁用滑动手势 | 布尔值 | 否 | 全平台 | 是 | +| `e2eID` | 用于自动化测试的 TestID | 字符串 | 否 | 全平台 | 是 | +| `viewabilityConfig` | 可见性配置 | ViewabilityConfig | 否 | 全平台 | 是 | +| `useReactNativeGestureHandler` | 使用 react-native-gesture-handler 的 FlatList 代替原生 FlatList | 布尔值 | 否 | 全平台 | 是 | +| `paginationAccessibilityLabels` | 分页项目的无障碍标签。此为可选,用于屏幕阅读器。 | 字符串数组 | 否 | 全平台 | 否 | + +### Pagination 属性 + +| 名称 | 描述 | 类型 | 必填 | 平台 | HarmonyOS 支持 | +| :--- | :--- | :--- | :--- | :--- | :--- | +| `paginationDefaultColor` | 分页默认颜色 | 字符串 | 否 | 全平台 | 是 | +| `paginationActiveColor` | 分页激活状态颜色 | 字符串 | 否 | 全平台 | 是 | +| `paginationStyle` | 容器的样式对象 | ViewStyle | 否 | 全平台 | 是 | +| `paginationStyleItem` | 分页项的样式对象 | ViewStyle | 否 | 全平台 | 是 | +| `paginationStyleItemActive` | 激活状态分页项的样式对象 | ViewStyle | 否 | 全平台 | 是 | +| `paginationStyleItemInactive` | 非激活状态分页项的样式对象 | ViewStyle | 否 | 全平台 | 是 | +| `onPaginationSelectedIndex` | 当用户按下分页索引时执行,类似于 onChangeIndex 属性 | () => void | 否 | 全平台 | 是 | +| `size` | 分页指示器大小 | 数字 | 是 | 全平台 | 是 | +| `paginationIndex` | 选中的分页索引 | 数字 | 否 | 全平台 | 是 | +| `e2eID` | 用于自动化测试的 TestID | 字符串 | 否 | 全平台 | 是 | +| `paginationAccessibilityLabels` | 分页项目的无障碍标签。此为可选,用于屏幕阅读器。 | 字符串数组 | 否 | 全平台 | 否 | +| `paginationTapDisabled` | 防止点击分页点 | 布尔值 | 否 | 全平台 | 是 | + +### SwiperFlatList 函数 + +| 名称 | 描述 | 类型 | 必填 | 平台 | HarmonyOS 支持 | +| :--- | :--- | :--- | :--- | :--- | :--- | +| `scrollToIndex` | 滚动到指定索引 | ({ item: ScrollToIndex}) => void | 否 | 全平台 | 是 | +| `getCurrentIndex` | 返回当前索引 | () => number | 否 | 全平台 | 是 | +| `getPrevIndex` | 返回上一个索引 | () => number | 否 | 全平台 | 是 | +| `goToFirstIndex` | 跳转到第一个索引 | () => void | 否 | 全平台 | 是 | +| `goToLastIndex` | 跳转到最后一个索引 | () => void | 否 | 全平台 | 是 | + +### Pagination 函数 + +| 名称 | 描述 | 类型 | 必填 | 平台 | HarmonyOS 支持 | +| :--- | :--- | :--- | :--- | :--- | :--- | +| `scrollToIndex` | 滚动到指定索引 | ({ index: number}) => void | 是 | 全平台 | 是 | + +## 遗留问题 + +## 其他 + +paginationAccessibilityLabels: 原生平台测试无效果 + +## 许可证 + +此项目根据 [The MIT License (MIT)](https://github.com/gusgard/react-native-swiper-flatlist/blob/master/LICENSE) 许可证授权。 \ No newline at end of file