MCPcopy Index your code
hub / github.com/GetStream/flat-list-mvcp

github.com/GetStream/flat-list-mvcp @v0.10.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.10.3 ↗ · + Follow
52 symbols 105 edges 23 files 2 documented · 4% updated 4d agov0.10.3 · 2023-05-17★ 13815 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

maintainVisibleContentPosition prop support for Android react-native.

License Npm Package Compatibility

[ Built with ♥ at Stream ]

In react-native, ScrollView (and FlatList) component have support for a prop maintainVisibleContentPosition, which is really useful for chat-like applications where you want to see new messages scroll into place. Also you might need it in other applications where you need bi-directional infinite scroll. Although currently its only supported on iOS. So here we have built a simple wrapper for FlatList and ScrollView to add support for this prop for android. On iOS, we simply return FlatList and ScrollView from react-native package.

We built this wrapper for our in-house react-native chat sdk, but we are making it public, in case it helps other devs from react-native community.

Before you proceed, please don't forget to also check other relevant packages, built at Stream:

⚠️ Horizontal list is currently not supported on this package.

Example

#  clone the repo
git clone https://github.com/GetStream/flat-list-mvcp.git
cd flat-list-mvcp/Example

# Install npm and pod dependencies
yarn; npx pod-install;

# run the app
npx react-native run-android

Installation

yarn add @stream-io/flat-list-mvcp

Usage

import { FlatList, ScrollView } from '@stream-io/flat-list-mvcp';

<FlatList
    maintainVisibleContentPosition={{
        autoscrollToTopThreshold: 10,
        minIndexForVisible: 1,
    }}
    ...
/>

<ScrollView
    maintainVisibleContentPosition={{
        autoscrollToTopThreshold: 10,
        minIndexForVisible: 1,
    }}
    ...
/>

Expo support

This package doesn't support Expo managed workflow. There is a feature request open for expo - https://expo.canny.io/feature-requests/p/android-maintainvisiblecontentposition-on-flatlist (please upvote)

Credits

Thanks to stackia for https://github.com/facebook/react-native/pull/29466#issuecomment-664367382

Contributing

PRs for improvement are welcome :)

License

MIT

Core symbols most depended-on inside this repo

enableMaintainVisibleContentPosition
called by 3
android/src/main/java/com/mvcpscrollviewmanager/MvcpScrollViewManagerModule.java
disableMaintainVisibleContentPosition
called by 3
android/src/main/java/com/mvcpscrollviewmanager/MvcpScrollViewManagerModule.java
generateUniqueKey
called by 3
Example/src/FlatListExample.tsx
getRnHandle
called by 1
android/src/main/java/com/mvcpscrollviewmanager/ScrollViewUIHolder.java
setRnHandle
called by 1
android/src/main/java/com/mvcpscrollviewmanager/ScrollViewUIHolder.java
getPrevFirstVisibleTop
called by 1
android/src/main/java/com/mvcpscrollviewmanager/ScrollViewUIHolder.java
setPrevFirstVisibleTop
called by 1
android/src/main/java/com/mvcpscrollviewmanager/ScrollViewUIHolder.java
getFirstVisibleView
called by 1
android/src/main/java/com/mvcpscrollviewmanager/ScrollViewUIHolder.java

Shape

Method 32
Function 14
Class 6

Languages

Java73%
TypeScript27%

Modules by API surface

android/src/main/java/com/mvcpscrollviewmanager/MvcpScrollViewManagerModule.java12 symbols
android/src/main/java/com/mvcpscrollviewmanager/ScrollViewUIHolder.java9 symbols
Example/android/app/src/main/java/com/example/MainApplication.java7 symbols
Example/src/FlatListExample.tsx6 symbols
Example/src/ScrollViewExample.tsx5 symbols
Example/android/app/src/debug/java/com/example/ReactNativeFlipper.java5 symbols
android/src/main/java/com/mvcpscrollviewmanager/MvcpScrollViewManagerPackage.java3 symbols
src/useMvcpTuner.ts2 symbols
Example/android/app/src/main/java/com/example/MainActivity.java2 symbols
Example/App.tsx1 symbols

For agents

$ claude mcp add flat-list-mvcp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact