Skip to content

Implement left and right sliding interface to switch pages#112

Open
RogerIn1900 wants to merge 1 commit into
ryanw-mobile:mainfrom
RogerIn1900:feature/add-swipe-switch
Open

Implement left and right sliding interface to switch pages#112
RogerIn1900 wants to merge 1 commit into
ryanw-mobile:mainfrom
RogerIn1900:feature/add-swipe-switch

Conversation

@RogerIn1900

Copy link
Copy Markdown

Functionality:

Added left-right swipe functionality to the navigation bar, adapting to two navigation styles:

  1. Side Navigation: Swipe the main content area to switch pages, and the navigation selection status will be updated simultaneously.
  2. Bottom Navigation: Swipe to switch between pages, just like tapping a navigation item.
  3. Swipe is disabled in PIP mode to avoid interaction conflicts.

Implementation method:

  • Use Jetpack Compose's HorizontalPager to manage page scrolling.
  • Monitor pager state changes and synchronously update the NavController navigation state.
  • When a navigation item is clicked, the pager animation switches to the corresponding page.

Test situation:

  • We've tested both tablet (side navigation) and phone (bottom navigation) scenarios, and swiping works correctly.
  • We've tested PIP mode, and swiping works correctly.

Effect:

Screen_recording_20251014_142721.webm

Comment thread app/build.gradle.kts
Comment on lines +101 to +102
implementation(libs.google.accompanist.pager)
implementation(libs.google.accompanist.pager.indicators)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@RogerIn1900 thank you for your contributions. It's a good idea to introduce pager to the UI. However, Accompainst was deprecated 2 years ago. Would you consider implementing it using the Pager in the main Compose library?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for your feedback and pointing out this issue! So sorry am I for using this outdated component,I agree that introducing a Pager is a good idea. However, since Accompanist was deprecated two years ago and is no longer actively maintained, I plan to use the official Pager from androidx.compose.foundation.pager instead. This will ensure better compatibility with future Compose versions and access to the latest features and bug fixes. I'll keep the functionality and UI consistent with the original design.

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