feat(mobile): swipe between For You and Latest feed tabs#14473
Merged
Conversation
Wrap the home feed in a horizontal PagerView so users can swipe left/right to toggle between the For You and Latest feeds, in addition to tapping the existing tab headers. Uses react-native-pager-view (already a dependency — no new native module). Tab state and the pager stay in two-way sync: header taps update state immediately and an effect slides the pager to match; swipes commit the new tab via onPageSelected. The page-selected handler is guarded to skip when the pager already matches state, which swallows the initial onPageSelected PagerView emits on mount (Android) — avoiding a spurious FEED_CHANGE_VIEW analytics event and a clobber of the persisted tab — and a reconciliation effect realigns the pager once the persisted tab resolves from localStorage after mount. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds swipe left/right gesture paging to the mobile home feed, letting users swipe between the For You and Latest tabs in addition to tapping the existing tab headers (which remain fully functional).
PagerView(react-native-pager-view) — already a dependency and linked into iOS pods / Android autolink, so no new native module is added.enabled: isForYou/!isForYou) — only the active feed fetches; swiping enables the other feed on arrival, just like tapping did before.Two-way sync between tab state and pager
Tab state comes from
useFeedTab(persisted to localStorage).useEffectslides the pager to match.onPageSelectedcommits the new tab and fires the existingFEED_CHANGE_VIEWanalytics event.Correctness details handled
onPageSelectedskips when the pager already matches state. This swallows the initialonPageSelectedPagerView emits on mount (Android), which would otherwise fire a spuriousFEED_CHANGE_VIEWevent and could clobber the persisted tab, and it prevents double-counting a header tap.useFeedTabreturns theFOR_YOUdefault while localStorage resolves, so a user whose last tab was "Latest" would briefly land on the wrong page. An effect re-aligns the pager once the stored tab resolves.Testing
tsc --noEmit→ 0 errorseslinton the changed file → clean🤖 Generated with Claude Code