Skip to content

feat(android): jetpack compose support#1092

Open
troZee wants to merge 6 commits into
masterfrom
feat/jetpack-compose
Open

feat(android): jetpack compose support#1092
troZee wants to merge 6 commits into
masterfrom
feat/jetpack-compose

Conversation

@troZee

@troZee troZee commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR replaces the Android pager implementation with a Jetpack Compose-backed pager while preserving the existing
React Native manager API.

Changes

  • Add ComposePagerView, backed by Compose HorizontalPager and VerticalPager.
  • Wire Android manager methods to the new Compose pager implementation.
  • Add Compose Gradle plugin/configuration and Compose runtime/foundation/ui dependencies.
  • Preserve pager behavior for:
    • horizontal and vertical orientation
    • initial page
    • imperative page changes
    • scroll enabled/disabled
    • page margin
    • offscreen page limit
    • RTL layout direction
    • page selected, page scroll, and scroll state events

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Android implementation of RNCViewPager from a ViewPager2-backed view hierarchy to a Jetpack Compose-backed pager (HorizontalPager / VerticalPager) while keeping the existing React Native manager API surface.

Changes:

  • Replaces the Android native view implementation with a new ComposePagerView that hosts RN child views via AndroidView.
  • Rewires the RN ViewGroupManager and manager-impl helpers to operate on ComposePagerView instead of NestedScrollableHost/ViewPager2.
  • Adds Compose Gradle configuration and Compose dependencies to the Android module.

Reviewed changes

Copilot reviewed 5 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
android/src/main/java/com/reactnativepagerview/PagerViewViewManagerImpl.kt Redirects child management and prop setters to ComposePagerView methods.
android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt Switches the manager’s view type to ComposePagerView and forwards commands/props accordingly.
android/src/main/java/com/reactnativepagerview/ComposePagerView.kt New Compose-based pager implementation, including event dispatching and RN-child hosting.
android/gradle.properties Introduces a Compose version property for dependency management.
android/build.gradle Enables Compose + adds Kotlin Compose plugin and Compose dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread android/build.gradle
Comment on lines +236 to +239
implementation "androidx.compose.foundation:foundation:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-viewbinding:$compose_version"
Comment on lines +52 to 54
fun setOverScrollMode(host: ComposePagerView, value: String) {
return
}
Comment on lines +193 to +195
fun setOffscreenPageLimit(value: Int) {
offscreenPageLimitState.value = value.coerceAtLeast(0)
}
Comment on lines +313 to +318
.collect { inProgress ->
if (!inProgress) {
dispatchPageScroll(pagerState.settledPage, 0f)
dispatchScrollState("idle")
}
}
Comment thread package.json
{
"name": "react-native-pager-view",
"version": "8.0.2",
"version": "9.0.0-rc.0",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this before the release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants