Skip to content

Commit 47d4076

Browse files
chore: added bidirectional infinite scroll support to flatlist
1 parent 9fe906b commit 47d4076

File tree

12 files changed

+15735
-974
lines changed

12 files changed

+15735
-974
lines changed

README.md

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,70 @@
1-
# react-native-bidirectional-infinite-scroll
1+
# 📜 react-native-bidirectional-infinite-scroll
22

3-
Birectional infinite scroll for react-native
3+
[![GitHub Workflow Status](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/GetStream/react-native-bidirectional-infinite-scroll/blob/main/LICENSE)
4+
[![Compatibility](https://img.shields.io/badge/react--native%20--%20android%20%7C%20iOS-compatible-brightgreen)](https://reactnative.dev/)
45

5-
## Installation
6+
Birectional infinite scroll for react-native, with **smooth scrolling**.
7+
8+
**[** Built with ♥ at [Stream](https://getstream.io/) **]**
9+
10+
11+
<table>
12+
<tr>
13+
<td align='center' width="33%"><img src='https://user-images.githubusercontent.com/11586388/108675127-a5545680-74e6-11eb-89f9-b617b5ce6cc6.gif'/></td>
14+
<td align='center' width="33%"><img src='https://user-images.githubusercontent.com/11586388/108675105-9ff70c00-74e6-11eb-8abf-7c07b79338e2.gif'/></td>
15+
</tr>
16+
<tr></tr>
17+
<tr>
18+
<td align='center'>
19+
<strong>iOS</strong>
20+
</td>
21+
<td align='center'>
22+
<strong>Android</strong>
23+
</td>
24+
</tr>
25+
</table>
26+
27+
## 🛠 Installation
628

729
```sh
8-
npm install react-native-bidirectional-infinite-scroll
30+
yarn add react-native-bidirectional-infinite-scroll @stream-io/flat-list-mvcp
931
```
1032

11-
## Usage
33+
## 🔮 Usage
1234

13-
```js
14-
import BidirectionalInfiniteScroll from "react-native-bidirectional-infinite-scroll";
35+
Please check the [example app](https://github.com/GetStream/react-native-bidirectional-infinite-scroll/tree/main/example) for working demo.
1536

16-
// ...
37+
```jsx
38+
import { FlatList } from "react-native-bidirectional-infinite-scroll";
39+
40+
<FlatList
41+
data={numbers}
42+
renderItem={ListItem}
43+
keyExtractor={(item) => item.toString()}
44+
onStartReached={onStartReached} // required, should return a promise
45+
onEndReached={onEndReached} // required, should return a promise
46+
showDefaultLoadingIndicators={true} // optional
47+
onStartReachedThreshold={10} // optional
48+
onEndReachedThreshold={10} // optional
49+
activityIndicatorColor={'black'} // optional
50+
HeaderLoadingIndicator={() => { /** Your loading indicator */ }} // optional
51+
FooterLoadingIndicator={() => { /** Your loading indicator */ }} // optional
52+
// You can use any other prop on react-native's FlatList
53+
/>
1754

18-
const result = await BidirectionalInfiniteScroll.multiply(3, 7);
1955
```
2056

21-
## Contributing
57+
**Note**:
58+
- `onEndReached` and `onStartReached` only get called once, per content length.
59+
- `onEndReached` and `onStartReached` must return a promise.
60+
- `maintainVisibleContentPosition` is fixed, and can't be modified through props.
61+
- doesn't accept `ListFooterComponent` via prop, since it is occupied by `FooterLoadingIndicator`
62+
63+
64+
## ✍ Contributing
2265

2366
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
2467

25-
## License
68+
## 🎗 License
2669

2770
MIT

example/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Example for react-native-bidirectional-infinite-scroll
2+
3+
## How to run
4+
5+
```sh
6+
git clone https://github.com/GetStream/react-native-bidirectional-infinite-scroll.git
7+
cd example
8+
yarn; npx pod-install
9+
10+
npx react-native run-ios
11+
```
12+
13+
<table>
14+
<tr>
15+
<td align='center' width="33%"><img src='https://user-images.githubusercontent.com/11586388/108675127-a5545680-74e6-11eb-89f9-b617b5ce6cc6.gif'/></td>
16+
<td align='center' width="33%"><img src='https://user-images.githubusercontent.com/11586388/108675105-9ff70c00-74e6-11eb-8abf-7c07b79338e2.gif'/></td>
17+
</tr>
18+
<tr></tr>
19+
<tr>
20+
<td align='center'>iOS</td>
21+
<td align='center'>Android</td>
22+
</tr>
23+
</table>

example/ios/BidirectionalInfiniteScrollExample.xcodeproj/project.pbxproj

Lines changed: 829 additions & 928 deletions
Large diffs are not rendered by default.

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ target 'BidirectionalInfiniteScrollExample' do
1313
#
1414
# Note that if you have use_frameworks! enabled, Flipper will not work and
1515
# you should disable these next few lines.
16-
use_flipper!
16+
use_flipper!({ 'Flipper' => '0.75.1' })
1717
post_install do |installer|
1818
flipper_post_install(installer)
1919
end

0 commit comments

Comments
 (0)