├── .circleci └── config.yml ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .yarnrc ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── babel.config.js ├── example ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── reactnativebidirectionalinfinitescroll │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── reactnativebidirectionalinfinitescroll │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.tsx ├── ios │ ├── BidirectionalInfiniteScrollExample-Bridging-Header.h │ ├── BidirectionalInfiniteScrollExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── BidirectionalInfiniteScrollExample.xcscheme │ ├── BidirectionalInfiniteScrollExample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── BidirectionalInfiniteScrollExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ ├── File.swift │ ├── Podfile │ └── Podfile.lock ├── metro.config.js ├── package.json ├── src │ ├── App.tsx │ ├── MessageBubble.tsx │ ├── MessageListExample.tsx │ └── utils.ts └── yarn.lock ├── package.json ├── scripts └── bootstrap.js ├── src ├── BidirectionalFlatList.tsx ├── __tests__ │ └── index.test.tsx └── index.ts ├── tsconfig.build.json ├── tsconfig.json ├── website ├── .gitignore ├── README.md ├── babel.config.js ├── docs │ ├── example.md │ ├── getting-started.md │ ├── how-it-works.md │ ├── introduction.md │ ├── props.md │ └── troubleshooting.md ├── docusaurus.config.js ├── package.json ├── sidebars.js ├── src │ └── css │ │ └── custom.css ├── static │ ├── .nojekyll │ └── img │ │ ├── docusaurus.png │ │ ├── favicon.ico │ │ ├── logo.svg │ │ ├── undraw_docusaurus_mountain.svg │ │ ├── undraw_docusaurus_react.svg │ │ └── undraw_docusaurus_tree.svg └── yarn.lock └── yarn.lock /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | default: 5 | docker: 6 | - image: circleci/node:10 7 | working_directory: ~/project 8 | 9 | commands: 10 | attach_project: 11 | steps: 12 | - attach_workspace: 13 | at: ~/project 14 | 15 | jobs: 16 | install-dependencies: 17 | executor: default 18 | steps: 19 | - checkout 20 | - attach_project 21 | - restore_cache: 22 | keys: 23 | - dependencies-{{ checksum "package.json" }} 24 | - dependencies- 25 | - restore_cache: 26 | keys: 27 | - dependencies-example-{{ checksum "example/package.json" }} 28 | - dependencies-example- 29 | - run: 30 | name: Install dependencies 31 | command: | 32 | yarn install --cwd example --frozen-lockfile 33 | yarn install --frozen-lockfile 34 | - save_cache: 35 | key: dependencies-{{ checksum "package.json" }} 36 | paths: node_modules 37 | - save_cache: 38 | key: dependencies-example-{{ checksum "example/package.json" }} 39 | paths: example/node_modules 40 | - persist_to_workspace: 41 | root: . 42 | paths: . 43 | 44 | lint: 45 | executor: default 46 | steps: 47 | - attach_project 48 | - run: 49 | name: Lint files 50 | command: | 51 | yarn lint 52 | 53 | typescript: 54 | executor: default 55 | steps: 56 | - attach_project 57 | - run: 58 | name: Typecheck files 59 | command: | 60 | yarn typescript 61 | 62 | unit-tests: 63 | executor: default 64 | steps: 65 | - attach_project 66 | - run: 67 | name: Run unit tests 68 | command: | 69 | yarn test --coverage 70 | - store_artifacts: 71 | path: coverage 72 | destination: coverage 73 | 74 | build-package: 75 | executor: default 76 | steps: 77 | - attach_project 78 | - run: 79 | name: Build package 80 | command: | 81 | yarn prepare 82 | 83 | workflows: 84 | build-and-test: 85 | jobs: 86 | - install-dependencies 87 | - lint: 88 | requires: 89 | - install-dependencies 90 | - typescript: 91 | requires: 92 | - install-dependencies 93 | - unit-tests: 94 | requires: 95 | - install-dependencies 96 | - build-package: 97 | requires: 98 | - install-dependencies 99 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | indent_style = space 10 | indent_size = 2 11 | 12 | end_of_line = lf 13 | charset = utf-8 14 | trim_trailing_whitespace = true 15 | insert_final_newline = true 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # XDE 6 | .expo/ 7 | 8 | # VSCode 9 | .vscode/ 10 | jsconfig.json 11 | 12 | # Xcode 13 | # 14 | build/ 15 | *.pbxuser 16 | !default.pbxuser 17 | *.mode1v3 18 | !default.mode1v3 19 | *.mode2v3 20 | !default.mode2v3 21 | *.perspectivev3 22 | !default.perspectivev3 23 | xcuserdata 24 | *.xccheckout 25 | *.moved-aside 26 | DerivedData 27 | *.hmap 28 | *.ipa 29 | *.xcuserstate 30 | project.xcworkspace 31 | 32 | # Android/IJ 33 | # 34 | .idea 35 | .gradle 36 | local.properties 37 | android.iml 38 | 39 | # Cocoapods 40 | # 41 | example/ios/Pods 42 | 43 | # node.js 44 | # 45 | node_modules/ 46 | npm-debug.log 47 | yarn-debug.log 48 | yarn-error.log 49 | 50 | # BUCK 51 | buck-out/ 52 | \.buckd/ 53 | android/app/libs 54 | android/keystores/debug.keystore 55 | 56 | # Expo 57 | .expo/* 58 | 59 | # generated by bob 60 | lib/ 61 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # Override Yarn command so we can automatically setup the repo on running `yarn` 2 | 3 | yarn-path "scripts/bootstrap.js" 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. 4 | 5 | ## Development workflow 6 | 7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 8 | 9 | ```sh 10 | yarn 11 | ``` 12 | 13 | While developing, you can run the [example app](/example/) to test your changes. 14 | 15 | To start the packager: 16 | 17 | ```sh 18 | yarn example start 19 | ``` 20 | 21 | To run the example app on Android: 22 | 23 | ```sh 24 | yarn example android 25 | ``` 26 | 27 | To run the example app on iOS: 28 | 29 | ```sh 30 | yarn example ios 31 | ``` 32 | 33 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 34 | 35 | ```sh 36 | yarn typescript 37 | yarn lint 38 | ``` 39 | 40 | To fix formatting errors, run the following: 41 | 42 | ```sh 43 | yarn lint --fix 44 | ``` 45 | 46 | Remember to add tests for your change if possible. Run the unit tests by: 47 | 48 | ```sh 49 | yarn test 50 | ``` 51 | 52 | To edit the Objective-C files, open `example/ios/BidirectionalInfiniteScrollExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-bidirectional-infinite-scroll`. 53 | 54 | To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativebidirectionalinfinitescroll` under `Android`. 55 | 56 | ### Commit message convention 57 | 58 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 59 | 60 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 61 | - `feat`: new features, e.g. add new method to the module. 62 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 63 | - `docs`: changes into documentation, e.g. add usage example for the module.. 64 | - `test`: adding or updating tests, e.g. add integration tests using detox. 65 | - `chore`: tooling changes, e.g. change CI config. 66 | 67 | Our pre-commit hooks verify that your commit message matches this format when committing. 68 | 69 | ### Linting and tests 70 | 71 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 72 | 73 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 74 | 75 | Our pre-commit hooks verify that the linter and tests pass when committing. 76 | 77 | ### Scripts 78 | 79 | The `package.json` file contains various scripts for common tasks: 80 | 81 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 82 | - `yarn typescript`: type-check files with TypeScript. 83 | - `yarn lint`: lint files with ESLint. 84 | - `yarn test`: run unit tests with Jest. 85 | - `yarn example start`: start the Metro server for the example app. 86 | - `yarn example android`: run the example app on Android. 87 | - `yarn example ios`: run the example app on iOS. 88 | 89 | ### Sending a pull request 90 | 91 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github). 92 | 93 | When you're sending a pull request: 94 | 95 | - Prefer small pull requests focused on one change. 96 | - Verify that linters and tests are passing. 97 | - Review the documentation to make sure it looks good. 98 | - Follow the pull request template when opening a pull request. 99 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 100 | 101 | ## Code of Conduct 102 | 103 | ### Our Pledge 104 | 105 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 106 | 107 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 108 | 109 | ### Our Standards 110 | 111 | Examples of behavior that contributes to a positive environment for our community include: 112 | 113 | - Demonstrating empathy and kindness toward other people 114 | - Being respectful of differing opinions, viewpoints, and experiences 115 | - Giving and gracefully accepting constructive feedback 116 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 117 | - Focusing on what is best not just for us as individuals, but for the overall community 118 | 119 | Examples of unacceptable behavior include: 120 | 121 | - The use of sexualized language or imagery, and sexual attention or 122 | advances of any kind 123 | - Trolling, insulting or derogatory comments, and personal or political attacks 124 | - Public or private harassment 125 | - Publishing others' private information, such as a physical or email 126 | address, without their explicit permission 127 | - Other conduct which could reasonably be considered inappropriate in a 128 | professional setting 129 | 130 | ### Enforcement Responsibilities 131 | 132 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 133 | 134 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 135 | 136 | ### Scope 137 | 138 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 139 | 140 | ### Enforcement 141 | 142 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. 143 | 144 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 145 | 146 | ### Enforcement Guidelines 147 | 148 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 149 | 150 | #### 1. Correction 151 | 152 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 153 | 154 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 155 | 156 | #### 2. Warning 157 | 158 | **Community Impact**: A violation through a single incident or series of actions. 159 | 160 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 161 | 162 | #### 3. Temporary Ban 163 | 164 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 165 | 166 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 167 | 168 | #### 4. Permanent Ban 169 | 170 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 171 | 172 | **Consequence**: A permanent ban from any sort of public interaction within the community. 173 | 174 | ### Attribution 175 | 176 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, 177 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 178 | 179 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 180 | 181 | [homepage]: https://www.contributor-covenant.org 182 | 183 | For answers to common questions about this code of conduct, see the FAQ at 184 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 185 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 vishtree 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 📜 React Native Bi-directional Infinite Scroll 2 | 3 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/GetStream/react-native-bidirectional-infinite-scroll/blob/main/LICENSE) 4 | [![NPM](https://img.shields.io/npm/v/react-native-bidirectional-infinite-scroll.svg)](https://www.npmjs.com/package/react-native-bidirectional-infinite-scroll) 5 | [![Compatibility](https://img.shields.io/badge/react--native%20--%20android%20%7C%20iOS-compatible-brightgreen)](https://reactnative.dev/) 6 | 7 | **Implement bidirectional infinite smooth scroll using React Native** 8 | 9 | **[** Built with ♥ at [Stream](https://getstream.io/) **]** 10 | 11 | ![Vishal - Article 01](https://user-images.githubusercontent.com/11586388/109156507-38082600-7771-11eb-82c4-2ca0dec97545.png) 12 | 13 | ## Introduction 14 | 15 | [FlatList](https://reactnative.dev/docs/flatlist) by react-native only allows infinite scroll in one direction (using `onEndReached`). This package adds capability on top of FlatList to allow infinite scroll from both directions, and also maintains **smooth scroll** UX. 16 | 17 | - Accepts prop `onStartReached` & `onEndReached`, which you can use to load more results. 18 | - Calls to onEndReached and onStartReached have been optimized. 19 | - Inline loading Indicators, which can be customized as well. 20 | - Uses [flat-list-mvcp](https://github.com/GetStream/flat-list-mvcp#maintainvisiblecontentposition-prop-support-for-android-react-native) to maintain scroll position or smooth scroll UX. 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 36 | 37 |
31 | iOS 32 | 34 | Android 35 |
38 | 39 | ## 🛠 Installation and Usage 40 | 41 | Please check the complete docs at https://getstream.github.io/react-native-bidirectional-infinite-scroll/ 42 | 43 | ## ✍ Contributing 44 | 45 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. 46 | 47 | ## 🎗 License 48 | 49 | MIT 50 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | 'module:metro-react-native-babel-preset', 4 | '@babel/preset-typescript', 5 | ], 6 | }; 7 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # Example of chat messaging 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 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 26 | 27 |
21 | iOS 22 | 24 | Android 25 |
28 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 22 | * bundleCommand: "ram-bundle", 23 | * 24 | * // whether to bundle JS and assets in debug mode 25 | * bundleInDebug: false, 26 | * 27 | * // whether to bundle JS and assets in release mode 28 | * bundleInRelease: true, 29 | * 30 | * // whether to bundle JS and assets in another build variant (if configured). 31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 32 | * // The configuration property can be in the following formats 33 | * // 'bundleIn${productFlavor}${buildType}' 34 | * // 'bundleIn${buildType}' 35 | * // bundleInFreeDebug: true, 36 | * // bundleInPaidRelease: true, 37 | * // bundleInBeta: true, 38 | * 39 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 40 | * // for BidirectionalInfiniteScrollExample: to disable dev mode in the staging build type (if configured) 41 | * devDisabledInStaging: true, 42 | * // The configuration property can be in the following formats 43 | * // 'devDisabledIn${productFlavor}${buildType}' 44 | * // 'devDisabledIn${buildType}' 45 | * 46 | * // the root of your project, i.e. where "package.json" lives 47 | * root: "../../", 48 | * 49 | * // where to put the JS bundle asset in debug mode 50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 51 | * 52 | * // where to put the JS bundle asset in release mode 53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 54 | * 55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 56 | * // require('./image.png')), in debug mode 57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 58 | * 59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 60 | * // require('./image.png')), in release mode 61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 62 | * 63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 67 | * // for BidirectionalInfiniteScrollExample, you might want to remove it from here. 68 | * inputExcludes: ["android/**", "ios/**"], 69 | * 70 | * // override which node gets called and with what additional arguments 71 | * nodeExecutableAndArgs: ["node"], 72 | * 73 | * // supply additional arguments to the packager 74 | * extraPackagerArgs: [] 75 | * ] 76 | */ 77 | 78 | project.ext.react = [ 79 | enableHermes: false, // clean and rebuild if changing 80 | entryFile: "index.tsx", 81 | ] 82 | 83 | apply from: "../../node_modules/react-native/react.gradle" 84 | 85 | /** 86 | * Set this to true to create two separate APKs instead of one: 87 | * - An APK that only works on ARM devices 88 | * - An APK that only works on x86 devices 89 | * The advantage is the size of the APK is reduced by about 4MB. 90 | * Upload all the APKs to the Play Store and people will download 91 | * the correct one based on the CPU architecture of their device. 92 | */ 93 | def enableSeparateBuildPerCPUArchitecture = false 94 | 95 | /** 96 | * Run Proguard to shrink the Java bytecode in release builds. 97 | */ 98 | def enableProguardInReleaseBuilds = false 99 | 100 | /** 101 | * The preferred build flavor of JavaScriptCore. 102 | * 103 | * For BidirectionalInfiniteScrollExample, to use the international variant, you can use: 104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 105 | * 106 | * The international variant includes ICU i18n library and necessary data 107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 108 | * give correct results when using with locales other than en-US. Note that 109 | * this variant is about 6MiB larger per architecture than default. 110 | */ 111 | def jscFlavor = 'org.webkit:android-jsc:+' 112 | 113 | /** 114 | * Whether to enable the Hermes VM. 115 | * 116 | * This should be set on project.ext.react and mirrored here. If it is not set 117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 118 | * and the benefits of using Hermes will therefore be sharply reduced. 119 | */ 120 | def enableHermes = project.ext.react.get("enableHermes", false); 121 | 122 | android { 123 | compileSdkVersion rootProject.ext.compileSdkVersion 124 | 125 | compileOptions { 126 | sourceCompatibility JavaVersion.VERSION_1_8 127 | targetCompatibility JavaVersion.VERSION_1_8 128 | } 129 | 130 | defaultConfig { 131 | applicationId "com.example.reactnativebidirectionalinfinitescroll" 132 | minSdkVersion rootProject.ext.minSdkVersion 133 | targetSdkVersion rootProject.ext.targetSdkVersion 134 | versionCode 1 135 | versionName "1.0" 136 | } 137 | splits { 138 | abi { 139 | reset() 140 | enable enableSeparateBuildPerCPUArchitecture 141 | universalApk false // If true, also generate a universal APK 142 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 143 | } 144 | } 145 | signingConfigs { 146 | debug { 147 | storeFile file('debug.keystore') 148 | storePassword 'android' 149 | keyAlias 'androiddebugkey' 150 | keyPassword 'android' 151 | } 152 | } 153 | buildTypes { 154 | debug { 155 | signingConfig signingConfigs.debug 156 | } 157 | release { 158 | // Caution! In production, you need to generate your own keystore file. 159 | // see https://reactnative.dev/docs/signed-apk-android. 160 | signingConfig signingConfigs.debug 161 | minifyEnabled enableProguardInReleaseBuilds 162 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 163 | } 164 | } 165 | // applicationVariants are e.g. debug, release 166 | applicationVariants.all { variant -> 167 | variant.outputs.each { output -> 168 | // For each separate APK per architecture, set a unique version code as described here: 169 | // https://developer.android.com/studio/build/configure-apk-splits.html 170 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 171 | def abi = output.getFilter(OutputFile.ABI) 172 | if (abi != null) { // null for the universal-debug, universal-release variants 173 | output.versionCodeOverride = 174 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 175 | } 176 | 177 | } 178 | } 179 | } 180 | 181 | dependencies { 182 | implementation fileTree(dir: "libs", include: ["*.jar"]) 183 | //noinspection GradleDynamicVersion 184 | implementation "com.facebook.react:react-native:+" // From node_modules 185 | 186 | 187 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 188 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 189 | exclude group:'com.facebook.fbjni' 190 | } 191 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 192 | exclude group:'com.facebook.flipper' 193 | exclude group:'com.squareup.okhttp3', module:'okhttp' 194 | } 195 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 196 | exclude group:'com.facebook.flipper' 197 | } 198 | 199 | if (enableHermes) { 200 | def hermesPath = "../../node_modules/hermes-engine/android/"; 201 | debugImplementation files(hermesPath + "hermes-debug.aar") 202 | releaseImplementation files(hermesPath + "hermes-release.aar") 203 | } else { 204 | implementation jscFlavor 205 | } 206 | 207 | } 208 | 209 | // Run this once to be able to run the application with BUCK 210 | // puts all compile dependencies into folder libs for BUCK to use 211 | task copyDownloadableDepsToLibs(type: Copy) { 212 | from configurations.compile 213 | into 'libs' 214 | } 215 | 216 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 217 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/example/reactnativebidirectionalinfinitescroll/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.example.reactnativebidirectionalinfinitescroll; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 32 | client.addPlugin(new ReactFlipperPlugin()); 33 | client.addPlugin(new DatabasesFlipperPlugin(context)); 34 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 35 | client.addPlugin(CrashReporterPlugin.getInstance()); 36 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 37 | NetworkingModule.setCustomClientBuilder( 38 | new NetworkingModule.CustomClientBuilder() { 39 | @Override 40 | public void apply(OkHttpClient.Builder builder) { 41 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 42 | } 43 | }); 44 | client.addPlugin(networkFlipperPlugin); 45 | client.start(); 46 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 47 | // Hence we run if after all native modules have been initialized 48 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 49 | if (reactContext == null) { 50 | reactInstanceManager.addReactInstanceEventListener( 51 | new ReactInstanceManager.ReactInstanceEventListener() { 52 | @Override 53 | public void onReactContextInitialized(ReactContext reactContext) { 54 | reactInstanceManager.removeReactInstanceEventListener(this); 55 | reactContext.runOnNativeModulesQueueThread( 56 | new Runnable() { 57 | @Override 58 | public void run() { 59 | client.addPlugin(new FrescoFlipperPlugin()); 60 | } 61 | }); 62 | } 63 | }); 64 | } else { 65 | client.addPlugin(new FrescoFlipperPlugin()); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativebidirectionalinfinitescroll/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativebidirectionalinfinitescroll; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "BidirectionalInfiniteScrollExample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativebidirectionalinfinitescroll/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativebidirectionalinfinitescroll; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactNativeHost; 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.ReactInstanceManager; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = 17 | new ReactNativeHost(this) { 18 | @Override 19 | public boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | @SuppressWarnings("UnnecessaryLocalVariable") 26 | List packages = new PackageList(this).getPackages(); 27 | // Packages that cannot be autolinked yet can be added manually here, for BidirectionalInfiniteScrollExample: 28 | // packages.add(new MyReactNativePackage()); 29 | 30 | return packages; 31 | } 32 | 33 | @Override 34 | protected String getJSMainModuleName() { 35 | return "index"; 36 | } 37 | }; 38 | 39 | @Override 40 | public ReactNativeHost getReactNativeHost() { 41 | return mReactNativeHost; 42 | } 43 | 44 | @Override 45 | public void onCreate() { 46 | super.onCreate(); 47 | SoLoader.init(this, /* native exopackage */ false); 48 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want Flipper enabled 49 | } 50 | 51 | /** 52 | * Loads Flipper in React Native templates. 53 | * 54 | * @param context 55 | */ 56 | private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 57 | if (BuildConfig.DEBUG) { 58 | try { 59 | /* 60 | We use reflection here to pick up the class that initializes Flipper, 61 | since Flipper library is not available in release mode 62 | */ 63 | Class aClass = Class.forName("com.reactnativebidirectionalinfinitescrollExample.ReactNativeFlipper"); 64 | aClass 65 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 66 | .invoke(null, context, reactInstanceManager); 67 | } catch (ClassNotFoundException e) { 68 | e.printStackTrace(); 69 | } catch (NoSuchMethodException e) { 70 | e.printStackTrace(); 71 | } catch (IllegalAccessException e) { 72 | e.printStackTrace(); 73 | } catch (InvocationTargetException e) { 74 | e.printStackTrace(); 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BidirectionalInfiniteScroll Example 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.2" 6 | minSdkVersion = 16 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | } 10 | repositories { 11 | google() 12 | jcenter() 13 | } 14 | dependencies { 15 | classpath("com.android.tools.build:gradle:3.5.3") 16 | 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | mavenLocal() 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | 34 | google() 35 | jcenter() 36 | maven { url 'https://www.jitpack.io' } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useAndroidX=true 21 | android.enableJetifier=true 22 | FLIPPER_VERSION=0.54.0 23 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'BidirectionalInfiniteScrollExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | 5 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BidirectionalInfiniteScrollExample", 3 | "displayName": "BidirectionalInfiniteScroll Example" 4 | } 5 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | 'module:metro-react-native-babel-preset', 4 | '@babel/preset-typescript', 5 | ], 6 | }; 7 | -------------------------------------------------------------------------------- /example/index.tsx: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './src/App'; 3 | import { name as appName } from './app.json'; 4 | 5 | AppRegistry.registerComponent(appName, () => App); 6 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample.xcodeproj/xcshareddata/xcschemes/BidirectionalInfiniteScrollExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (nonatomic, strong) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | #import 13 | 14 | #ifdef FB_SONARKIT_ENABLED 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | static void InitializeFlipper(UIApplication *application) { 22 | FlipperClient *client = [FlipperClient sharedClient]; 23 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 24 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 25 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 26 | [client addPlugin:[FlipperKitReactPlugin new]]; 27 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 28 | [client start]; 29 | } 30 | #endif 31 | 32 | @implementation AppDelegate 33 | 34 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 35 | { 36 | #ifdef FB_SONARKIT_ENABLED 37 | InitializeFlipper(application); 38 | #endif 39 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 40 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 41 | moduleName:@"BidirectionalInfiniteScrollExample" 42 | initialProperties:nil]; 43 | 44 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 45 | 46 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 47 | UIViewController *rootViewController = [UIViewController new]; 48 | rootViewController.view = rootView; 49 | self.window.rootViewController = rootViewController; 50 | [self.window makeKeyAndVisible]; 51 | return YES; 52 | } 53 | 54 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 55 | { 56 | #if DEBUG 57 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 58 | #else 59 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 60 | #endif 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | BidirectionalInfiniteScroll Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UIViewControllerBasedStatusBarAppearance 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /example/ios/BidirectionalInfiniteScrollExample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/ios/File.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // BidirectionalInfiniteScrollExample 4 | // 5 | 6 | import Foundation 7 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'BidirectionalInfiniteScrollExample' do 7 | config = use_native_modules! 8 | 9 | use_react_native!(:path => config["reactNativePath"]) 10 | 11 | 12 | # Enables Flipper. 13 | # 14 | # Note that if you have use_frameworks! enabled, Flipper will not work and 15 | # you should disable these next few lines. 16 | use_flipper!({ 'Flipper' => '0.75.1' }) 17 | post_install do |installer| 18 | flipper_post_install(installer) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost-for-react-native (1.63.0) 3 | - CocoaAsyncSocket (7.6.5) 4 | - DoubleConversion (1.1.6) 5 | - FBLazyVector (0.63.4) 6 | - FBReactNativeSpec (0.63.4): 7 | - Folly (= 2020.01.13.00) 8 | - RCTRequired (= 0.63.4) 9 | - RCTTypeSafety (= 0.63.4) 10 | - React-Core (= 0.63.4) 11 | - React-jsi (= 0.63.4) 12 | - ReactCommon/turbomodule/core (= 0.63.4) 13 | - Flipper (0.75.1): 14 | - Flipper-Folly (~> 2.5) 15 | - Flipper-RSocket (~> 1.3) 16 | - Flipper-DoubleConversion (1.1.7) 17 | - Flipper-Folly (2.5.1): 18 | - boost-for-react-native 19 | - Flipper-DoubleConversion 20 | - Flipper-Glog 21 | - libevent (~> 2.1.12) 22 | - OpenSSL-Universal (= 1.1.180) 23 | - Flipper-Glog (0.3.6) 24 | - Flipper-PeerTalk (0.0.4) 25 | - Flipper-RSocket (1.3.0): 26 | - Flipper-Folly (~> 2.5) 27 | - FlipperKit (0.75.1): 28 | - FlipperKit/Core (= 0.75.1) 29 | - FlipperKit/Core (0.75.1): 30 | - Flipper (~> 0.75.1) 31 | - FlipperKit/CppBridge 32 | - FlipperKit/FBCxxFollyDynamicConvert 33 | - FlipperKit/FBDefines 34 | - FlipperKit/FKPortForwarding 35 | - FlipperKit/CppBridge (0.75.1): 36 | - Flipper (~> 0.75.1) 37 | - FlipperKit/FBCxxFollyDynamicConvert (0.75.1): 38 | - Flipper-Folly (~> 2.5) 39 | - FlipperKit/FBDefines (0.75.1) 40 | - FlipperKit/FKPortForwarding (0.75.1): 41 | - CocoaAsyncSocket (~> 7.6) 42 | - Flipper-PeerTalk (~> 0.0.4) 43 | - FlipperKit/FlipperKitHighlightOverlay (0.75.1) 44 | - FlipperKit/FlipperKitLayoutPlugin (0.75.1): 45 | - FlipperKit/Core 46 | - FlipperKit/FlipperKitHighlightOverlay 47 | - FlipperKit/FlipperKitLayoutTextSearchable 48 | - YogaKit (~> 1.18) 49 | - FlipperKit/FlipperKitLayoutTextSearchable (0.75.1) 50 | - FlipperKit/FlipperKitNetworkPlugin (0.75.1): 51 | - FlipperKit/Core 52 | - FlipperKit/FlipperKitReactPlugin (0.75.1): 53 | - FlipperKit/Core 54 | - FlipperKit/FlipperKitUserDefaultsPlugin (0.75.1): 55 | - FlipperKit/Core 56 | - FlipperKit/SKIOSNetworkPlugin (0.75.1): 57 | - FlipperKit/Core 58 | - FlipperKit/FlipperKitNetworkPlugin 59 | - Folly (2020.01.13.00): 60 | - boost-for-react-native 61 | - DoubleConversion 62 | - Folly/Default (= 2020.01.13.00) 63 | - glog 64 | - Folly/Default (2020.01.13.00): 65 | - boost-for-react-native 66 | - DoubleConversion 67 | - glog 68 | - glog (0.3.5) 69 | - libevent (2.1.12) 70 | - OpenSSL-Universal (1.1.180) 71 | - RCTRequired (0.63.4) 72 | - RCTTypeSafety (0.63.4): 73 | - FBLazyVector (= 0.63.4) 74 | - Folly (= 2020.01.13.00) 75 | - RCTRequired (= 0.63.4) 76 | - React-Core (= 0.63.4) 77 | - React (0.63.4): 78 | - React-Core (= 0.63.4) 79 | - React-Core/DevSupport (= 0.63.4) 80 | - React-Core/RCTWebSocket (= 0.63.4) 81 | - React-RCTActionSheet (= 0.63.4) 82 | - React-RCTAnimation (= 0.63.4) 83 | - React-RCTBlob (= 0.63.4) 84 | - React-RCTImage (= 0.63.4) 85 | - React-RCTLinking (= 0.63.4) 86 | - React-RCTNetwork (= 0.63.4) 87 | - React-RCTSettings (= 0.63.4) 88 | - React-RCTText (= 0.63.4) 89 | - React-RCTVibration (= 0.63.4) 90 | - React-callinvoker (0.63.4) 91 | - React-Core (0.63.4): 92 | - Folly (= 2020.01.13.00) 93 | - glog 94 | - React-Core/Default (= 0.63.4) 95 | - React-cxxreact (= 0.63.4) 96 | - React-jsi (= 0.63.4) 97 | - React-jsiexecutor (= 0.63.4) 98 | - Yoga 99 | - React-Core/CoreModulesHeaders (0.63.4): 100 | - Folly (= 2020.01.13.00) 101 | - glog 102 | - React-Core/Default 103 | - React-cxxreact (= 0.63.4) 104 | - React-jsi (= 0.63.4) 105 | - React-jsiexecutor (= 0.63.4) 106 | - Yoga 107 | - React-Core/Default (0.63.4): 108 | - Folly (= 2020.01.13.00) 109 | - glog 110 | - React-cxxreact (= 0.63.4) 111 | - React-jsi (= 0.63.4) 112 | - React-jsiexecutor (= 0.63.4) 113 | - Yoga 114 | - React-Core/DevSupport (0.63.4): 115 | - Folly (= 2020.01.13.00) 116 | - glog 117 | - React-Core/Default (= 0.63.4) 118 | - React-Core/RCTWebSocket (= 0.63.4) 119 | - React-cxxreact (= 0.63.4) 120 | - React-jsi (= 0.63.4) 121 | - React-jsiexecutor (= 0.63.4) 122 | - React-jsinspector (= 0.63.4) 123 | - Yoga 124 | - React-Core/RCTActionSheetHeaders (0.63.4): 125 | - Folly (= 2020.01.13.00) 126 | - glog 127 | - React-Core/Default 128 | - React-cxxreact (= 0.63.4) 129 | - React-jsi (= 0.63.4) 130 | - React-jsiexecutor (= 0.63.4) 131 | - Yoga 132 | - React-Core/RCTAnimationHeaders (0.63.4): 133 | - Folly (= 2020.01.13.00) 134 | - glog 135 | - React-Core/Default 136 | - React-cxxreact (= 0.63.4) 137 | - React-jsi (= 0.63.4) 138 | - React-jsiexecutor (= 0.63.4) 139 | - Yoga 140 | - React-Core/RCTBlobHeaders (0.63.4): 141 | - Folly (= 2020.01.13.00) 142 | - glog 143 | - React-Core/Default 144 | - React-cxxreact (= 0.63.4) 145 | - React-jsi (= 0.63.4) 146 | - React-jsiexecutor (= 0.63.4) 147 | - Yoga 148 | - React-Core/RCTImageHeaders (0.63.4): 149 | - Folly (= 2020.01.13.00) 150 | - glog 151 | - React-Core/Default 152 | - React-cxxreact (= 0.63.4) 153 | - React-jsi (= 0.63.4) 154 | - React-jsiexecutor (= 0.63.4) 155 | - Yoga 156 | - React-Core/RCTLinkingHeaders (0.63.4): 157 | - Folly (= 2020.01.13.00) 158 | - glog 159 | - React-Core/Default 160 | - React-cxxreact (= 0.63.4) 161 | - React-jsi (= 0.63.4) 162 | - React-jsiexecutor (= 0.63.4) 163 | - Yoga 164 | - React-Core/RCTNetworkHeaders (0.63.4): 165 | - Folly (= 2020.01.13.00) 166 | - glog 167 | - React-Core/Default 168 | - React-cxxreact (= 0.63.4) 169 | - React-jsi (= 0.63.4) 170 | - React-jsiexecutor (= 0.63.4) 171 | - Yoga 172 | - React-Core/RCTSettingsHeaders (0.63.4): 173 | - Folly (= 2020.01.13.00) 174 | - glog 175 | - React-Core/Default 176 | - React-cxxreact (= 0.63.4) 177 | - React-jsi (= 0.63.4) 178 | - React-jsiexecutor (= 0.63.4) 179 | - Yoga 180 | - React-Core/RCTTextHeaders (0.63.4): 181 | - Folly (= 2020.01.13.00) 182 | - glog 183 | - React-Core/Default 184 | - React-cxxreact (= 0.63.4) 185 | - React-jsi (= 0.63.4) 186 | - React-jsiexecutor (= 0.63.4) 187 | - Yoga 188 | - React-Core/RCTVibrationHeaders (0.63.4): 189 | - Folly (= 2020.01.13.00) 190 | - glog 191 | - React-Core/Default 192 | - React-cxxreact (= 0.63.4) 193 | - React-jsi (= 0.63.4) 194 | - React-jsiexecutor (= 0.63.4) 195 | - Yoga 196 | - React-Core/RCTWebSocket (0.63.4): 197 | - Folly (= 2020.01.13.00) 198 | - glog 199 | - React-Core/Default (= 0.63.4) 200 | - React-cxxreact (= 0.63.4) 201 | - React-jsi (= 0.63.4) 202 | - React-jsiexecutor (= 0.63.4) 203 | - Yoga 204 | - React-CoreModules (0.63.4): 205 | - FBReactNativeSpec (= 0.63.4) 206 | - Folly (= 2020.01.13.00) 207 | - RCTTypeSafety (= 0.63.4) 208 | - React-Core/CoreModulesHeaders (= 0.63.4) 209 | - React-jsi (= 0.63.4) 210 | - React-RCTImage (= 0.63.4) 211 | - ReactCommon/turbomodule/core (= 0.63.4) 212 | - React-cxxreact (0.63.4): 213 | - boost-for-react-native (= 1.63.0) 214 | - DoubleConversion 215 | - Folly (= 2020.01.13.00) 216 | - glog 217 | - React-callinvoker (= 0.63.4) 218 | - React-jsinspector (= 0.63.4) 219 | - React-jsi (0.63.4): 220 | - boost-for-react-native (= 1.63.0) 221 | - DoubleConversion 222 | - Folly (= 2020.01.13.00) 223 | - glog 224 | - React-jsi/Default (= 0.63.4) 225 | - React-jsi/Default (0.63.4): 226 | - boost-for-react-native (= 1.63.0) 227 | - DoubleConversion 228 | - Folly (= 2020.01.13.00) 229 | - glog 230 | - React-jsiexecutor (0.63.4): 231 | - DoubleConversion 232 | - Folly (= 2020.01.13.00) 233 | - glog 234 | - React-cxxreact (= 0.63.4) 235 | - React-jsi (= 0.63.4) 236 | - React-jsinspector (0.63.4) 237 | - React-RCTActionSheet (0.63.4): 238 | - React-Core/RCTActionSheetHeaders (= 0.63.4) 239 | - React-RCTAnimation (0.63.4): 240 | - FBReactNativeSpec (= 0.63.4) 241 | - Folly (= 2020.01.13.00) 242 | - RCTTypeSafety (= 0.63.4) 243 | - React-Core/RCTAnimationHeaders (= 0.63.4) 244 | - React-jsi (= 0.63.4) 245 | - ReactCommon/turbomodule/core (= 0.63.4) 246 | - React-RCTBlob (0.63.4): 247 | - FBReactNativeSpec (= 0.63.4) 248 | - Folly (= 2020.01.13.00) 249 | - React-Core/RCTBlobHeaders (= 0.63.4) 250 | - React-Core/RCTWebSocket (= 0.63.4) 251 | - React-jsi (= 0.63.4) 252 | - React-RCTNetwork (= 0.63.4) 253 | - ReactCommon/turbomodule/core (= 0.63.4) 254 | - React-RCTImage (0.63.4): 255 | - FBReactNativeSpec (= 0.63.4) 256 | - Folly (= 2020.01.13.00) 257 | - RCTTypeSafety (= 0.63.4) 258 | - React-Core/RCTImageHeaders (= 0.63.4) 259 | - React-jsi (= 0.63.4) 260 | - React-RCTNetwork (= 0.63.4) 261 | - ReactCommon/turbomodule/core (= 0.63.4) 262 | - React-RCTLinking (0.63.4): 263 | - FBReactNativeSpec (= 0.63.4) 264 | - React-Core/RCTLinkingHeaders (= 0.63.4) 265 | - React-jsi (= 0.63.4) 266 | - ReactCommon/turbomodule/core (= 0.63.4) 267 | - React-RCTNetwork (0.63.4): 268 | - FBReactNativeSpec (= 0.63.4) 269 | - Folly (= 2020.01.13.00) 270 | - RCTTypeSafety (= 0.63.4) 271 | - React-Core/RCTNetworkHeaders (= 0.63.4) 272 | - React-jsi (= 0.63.4) 273 | - ReactCommon/turbomodule/core (= 0.63.4) 274 | - React-RCTSettings (0.63.4): 275 | - FBReactNativeSpec (= 0.63.4) 276 | - Folly (= 2020.01.13.00) 277 | - RCTTypeSafety (= 0.63.4) 278 | - React-Core/RCTSettingsHeaders (= 0.63.4) 279 | - React-jsi (= 0.63.4) 280 | - ReactCommon/turbomodule/core (= 0.63.4) 281 | - React-RCTText (0.63.4): 282 | - React-Core/RCTTextHeaders (= 0.63.4) 283 | - React-RCTVibration (0.63.4): 284 | - FBReactNativeSpec (= 0.63.4) 285 | - Folly (= 2020.01.13.00) 286 | - React-Core/RCTVibrationHeaders (= 0.63.4) 287 | - React-jsi (= 0.63.4) 288 | - ReactCommon/turbomodule/core (= 0.63.4) 289 | - ReactCommon/turbomodule/core (0.63.4): 290 | - DoubleConversion 291 | - Folly (= 2020.01.13.00) 292 | - glog 293 | - React-callinvoker (= 0.63.4) 294 | - React-Core (= 0.63.4) 295 | - React-cxxreact (= 0.63.4) 296 | - React-jsi (= 0.63.4) 297 | - Yoga (1.14.0) 298 | - YogaKit (1.18.1): 299 | - Yoga (~> 1.14) 300 | 301 | DEPENDENCIES: 302 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 303 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) 304 | - FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`) 305 | - Flipper (= 0.75.1) 306 | - Flipper-DoubleConversion (= 1.1.7) 307 | - Flipper-Folly (~> 2.2) 308 | - Flipper-Glog (= 0.3.6) 309 | - Flipper-PeerTalk (~> 0.0.4) 310 | - Flipper-RSocket (~> 1.1) 311 | - FlipperKit (= 0.75.1) 312 | - FlipperKit/Core (= 0.75.1) 313 | - FlipperKit/CppBridge (= 0.75.1) 314 | - FlipperKit/FBCxxFollyDynamicConvert (= 0.75.1) 315 | - FlipperKit/FBDefines (= 0.75.1) 316 | - FlipperKit/FKPortForwarding (= 0.75.1) 317 | - FlipperKit/FlipperKitHighlightOverlay (= 0.75.1) 318 | - FlipperKit/FlipperKitLayoutPlugin (= 0.75.1) 319 | - FlipperKit/FlipperKitLayoutTextSearchable (= 0.75.1) 320 | - FlipperKit/FlipperKitNetworkPlugin (= 0.75.1) 321 | - FlipperKit/FlipperKitReactPlugin (= 0.75.1) 322 | - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.75.1) 323 | - FlipperKit/SKIOSNetworkPlugin (= 0.75.1) 324 | - Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`) 325 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 326 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) 327 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) 328 | - React (from `../node_modules/react-native/`) 329 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) 330 | - React-Core (from `../node_modules/react-native/`) 331 | - React-Core/DevSupport (from `../node_modules/react-native/`) 332 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`) 333 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) 334 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 335 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 336 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 337 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 338 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 339 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 340 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 341 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 342 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 343 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 344 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 345 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 346 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 347 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) 348 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) 349 | 350 | SPEC REPOS: 351 | trunk: 352 | - boost-for-react-native 353 | - CocoaAsyncSocket 354 | - Flipper 355 | - Flipper-DoubleConversion 356 | - Flipper-Folly 357 | - Flipper-Glog 358 | - Flipper-PeerTalk 359 | - Flipper-RSocket 360 | - FlipperKit 361 | - libevent 362 | - OpenSSL-Universal 363 | - YogaKit 364 | 365 | EXTERNAL SOURCES: 366 | DoubleConversion: 367 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 368 | FBLazyVector: 369 | :path: "../node_modules/react-native/Libraries/FBLazyVector" 370 | FBReactNativeSpec: 371 | :path: "../node_modules/react-native/Libraries/FBReactNativeSpec" 372 | Folly: 373 | :podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec" 374 | glog: 375 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 376 | RCTRequired: 377 | :path: "../node_modules/react-native/Libraries/RCTRequired" 378 | RCTTypeSafety: 379 | :path: "../node_modules/react-native/Libraries/TypeSafety" 380 | React: 381 | :path: "../node_modules/react-native/" 382 | React-callinvoker: 383 | :path: "../node_modules/react-native/ReactCommon/callinvoker" 384 | React-Core: 385 | :path: "../node_modules/react-native/" 386 | React-CoreModules: 387 | :path: "../node_modules/react-native/React/CoreModules" 388 | React-cxxreact: 389 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 390 | React-jsi: 391 | :path: "../node_modules/react-native/ReactCommon/jsi" 392 | React-jsiexecutor: 393 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 394 | React-jsinspector: 395 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 396 | React-RCTActionSheet: 397 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 398 | React-RCTAnimation: 399 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 400 | React-RCTBlob: 401 | :path: "../node_modules/react-native/Libraries/Blob" 402 | React-RCTImage: 403 | :path: "../node_modules/react-native/Libraries/Image" 404 | React-RCTLinking: 405 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 406 | React-RCTNetwork: 407 | :path: "../node_modules/react-native/Libraries/Network" 408 | React-RCTSettings: 409 | :path: "../node_modules/react-native/Libraries/Settings" 410 | React-RCTText: 411 | :path: "../node_modules/react-native/Libraries/Text" 412 | React-RCTVibration: 413 | :path: "../node_modules/react-native/Libraries/Vibration" 414 | ReactCommon: 415 | :path: "../node_modules/react-native/ReactCommon" 416 | Yoga: 417 | :path: "../node_modules/react-native/ReactCommon/yoga" 418 | 419 | SPEC CHECKSUMS: 420 | boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c 421 | CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 422 | DoubleConversion: cde416483dac037923206447da6e1454df403714 423 | FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e 424 | FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e 425 | Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021 426 | Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 427 | Flipper-Folly: f7a3caafbd74bda4827954fd7a6e000e36355489 428 | Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6 429 | Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 430 | Flipper-RSocket: 602921fee03edacf18f5d6f3d3594ba477f456e5 431 | FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00 432 | Folly: b73c3869541e86821df3c387eb0af5f65addfab4 433 | glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 434 | libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 435 | OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b 436 | RCTRequired: 082f10cd3f905d6c124597fd1c14f6f2655ff65e 437 | RCTTypeSafety: 8c9c544ecbf20337d069e4ae7fd9a377aadf504b 438 | React: b0a957a2c44da4113b0c4c9853d8387f8e64e615 439 | React-callinvoker: c3f44dd3cb195b6aa46621fff95ded79d59043fe 440 | React-Core: d3b2a1ac9a2c13c3bcde712d9281fc1c8a5b315b 441 | React-CoreModules: 0581ff36cb797da0943d424f69e7098e43e9be60 442 | React-cxxreact: c1480d4fda5720086c90df537ee7d285d4c57ac3 443 | React-jsi: a0418934cf48f25b485631deb27c64dc40fb4c31 444 | React-jsiexecutor: 93bd528844ad21dc07aab1c67cb10abae6df6949 445 | React-jsinspector: 58aef7155bc9a9683f5b60b35eccea8722a4f53a 446 | React-RCTActionSheet: 89a0ca9f4a06c1f93c26067af074ccdce0f40336 447 | React-RCTAnimation: 1bde3ecc0c104c55df246eda516e0deb03c4e49b 448 | React-RCTBlob: a97d378b527740cc667e03ebfa183a75231ab0f0 449 | React-RCTImage: c1b1f2d3f43a4a528c8946d6092384b5c880d2f0 450 | React-RCTLinking: 35ae4ab9dc0410d1fcbdce4d7623194a27214fb2 451 | React-RCTNetwork: 29ec2696f8d8cfff7331fac83d3e893c95ef43ae 452 | React-RCTSettings: 60f0691bba2074ef394f95d4c2265ec284e0a46a 453 | React-RCTText: 5c51df3f08cb9dedc6e790161195d12bac06101c 454 | React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d 455 | ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b 456 | Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6 457 | YogaKit: f782866e155069a2cca2517aafea43200b01fd5a 458 | 459 | PODFILE CHECKSUM: 1ca5afe4c648999e1758a6b79555559960b291df 460 | 461 | COCOAPODS: 1.10.1 462 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const blacklist = require('metro-config/src/defaults/blacklist'); 3 | const escape = require('escape-string-regexp'); 4 | const pak = require('../package.json'); 5 | 6 | const root = path.resolve(__dirname, '..'); 7 | 8 | const modules = Object.keys({ 9 | ...pak.peerDependencies, 10 | }); 11 | 12 | module.exports = { 13 | projectRoot: __dirname, 14 | watchFolders: [root], 15 | 16 | // We need to make sure that only one version is loaded for peerDependencies 17 | // So we blacklist them at the root, and alias them to the versions in example's node_modules 18 | resolver: { 19 | blacklistRE: blacklist( 20 | modules.map( 21 | (m) => 22 | new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) 23 | ) 24 | ), 25 | 26 | extraNodeModules: modules.reduce((acc, name) => { 27 | acc[name] = path.join(__dirname, 'node_modules', name); 28 | return acc; 29 | }, {}), 30 | }, 31 | 32 | transformer: { 33 | getTransformOptions: async () => ({ 34 | transform: { 35 | experimentalImportSupport: false, 36 | inlineRequires: true, 37 | }, 38 | }), 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-bidirectional-infinite-scroll-example", 3 | "description": "Example app for react-native-bidirectional-infinite-scroll", 4 | "version": "0.0.1", 5 | "private": true, 6 | "scripts": { 7 | "android": "react-native run-android", 8 | "ios": "react-native run-ios", 9 | "start": "react-native start" 10 | }, 11 | "dependencies": { 12 | "@stream-io/flat-list-mvcp": "0.10.0", 13 | "react": "16.13.1", 14 | "react-native": "0.63.4", 15 | "react-native-bidirectional-infinite-scroll": "link:../" 16 | }, 17 | "devDependencies": { 18 | "@babel/core": "^7.12.10", 19 | "@babel/runtime": "^7.12.5", 20 | "babel-plugin-module-resolver": "^4.0.0", 21 | "metro-react-native-babel-preset": "^0.64.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import MessageListExample from './MessageListExample'; 3 | 4 | const App = () => { 5 | return ; 6 | }; 7 | 8 | export default App; 9 | -------------------------------------------------------------------------------- /example/src/MessageBubble.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text, View } from 'react-native'; 3 | import type { Message } from './utils'; 4 | 5 | type Props = { 6 | item: Message; 7 | }; 8 | 9 | export const MessageBubble: React.FC = ({ item }) => { 10 | if (item.isMyMessage) { 11 | return ( 12 | 16 | {item.text} 17 | 18 | ); 19 | } 20 | 21 | return ( 22 | 23 | {item.text} 24 | 25 | ); 26 | }; 27 | 28 | const styles = StyleSheet.create({ 29 | messageBubble: { 30 | maxWidth: 300, 31 | padding: 10, 32 | borderRadius: 10, 33 | marginVertical: 5, 34 | marginHorizontal: 5, 35 | backgroundColor: '#F1F0F0', 36 | }, 37 | myMessageBubble: { 38 | alignSelf: 'flex-end', 39 | // borderColor: '#989898', 40 | // borderWidth: 1, 41 | backgroundColor: '#3784FF', 42 | }, 43 | messageText: { 44 | fontSize: 15, 45 | }, 46 | myMessageText: { 47 | color: 'white', 48 | fontSize: 15, 49 | }, 50 | }); 51 | -------------------------------------------------------------------------------- /example/src/MessageListExample.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | import { SafeAreaView, StyleSheet, Text, View } from 'react-native'; 3 | 4 | import { FlatList } from 'react-native-bidirectional-infinite-scroll'; 5 | import { MessageBubble } from './MessageBubble'; 6 | import { Message, queryMoreMessages } from './utils'; 7 | 8 | const App = () => { 9 | const [messages, setMessages] = useState>([]); 10 | useEffect(() => { 11 | const initChat = async () => { 12 | const initialMessages = await queryMoreMessages(50); 13 | if (!initialMessages) return; 14 | 15 | setMessages(initialMessages); 16 | }; 17 | 18 | initChat(); 19 | }, []); 20 | 21 | const loadMoreOlderMessages = async () => { 22 | const newMessages = await queryMoreMessages(10); 23 | setMessages((m) => { 24 | return m.concat(newMessages); 25 | }); 26 | }; 27 | 28 | const loadMoreRecentMessages = async () => { 29 | const newMessages = await queryMoreMessages(10); 30 | setMessages((m) => { 31 | return newMessages.concat(m); 32 | }); 33 | }; 34 | 35 | if (!messages.length) { 36 | return null; 37 | } 38 | 39 | return ( 40 | 41 | 42 | Chat between two users 43 | 44 | 51 | 52 | ); 53 | }; 54 | 55 | const styles = StyleSheet.create({ 56 | header: { 57 | alignItems: 'center', 58 | paddingVertical: 10, 59 | borderBottomColor: '#BEBEBE', 60 | borderBottomWidth: 1, 61 | }, 62 | headerTitle: { fontSize: 20, fontWeight: 'bold' }, 63 | safeArea: { 64 | flex: 1, 65 | }, 66 | sendMessageButton: { 67 | width: '100%', 68 | padding: 20, 69 | backgroundColor: '#FF4500', 70 | alignItems: 'center', 71 | }, 72 | sendButtonTitle: { 73 | color: 'white', 74 | fontSize: 15, 75 | fontWeight: 'bold', 76 | }, 77 | }); 78 | 79 | export default App; 80 | -------------------------------------------------------------------------------- /example/src/utils.ts: -------------------------------------------------------------------------------- 1 | // Generate random integer, we will use this to use random message from list of dummy messages. 2 | export const getRandomInt = (min: number, max: number) => { 3 | return Math.floor(Math.random() * (max - min)) + min; 4 | }; 5 | 6 | // Generate unique key for message component of FlatList. 7 | export const generateUniqueKey = () => 8 | `_${Math.random().toString(36).substr(2, 9)}`; 9 | 10 | export type Message = { 11 | id: string; 12 | text: string; 13 | isMyMessage: boolean; 14 | }; 15 | 16 | // Mocks the api call to query 'n' number of messages. 17 | export const queryMoreMessages: (n: number) => Promise> = ( 18 | n 19 | ) => { 20 | return new Promise((resolve) => { 21 | const newMessages: Array = []; 22 | 23 | for (let i = 0; i < n; i++) { 24 | const messageText = testMessages[getRandomInt(0, testMessages.length)]; 25 | newMessages.push({ 26 | id: generateUniqueKey(), 27 | text: messageText, 28 | isMyMessage: Boolean(getRandomInt(0, 2)), // Randomly assign true or false. 29 | }); 30 | } 31 | 32 | // Lets resolve after 500 ms, to simulate network latency. 33 | setTimeout(() => { 34 | resolve(newMessages); 35 | }, 500); 36 | }); 37 | }; 38 | 39 | // List of test messages to generate chat data. 40 | export const testMessages = [ 41 | 'Hey, where were you yesterday? I was trying to call you', 42 | 'Yeah dude!! Had a really bad night. I was really hungover', 43 | 'lol, thats so typical you. Who did you go out with?', 44 | 'Dont even ask me about it, I am never going drink with Uthred again. That dude is a beast', 45 | 'hahahaha, I can totally imagine!!', 46 | 'Ciao :)', 47 | ]; 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-bidirectional-infinite-scroll", 3 | "version": "0.3.3", 4 | "description": "Birectional infinite scroll for react-native", 5 | "main": "lib/commonjs/index", 6 | "module": "lib/module/index", 7 | "types": "lib/typescript/index.d.ts", 8 | "react-native": "src/index", 9 | "source": "src/index", 10 | "files": [ 11 | "src", 12 | "lib", 13 | "android", 14 | "ios", 15 | "cpp", 16 | "react-native-bidirectional-infinite-scroll.podspec", 17 | "!lib/typescript/example", 18 | "!android/build", 19 | "!ios/build", 20 | "!**/__tests__", 21 | "!**/__fixtures__", 22 | "!**/__mocks__" 23 | ], 24 | "scripts": { 25 | "test": "jest", 26 | "typescript": "tsc --noEmit", 27 | "lint": "eslint \"**/*.{js,ts,tsx}\"", 28 | "prepare": "bob build", 29 | "release": "release-it", 30 | "example": "yarn --cwd example", 31 | "pods": "cd example && pod-install --quiet", 32 | "bootstrap": "yarn example && yarn && yarn pods" 33 | }, 34 | "keywords": [ 35 | "react-native", 36 | "ios", 37 | "android" 38 | ], 39 | "repository": "https://github.com/GetStream/react-native-bidirectional-infinite-scroll", 40 | "author": "vishtree (https://github.com/vishalnarkhede)", 41 | "license": "MIT", 42 | "bugs": { 43 | "url": "https://github.com/GetStream/react-native-bidirectional-infinite-scroll/issues" 44 | }, 45 | "homepage": "https://github.com/GetStream/react-native-bidirectional-infinite-scroll#readme", 46 | "publishConfig": { 47 | "registry": "https://registry.npmjs.org/" 48 | }, 49 | "devDependencies": { 50 | "@commitlint/config-conventional": "^11.0.0", 51 | "@react-native-community/eslint-config": "^2.0.0", 52 | "@release-it/conventional-changelog": "^2.0.0", 53 | "@stream-io/flat-list-mvcp": "^0.10.0", 54 | "@types/jest": "^26.0.0", 55 | "@types/react": "^16.9.19", 56 | "@types/react-native": "0.63.50", 57 | "commitlint": "^11.0.0", 58 | "eslint": "^7.2.0", 59 | "eslint-config-prettier": "^7.0.0", 60 | "eslint-plugin-prettier": "^3.1.3", 61 | "husky": "^4.2.5", 62 | "jest": "^26.0.1", 63 | "pod-install": "^0.1.0", 64 | "prettier": "^2.0.5", 65 | "react": "16.13.1", 66 | "react-native": "0.63.4", 67 | "react-native-builder-bob": "^0.17.1", 68 | "release-it": "^14.2.2", 69 | "typescript": "^4.1.3" 70 | }, 71 | "peerDependencies": { 72 | "@stream-io/flat-list-mvcp": ">=0.10.0", 73 | "react": "*", 74 | "react-native": "*" 75 | }, 76 | "jest": { 77 | "preset": "react-native", 78 | "modulePathIgnorePatterns": [ 79 | "/example/node_modules", 80 | "/lib/" 81 | ] 82 | }, 83 | "husky": { 84 | "hooks": { 85 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS", 86 | "pre-commit": "yarn lint && yarn typescript" 87 | } 88 | }, 89 | "commitlint": { 90 | "extends": [ 91 | "@commitlint/config-conventional" 92 | ] 93 | }, 94 | "release-it": { 95 | "git": { 96 | "commitMessage": "chore: release ${version}", 97 | "tagName": "v${version}" 98 | }, 99 | "npm": { 100 | "publish": true 101 | }, 102 | "github": { 103 | "release": true 104 | }, 105 | "plugins": { 106 | "@release-it/conventional-changelog": { 107 | "preset": "angular" 108 | } 109 | } 110 | }, 111 | "eslintConfig": { 112 | "root": true, 113 | "extends": [ 114 | "@react-native-community", 115 | "prettier" 116 | ], 117 | "rules": { 118 | "prettier/prettier": [ 119 | "error", 120 | { 121 | "quoteProps": "consistent", 122 | "singleQuote": true, 123 | "tabWidth": 2, 124 | "trailingComma": "es5", 125 | "useTabs": false 126 | } 127 | ] 128 | } 129 | }, 130 | "eslintIgnore": [ 131 | "node_modules/", 132 | "lib/" 133 | ], 134 | "prettier": { 135 | "quoteProps": "consistent", 136 | "singleQuote": true, 137 | "tabWidth": 2, 138 | "trailingComma": "es5", 139 | "useTabs": false 140 | }, 141 | "react-native-builder-bob": { 142 | "source": "src", 143 | "output": "lib", 144 | "targets": [ 145 | "commonjs", 146 | "module", 147 | [ 148 | "typescript", 149 | { 150 | "project": "tsconfig.build.json" 151 | } 152 | ] 153 | ] 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const child_process = require('child_process'); 3 | 4 | const root = path.resolve(__dirname, '..'); 5 | const args = process.argv.slice(2); 6 | const options = { 7 | cwd: process.cwd(), 8 | env: process.env, 9 | stdio: 'inherit', 10 | encoding: 'utf-8', 11 | }; 12 | 13 | let result; 14 | 15 | if (process.cwd() !== root || args.length) { 16 | // We're not in the root of the project, or additional arguments were passed 17 | // In this case, forward the command to `yarn` 18 | result = child_process.spawnSync('yarn', args, options); 19 | } else { 20 | // If `yarn` is run without arguments, perform bootstrap 21 | result = child_process.spawnSync('yarn', ['bootstrap'], options); 22 | } 23 | 24 | process.exitCode = result.status; 25 | -------------------------------------------------------------------------------- /src/BidirectionalFlatList.tsx: -------------------------------------------------------------------------------- 1 | import React, { MutableRefObject, useRef, useState } from 'react'; 2 | import { 3 | ActivityIndicator, 4 | FlatList as FlatListType, 5 | FlatListProps, 6 | ScrollViewProps, 7 | StyleSheet, 8 | View, 9 | } from 'react-native'; 10 | import { FlatList } from '@stream-io/flat-list-mvcp'; 11 | 12 | const styles = StyleSheet.create({ 13 | indicatorContainer: { 14 | paddingVertical: 5, 15 | width: '100%', 16 | }, 17 | }); 18 | 19 | export type Props = Omit< 20 | FlatListProps, 21 | 'maintainVisibleContentPosition' 22 | > & { 23 | /** 24 | * Called once when the scroll position gets close to end of list. This must return a promise. 25 | * You can `onEndReachedThreshold` as distance from end of list, when this function should be called. 26 | */ 27 | onEndReached: () => Promise; 28 | /** 29 | * Called once when the scroll position gets close to begining of list. This must return a promise. 30 | * You can `onStartReachedThreshold` as distance from beginning of list, when this function should be called. 31 | */ 32 | onStartReached: () => Promise; 33 | /** Color for inline loading indicator */ 34 | activityIndicatorColor?: string; 35 | /** 36 | * Enable autoScrollToTop. 37 | * In chat type applications, you want to auto scroll to bottom, when new message comes it. 38 | */ 39 | enableAutoscrollToTop?: boolean; 40 | /** 41 | * If `enableAutoscrollToTop` is true, the scroll threshold below which auto scrolling should occur. 42 | */ 43 | autoscrollToTopThreshold?: number; 44 | /** Scroll distance from beginning of list, when onStartReached should be called. */ 45 | onStartReachedThreshold?: number; 46 | /** 47 | * Scroll distance from end of list, when onStartReached should be called. 48 | * Please note that this is different from onEndReachedThreshold of FlatList from react-native. 49 | */ 50 | onEndReachedThreshold?: number; 51 | /** If true, inline loading indicators will be shown. Default - true */ 52 | showDefaultLoadingIndicators?: boolean; 53 | /** Custom UI component for header inline loading indicator */ 54 | HeaderLoadingIndicator?: React.ComponentType; 55 | /** Custom UI component for footer inline loading indicator */ 56 | FooterLoadingIndicator?: React.ComponentType; 57 | /** Custom UI component for header indicator of FlatList. Only used when `showDefaultLoadingIndicators` is false */ 58 | ListHeaderComponent?: React.ComponentType; 59 | /** Custom UI component for footer indicator of FlatList. Only used when `showDefaultLoadingIndicators` is false */ 60 | ListFooterComponent?: React.ComponentType; 61 | }; 62 | /** 63 | * Note: 64 | * - `onEndReached` and `onStartReached` must return a promise. 65 | * - `onEndReached` and `onStartReached` only get called once, per content length. 66 | * - maintainVisibleContentPosition is fixed, and can't be modified through props. 67 | * - doesn't accept `ListFooterComponent` via prop, since it is occupied by `FooterLoadingIndicator`. 68 | * Set `showDefaultLoadingIndicators` to use `ListFooterComponent`. 69 | * - doesn't accept `ListHeaderComponent` via prop, since it is occupied by `HeaderLoadingIndicator` 70 | * Set `showDefaultLoadingIndicators` to use `ListHeaderComponent`. 71 | */ 72 | export const BidirectionalFlatList = (React.forwardRef( 73 | ( 74 | props: Props, 75 | ref: 76 | | ((instance: FlatListType | null) => void) 77 | | MutableRefObject | null> 78 | | null 79 | ) => { 80 | const { 81 | activityIndicatorColor = 'black', 82 | autoscrollToTopThreshold = 100, 83 | data, 84 | enableAutoscrollToTop, 85 | FooterLoadingIndicator, 86 | HeaderLoadingIndicator, 87 | ListHeaderComponent, 88 | ListFooterComponent, 89 | onEndReached = () => Promise.resolve(), 90 | onEndReachedThreshold = 10, 91 | onScroll, 92 | onStartReached = () => Promise.resolve(), 93 | onStartReachedThreshold = 10, 94 | showDefaultLoadingIndicators = true, 95 | } = props; 96 | const [onStartReachedInProgress, setOnStartReachedInProgress] = useState( 97 | false 98 | ); 99 | const [onEndReachedInProgress, setOnEndReachedInProgress] = useState(false); 100 | 101 | const onStartReachedTracker = useRef>({}); 102 | const onEndReachedTracker = useRef>({}); 103 | 104 | const onStartReachedInPromise = useRef | null>(null); 105 | const onEndReachedInPromise = useRef | null>(null); 106 | 107 | const maybeCallOnStartReached = () => { 108 | // If onStartReached has already been called for given data length, then ignore. 109 | if (data?.length && onStartReachedTracker.current[data.length]) { 110 | return; 111 | } 112 | 113 | if (data?.length) { 114 | onStartReachedTracker.current[data.length] = true; 115 | } 116 | 117 | setOnStartReachedInProgress(true); 118 | const p = () => { 119 | return new Promise((resolve) => { 120 | onStartReachedInPromise.current = null; 121 | setOnStartReachedInProgress(false); 122 | resolve(); 123 | }); 124 | }; 125 | 126 | if (onEndReachedInPromise.current) { 127 | onEndReachedInPromise.current.finally(() => { 128 | onStartReachedInPromise.current = onStartReached().then(p); 129 | }); 130 | } else { 131 | onStartReachedInPromise.current = onStartReached().then(p); 132 | } 133 | }; 134 | 135 | const maybeCallOnEndReached = () => { 136 | // If onEndReached has already been called for given data length, then ignore. 137 | if (data?.length && onEndReachedTracker.current[data.length]) { 138 | return; 139 | } 140 | 141 | if (data?.length) { 142 | onEndReachedTracker.current[data.length] = true; 143 | } 144 | 145 | setOnEndReachedInProgress(true); 146 | const p = () => { 147 | return new Promise((resolve) => { 148 | onStartReachedInPromise.current = null; 149 | setOnEndReachedInProgress(false); 150 | resolve(); 151 | }); 152 | }; 153 | 154 | if (onStartReachedInPromise.current) { 155 | onStartReachedInPromise.current.finally(() => { 156 | onEndReachedInPromise.current = onEndReached().then(p); 157 | }); 158 | } else { 159 | onEndReachedInPromise.current = onEndReached().then(p); 160 | } 161 | }; 162 | 163 | const handleScroll: ScrollViewProps['onScroll'] = (event) => { 164 | // Call the parent onScroll handler, if provided. 165 | onScroll?.(event); 166 | 167 | const offset = event.nativeEvent.contentOffset.y; 168 | const visibleLength = event.nativeEvent.layoutMeasurement.height; 169 | const contentLength = event.nativeEvent.contentSize.height; 170 | 171 | // Check if scroll has reached either start of end of list. 172 | const isScrollAtStart = offset < onStartReachedThreshold; 173 | const isScrollAtEnd = 174 | contentLength - visibleLength - offset < onEndReachedThreshold; 175 | 176 | if (isScrollAtStart) { 177 | maybeCallOnStartReached(); 178 | } 179 | 180 | if (isScrollAtEnd) { 181 | maybeCallOnEndReached(); 182 | } 183 | }; 184 | 185 | const renderHeaderLoadingIndicator = () => { 186 | if (!showDefaultLoadingIndicators) { 187 | if (ListHeaderComponent) { 188 | return ; 189 | } else { 190 | return null; 191 | } 192 | } 193 | 194 | if (!onStartReachedInProgress) return null; 195 | 196 | if (HeaderLoadingIndicator) { 197 | return ; 198 | } 199 | 200 | return ( 201 | 202 | 203 | 204 | ); 205 | }; 206 | 207 | const renderFooterLoadingIndicator = () => { 208 | if (!showDefaultLoadingIndicators) { 209 | if (ListFooterComponent) { 210 | return ; 211 | } else { 212 | return null; 213 | } 214 | } 215 | 216 | if (!onEndReachedInProgress) return null; 217 | 218 | if (FooterLoadingIndicator) { 219 | return ; 220 | } 221 | 222 | return ( 223 | 224 | 225 | 226 | ); 227 | }; 228 | 229 | return ( 230 | <> 231 | 232 | {...props} 233 | ref={ref} 234 | progressViewOffset={50} 235 | ListHeaderComponent={renderHeaderLoadingIndicator} 236 | ListFooterComponent={renderFooterLoadingIndicator} 237 | onEndReached={null} 238 | onScroll={handleScroll} 239 | maintainVisibleContentPosition={{ 240 | autoscrollToTopThreshold: enableAutoscrollToTop 241 | ? autoscrollToTopThreshold 242 | : undefined, 243 | minIndexForVisible: 1, 244 | }} 245 | /> 246 | 247 | ); 248 | } 249 | ) as unknown) as BidirectionalFlatListType; 250 | 251 | type BidirectionalFlatListType = ( 252 | props: Props 253 | ) => React.ReactElement; 254 | -------------------------------------------------------------------------------- /src/__tests__/index.test.tsx: -------------------------------------------------------------------------------- 1 | it.todo('write a test'); 2 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export { BidirectionalFlatList as FlatList } from './BidirectionalFlatList'; 2 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": "./tsconfig", 4 | "exclude": ["example"] 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "react-native-bidirectional-infinite-scroll": ["./src/index"] 6 | }, 7 | "allowUnreachableCode": false, 8 | "allowUnusedLabels": false, 9 | "esModuleInterop": true, 10 | "importsNotUsedAsValues": "error", 11 | "forceConsistentCasingInFileNames": true, 12 | "jsx": "react", 13 | "lib": ["esnext"], 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "noFallthroughCasesInSwitch": true, 17 | "noImplicitReturns": true, 18 | "noImplicitUseStrict": false, 19 | "noStrictGenericChecks": false, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "resolveJsonModule": true, 23 | "skipLibCheck": true, 24 | "strict": true, 25 | "target": "esnext" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. 4 | 5 | ## Installation 6 | 7 | ```console 8 | yarn install 9 | ``` 10 | 11 | ## Local Development 12 | 13 | ```console 14 | yarn start 15 | ``` 16 | 17 | This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ## Build 20 | 21 | ```console 22 | yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ## Deployment 28 | 29 | ```console 30 | GIT_USER= USE_SSH=true yarn deploy 31 | ``` 32 | 33 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 34 | -------------------------------------------------------------------------------- /website/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /website/docs/example.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Example 3 | slug: /example 4 | sidebar_label: Example 5 | --- 6 | 7 | You can refer following resources for examples: 8 | 9 | - [https://dev.to/vishalnarkhede/react-native-how-to-build-bidirectional-infinite-scroll](https://dev.to/vishalnarkhede/react-native-how-to-build-bidirectional-infinite-scroll-32ph#%F0%9F%96%A5-tutorial-chat-ui-with-bidirectional-infinite-scroll) 10 | - [https://github.com/GetStream/react-native-bidirectional-infinite-scroll/tree/main/example](https://github.com/GetStream/react-native-bidirectional-infinite-scroll/tree/main/example) -------------------------------------------------------------------------------- /website/docs/getting-started.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Installation and Usage 3 | slug: /installation 4 | --- 5 | 6 | ## Setup 7 | 8 | #### NPM 9 | 10 | ```sh 11 | $ npm i react-native-bidirectional-infinite-scroll @stream-io/flat-list-mvcp 12 | ``` 13 | 14 | #### Yarn 15 | 16 | ```sh 17 | $ yarn add react-native-bidirectional-infinite-scroll @stream-io/flat-list-mvcp 18 | ``` 19 | 20 | ## Usage 21 | 22 | Please check the [example app](https://github.com/GetStream/react-native-bidirectional-infinite-scroll/tree/main/example) for working demo. 23 | 24 | ```js 25 | import { FlatList } from "react-native-bidirectional-infinite-scroll"; 26 | 27 | export const App = () => { 28 | // All your business logic here 29 | 30 | return ( 31 | item.toString()} 35 | onStartReached={onStartReached} // required, should return a promise 36 | onEndReached={onEndReached} // required, should return a promise 37 | showDefaultLoadingIndicators={true} // optional 38 | onStartReachedThreshold={10} // optional 39 | onEndReachedThreshold={10} // optional 40 | activityIndicatorColor={'black'} // optional 41 | HeaderLoadingIndicator={() => { /** Your loading indicator */ }} // optional 42 | FooterLoadingIndicator={() => { /** Your loading indicator */ }} // optional 43 | enableAutoscrollToTop={false} // optional | default - false 44 | // You can use any other prop on react-native's FlatList 45 | /> 46 | ) 47 | } 48 | ``` 49 | -------------------------------------------------------------------------------- /website/docs/how-it-works.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How it works 3 | slug: /how-it-works 4 | --- 5 | 6 | This section will walk you through the hurdles of implementing bidirectional infinite scroll and how its solved by this package. 7 | ​ 8 | ### Support for `onStartReached` 9 | [FlatList](https://reactnative.dev/docs/flatlist) from React Native has built-in support for infinite scroll in a single direction (from the end of the list). You can add a prop `onEndReached`on `FlatList`. This function gets called when your scroll is near the end of the list, and thus you can append more items to the list from this function. You can Google for **React Native infinite scrolling**, and you will find plenty of examples for this. Unfortunately, the `FlatList` doesn't provide any similar prop for `onStartReached` for infinite scrolling in other directions. 10 | ​ 11 | We have added support for this prop as part of this package by simply adding the `onScroll` handler on `FlatList`, and executing the callback function (`onStartReached`) when the scroll is near the start of the list. If you take a look at the implementation of [VirtualizedList](https://github.com/facebook/react-native/blob/master/Libraries/Lists/VirtualizedList.js), you will notice that `onEndReached`function gets called only once per content length. That's there for a good purpose - to avoid redundant function calls on every scroll position change. Similar optimizations have been done for `onStartReached` within this package. 12 | ​ 13 | ### Race condition between `onStartReached` and `onEndReached` 14 | 15 | To maintain a smooth scrolling experience, we need to manage the execution order of `onStartReached` and `onEndReached`. Because if both the callbacks happen at (almost) the same time, which means items will be added to the list from both directions. This may result in scroll jump, and that's not a good user experience. Thus it's essential to make sure one callback waits for the other callback to finish. 16 | ​ 17 | ### `onStartReachedThreshold` and `onEndReachedThreshold` 18 | 19 | `FlatList` from React Native has a support for the prop `onEndReachedThreshold`, which is [documented here](https://reactnative.dev/docs/flatlist#onendreachedthreshold) 20 | ​ 21 | > How far from the end (in units of visible length of the list) the bottom edge of the list must be from the end of the content to trigger the `onEndReached` callback. 22 | 23 | 24 | Instead, it's easier to have a fixed value offset (distance from the end of the list) to trigger one of these callbacks. Thus we can maintain these two values within our implementation. So `onStartReachedThreshold` and `onEndReachedThreshold` props accept the number - distance from the end of the list to trigger one of these callbacks. 25 | ​ 26 | ### Smooth scrolling experience 27 | `FlatList` from React Native accepts a prop - [maintainVisibleContentPosition](https://reactnative.dev/docs/scrollview#maintainvisiblecontentposition), which makes sure your scroll doesn't jump to the end of the list when more items are added to the list. But this prop is only supported on iOS for now. So taking some inspiration from this [PR](https://github.com/facebook/react-native/pull/29466), we published our separate package to add support for this prop on Android - [flat-list-mvcp](https://github.com/GetStream/flat-list-mvcp#maintainvisiblecontentposition-prop-support-for-android-react-native). And thus `@stream-io/flat-list-mvcp` is a dependency of the `react-native-bidirectional-scroll` package. 28 | ​ -------------------------------------------------------------------------------- /website/docs/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Introduction 3 | slug: / 4 | --- 5 | 6 | [FlatList](https://reactnative.dev/docs/flatlist) by react-native only allows infinite scroll in one direction (using `onEndReached`). This package adds capability on top of FlatList to allow infinite scroll from both directions, and also maintains **smooth scroll** UX. 7 | 8 | - Accepts prop `onStartReached` & `onEndReached`, which you can use to load more results. 9 | - Calls to onEndReached and onStartReached have been optimized. 10 | - Inline loading Indicators, which can be customized as well. 11 | - Uses [flat-list-mvcp](https://github.com/GetStream/flat-list-mvcp#maintainvisiblecontentposition-prop-support-for-android-react-native) to maintain scroll position or smooth scroll UX. 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 27 | 28 |
22 | iOS 23 | 25 | Android 26 |
-------------------------------------------------------------------------------- /website/docs/props.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Props 3 | slug: /props 4 | --- 5 | 6 | This package is a wrapper around react-native's FlatList. So it accepts all the props from `FlatList`, except for [`maintainVisibleContentPosition`](https://reactnative.dev/docs/0.63/scrollview#maintainvisiblecontentposition). It has support for following additional props, to fine tune your infinite scroll. 7 | 8 | 9 | ### `onEndReached` 10 | 11 | Called once when the scroll position gets close to end of list. This must return a promise. 12 | You can `onEndReachedThreshold` as distance from end of list, when this function should be called. 13 | 14 | 15 | | type | default | required | 16 | | -------- | ------- | -------- | 17 | | function | null | YES | 18 | 19 | 20 | ### `onStartReached` 21 | 22 | Called once when the scroll position gets close to begining of list. This must return a promise. 23 | You can `onStartReachedThreshold` as distance from beginning of list, when this function should be called. 24 | 25 | | type | default | required | 26 | | -------- | ------- | -------- | 27 | | function | null | YES | 28 | 29 | ### `activityIndicatorColor` 30 | 31 | Color for inline loading indicator 32 | 33 | | type | default | required | 34 | | ------ | ------- | -------- | 35 | | string | #000000 | NO | 36 | 37 | ### `enableAutoscrollToTop` 38 | 39 | Enable autoScrollToTop. 40 | In chat type applications, you want to auto scroll to bottom, when new message comes it. 41 | 42 | | type | default | required | 43 | | ------ | ------- | -------- | 44 | | string | false | NO | 45 | 46 | ### `autoscrollToTopThreshold` 47 | 48 | The scroll offset threshold, below which auto scrolling should occur. 49 | 50 | :::info 51 | 52 | This prop only works, when `enableAutoscrollToTop` is set to true. 53 | 54 | ::: 55 | 56 | | type | default | required | 57 | | -------- | ------- | -------- | 58 | | number | 100 | NO | 59 | 60 | 61 | ### `onStartReachedThreshold` 62 | 63 | Scroll offset from beginning of list, when onStartReached should be called. 64 | 65 | | type | default | required | 66 | | -------- | ------- | -------- | 67 | | number | 10 | NO | 68 | 69 | ### `onEndReachedThreshold` 70 | 71 | Scroll distance from end of list, when onStartReached should be called. 72 | Please note that this is different from onEndReachedThreshold of FlatList from react-native. 73 | 74 | | type | default | required | 75 | | -------- | ------- | -------- | 76 | | number | 10 | NO | 77 | 78 | ### `showDefaultLoadingIndicators` 79 | 80 | If true, inline loading indicators will be shown 81 | 82 | | type | default | required | 83 | | -------- | ------- | -------- | 84 | | boolean | true | NO | 85 | 86 | ### `HeaderLoadingIndicator` 87 | 88 | Custom UI component for header inline loading indicator 89 | 90 | | type | default | required | 91 | | -------- | ------- | -------- | 92 | | Component | [ActivityIndicator](https://reactnative.dev/docs/0.63/activityindicator) | NO | 93 | 94 | 95 | ### `FooterLoadingIndicator` 96 | 97 | Custom UI component for footer inline loading indicator 98 | 99 | | type | default | required | 100 | | -------- | ------- | -------- | 101 | | Component | [ActivityIndicator](https://reactnative.dev/docs/0.63/activityindicator) | NO | 102 | 103 | 104 | ### `ListHeaderComponent` 105 | 106 | Custom UI component for header indicator of FlatList, which overrides the HeaderLoadingIndicator. Only used when `showDefaultLoadingIndicators` is false 107 | 108 | | type | default | required | 109 | | -------- | ------- | -------- | 110 | | Component | null | NO | 111 | 112 | 113 | ### `ListFooterComponent` 114 | 115 | Custom UI component for footer indicator of FlatList, which overrides the FooterLoadingIndicator. Only used when `showDefaultLoadingIndicators` is false 116 | 117 | | type | default | required | 118 | | -------- | ------- | -------- | 119 | | Component | null | NO | 120 | 121 | 122 | -------------------------------------------------------------------------------- /website/docs/troubleshooting.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Troubleshooting 3 | --- 4 | 5 | ### Exception in native call from JS 6 | 7 | Please upgrade to `@stream-io/flat-list-mvcp@0.10.0` 8 | 9 | ### Scroll is jumping, when new items are loaded in list 10 | 11 | Please try adjusting (increasing) the [windowSize](https://reactnative.dev/docs/0.63/virtualizedlist#windowsize) on FlatList. 12 | -------------------------------------------------------------------------------- /website/docusaurus.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@docusaurus/types').DocusaurusConfig} */ 2 | module.exports = { 3 | title: 'React Native Bidirectional Infinite Scroll', 4 | tagline: 'Bidirectional infinite scroll using react-native and FlatList', 5 | url: 'https://getstream.github.io', 6 | baseUrl: '/react-native-bidirectional-infinite-scroll/', 7 | onBrokenLinks: 'throw', 8 | onBrokenMarkdownLinks: 'warn', 9 | favicon: 'https://getstream.imgix.net/images/favicons/favicon-96x96.png', 10 | organizationName: 'getstream', // Usually your GitHub org/user name. 11 | projectName: 'react-native-bidirectional-infinite-scroll', // Usually your repo name. 12 | themeConfig: { 13 | navbar: { 14 | title: 'Bidirectional Infinite Scroll', 15 | items: [ 16 | { 17 | href: 18 | 'https://github.com/GetStream/react-native-bidirectional-infinite-scroll', 19 | label: 'GitHub', 20 | position: 'right', 21 | }, 22 | ], 23 | }, 24 | footer: { 25 | style: 'light', 26 | copyright: `Created by Vishal Narkhede | Built with ❤️ @Stream`, 27 | }, 28 | }, 29 | presets: [ 30 | [ 31 | '@docusaurus/preset-classic', 32 | { 33 | docs: { 34 | sidebarPath: require.resolve('./sidebars.js'), 35 | routeBasePath: '/', 36 | // Please change this to your repo. 37 | editUrl: 38 | 'https://github.com/facebook/docusaurus/edit/master/website/', 39 | }, 40 | theme: { 41 | customCss: require.resolve('./src/css/custom.css'), 42 | }, 43 | }, 44 | ], 45 | ], 46 | }; 47 | -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids" 15 | }, 16 | "dependencies": { 17 | "@docusaurus/core": "2.0.0-alpha.72", 18 | "@docusaurus/preset-classic": "2.0.0-alpha.72", 19 | "@mdx-js/react": "^1.6.21", 20 | "clsx": "^1.1.1", 21 | "react": "^17.0.1", 22 | "react-dom": "^17.0.1" 23 | }, 24 | "browserslist": { 25 | "production": [ 26 | ">0.5%", 27 | "not dead", 28 | "not op_mini all" 29 | ], 30 | "development": [ 31 | "last 1 chrome version", 32 | "last 1 firefox version", 33 | "last 1 safari version" 34 | ] 35 | }, 36 | "devDependencies": { 37 | "@wino/docusaurus-gist-embed": "^1.0.2" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /website/sidebars.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | docs: [ 3 | { 4 | type: 'category', 5 | label: 'Table of content', 6 | items: [ 7 | 'introduction', 8 | 'getting-started', 9 | 'how-it-works', 10 | 'example', 11 | 'props', 12 | 'troubleshooting', 13 | ], 14 | }, 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /website/src/css/custom.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --ifm-code-font-size: 95%; 3 | } 4 | 5 | :root[data-theme='dark'] { 6 | --ifm-background-color: #000000; 7 | --ifm-color-primary: #ffc400; 8 | --ifm-color-primary-dark: #e6b800; 9 | --ifm-color-primary-darker: #d9ad00; 10 | --ifm-color-primary-darkest: #b38f00; 11 | --ifm-color-primary-light: #ffd11a; 12 | --ifm-color-primary-lighter: #ffd426; 13 | --ifm-color-primary-lightest: #ffdb4d; 14 | 15 | --ifm-toggle-icon-color: #ffffff; 16 | --ifm-table-border-color: #282c34; 17 | --ifm-table-head-background: #242526; 18 | --ifm-table-stripe-background: #101113; 19 | 20 | --ifm-navbar-background-color: #101113; 21 | --ifm-toc-border-color: #101113; 22 | } 23 | 24 | :root[data-theme='light'] { 25 | --ifm-background-color: #ffffff; 26 | --ifm-color-primary: #0010f5; 27 | --ifm-color-primary-dark: #7a00e6; 28 | --ifm-color-primary-darker: #7400d9; 29 | --ifm-color-primary-darkest: #5f00b3; 30 | --ifm-color-primary-light: #941aff; 31 | --ifm-color-primary-lighter: #9a26ff; 32 | --ifm-color-primary-lightest: #ac4dff; 33 | 34 | --ifm-toggle-icon-color: #000000; 35 | --ifm-table-border-color: #dadde1; 36 | --ifm-table-head-background: #ececec; 37 | --ifm-table-stripe-background: #f5f6f7; 38 | } 39 | 40 | .docusaurus-highlight-code-line { 41 | background-color: rgb(72, 77, 91); 42 | display: block; 43 | margin: 0 calc(-1 * var(--ifm-pre-padding)); 44 | padding: 0 var(--ifm-pre-padding); 45 | } 46 | 47 | article table { 48 | display: table; 49 | width: 100%; 50 | font-size: 14px; 51 | } 52 | article table thead th { 53 | text-align: left; 54 | text-transform: uppercase; 55 | } 56 | 57 | article table th, 58 | article table td { 59 | padding: 6px 10px; 60 | } 61 | 62 | article table tr:nth-child(2n) { 63 | background-color: var(--ifm-table-stripe-background); 64 | } 65 | 66 | .row .col.col--3 { 67 | padding: 0 var(--ifm-spacing-horizontal) 0, 0; 68 | } 69 | 70 | .table-of-contents ul { 71 | padding-left: 0px; 72 | } 73 | 74 | .table-of-contents ul li { 75 | margin-left: 0px; 76 | } -------------------------------------------------------------------------------- /website/static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/website/static/.nojekyll -------------------------------------------------------------------------------- /website/static/img/docusaurus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/website/static/img/docusaurus.png -------------------------------------------------------------------------------- /website/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/react-native-bidirectional-infinite-scroll/bab65ef05ec47601a7e80218d3dafcccea746bcb/website/static/img/favicon.ico -------------------------------------------------------------------------------- /website/static/img/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/static/img/undraw_docusaurus_mountain.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /website/static/img/undraw_docusaurus_react.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /website/static/img/undraw_docusaurus_tree.svg: -------------------------------------------------------------------------------- 1 | docu_tree --------------------------------------------------------------------------------