Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nicer Tabs] Fork TabBar, simplify Pager #6762

Merged
merged 6 commits into from
Dec 3, 2024
Merged

[Nicer Tabs] Fork TabBar, simplify Pager #6762

merged 6 commits into from
Dec 3, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Nov 26, 2024

The goal is to resurrect #1696. I've learned a bunch of things since I made that version, and I'm pretty sure I can get the indicator to work fast on Android now. Scrolling on demand may still be tricky but we'll see. Could be iOS-only.

In this PR, I'm just starting to clean things up a bit:

  • TabBar is going to diverge even more between web and native, so I'll just fork it now.
  • Remove Pager's onPageSelecting event. It's kind of ill-defined (what does "selecting" mean exactly?), and the implementation encourages putting heavy work just as the deceleration is starting. This is not great for performance, especially if we start adding more visual flourishes to it. I believe the goal was to optimistically start some work earlier (maybe fetching the selected feed?) — but if that's the goal, we should just add some kind of query prewarming later. In either case, it gets in the way of refactoring, so let's kill it for now and revisit this decision at the end of the stack.

Test Plan

Everything still works.

We're not sending the reason in the analytics event but that seems fine. Maybe I'll hook it up later, for now I want to simplify the code.

The "header catch up" animation after swipe now runs a bit later. We'll solve that in the subsequent PRs.

Copy link

github-actions bot commented Nov 27, 2024

Old size New size Diff
8.14 MB 8.14 MB 0 B (0.00%)

Copy link
Member

@mozzius mozzius left a comment

Choose a reason for hiding this comment

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

nice simplification, works cross-platform

It's difficult to tell what exactly it's supposed to represent, and in practice it's not really used aside from logging. Let's rip it out for now to keep other changes simpler.
It was added to try to do some work eagerly when we're sure which way the scroll is snapping. This is not necessarily a good idea though. It schedules a potentially expensive re-render right during the deceleration animation, which is not great. Whatever we're optimizing there, we should optimize smarter (e.g. prewarm just the network call). The other thing it used to help with is triggering the pager header autoscroll earlier. But we're going to rewrite that part differently anyway so that's not relevant either.
We'll have to revisit this when adding tablet support but for now I'd prefer to remove a codepath that is not being tested or ever run.
The Draggable thing was needed for web-only behavior so we can drop it in the native fork.
@arcalinea arcalinea temporarily deployed to nicer-tabs-1 - social-app PR #6762 November 30, 2024 18:03 — with Render Destroyed
@gaearon gaearon merged commit 5a313c2 into main Dec 3, 2024
6 checks passed
@gaearon gaearon deleted the nicer-tabs-1 branch December 3, 2024 01:13
Signez pushed a commit to Signez/bsky-social-app that referenced this pull request Dec 26, 2024
* Fork TabBar.web.tsx

* Trim dead code from both forks

* Remove onPageSelecting event

It's difficult to tell what exactly it's supposed to represent, and in practice it's not really used aside from logging. Let's rip it out for now to keep other changes simpler.

* Remove early onPageSelected call

It was added to try to do some work eagerly when we're sure which way the scroll is snapping. This is not necessarily a good idea though. It schedules a potentially expensive re-render right during the deceleration animation, which is not great. Whatever we're optimizing there, we should optimize smarter (e.g. prewarm just the network call). The other thing it used to help with is triggering the pager header autoscroll earlier. But we're going to rewrite that part differently anyway so that's not relevant either.

* Prune more dead code from the native version

We'll have to revisit this when adding tablet support but for now I'd prefer to remove a codepath that is not being tested or ever run.

* Use regular ScrollView on native

The Draggable thing was needed for web-only behavior so we can drop it in the native fork.
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.

3 participants