Page MenuHomePhabricator

[native] Migrate ChatInputBar component to Reanimated v2 API
ClosedPublic

Authored by angelika on Nov 22 2024, 4:47 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 24, 6:07 PM
Unknown Object (File)
Tue, Dec 24, 1:24 PM
Unknown Object (File)
Wed, Dec 18, 11:03 AM
Unknown Object (File)
Mon, Dec 16, 11:45 AM
Unknown Object (File)
Mon, Dec 16, 8:54 AM
Unknown Object (File)
Mon, Dec 16, 2:05 AM
Unknown Object (File)
Mon, Dec 16, 2:04 AM
Unknown Object (File)
Mon, Dec 16, 2:04 AM
Subscribers

Details

Summary
Test Plan

Tested this diff stack by playing around with ChatInputBar on both iOS simulator and Android device:

  • focus the text input and verify the keyboard is up and the camera buttons are animated correctly
  • try to send the message, verify the send button is animated correctly
  • verify the text input can be unfocused and keyboard is hidden
  • verify the draft works: write text, navigate from the chat, navigate into the chat again, verify the text is kept and the $
  • verify the edit mode works by editing a message
  • try to close the chat while editing a message - the alert should be shown
  • try to join a thread
  • try to select typed text

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ashoat requested changes to this revision.Nov 25 2024, 9:02 AM

I haven't had a chance to review this yet, but I discussed it with @angelika in our 1:1 just now. In our discussion we realized that this diff changes some animation behavior, so I'm passing back to @angelika to document what changes she's made.

This revision now requires changes to proceed.Nov 25 2024, 9:02 AM
ashoat requested changes to this revision.Nov 26 2024, 5:34 AM

Removing from my queue

(In the future, you can hit "Plan Changes" after a rebase update to keep a diff with requested changes on your queue instead of sending it back to your reviewers' queue)

This revision now requires changes to proceed.Nov 26 2024, 5:34 AM
angelika added inline comments.
native/chat/chat-input-bar.react.js
419–442 ↗(On Diff #46078)

Before we were starting the animation by setting targetExpandoButtonsOpen. Here if targetExpandoButtonsOpen changes, we stop the animation and if there is something to animate (expandoButtonsOpen != targetExpandoButtonsOpen) in runTiming reset the value to expandoButtonsOpen and start the animation. If targetExpandoButtonsOpen doesn't change, then continue the animation.

After the refactor, we trigger the animation by setting expandoButtonsOpen to the target value with withTiming. The only difference in behaviour is when we call withTiming with the same target value before previous animation ends but it's hardly possible and noticeable in this case because user would have to expand buttons before state is updated and even then the animation barely started.

The same applies to sendButtonContainerWidth. The rest of the changes are straightforward: interpolating the values works exactly the same and instead of memoizing styles with nodes we use useAnimatedStyle.

Great work on this! The conversion from Reanimated 1 to Reanimated 2/3 appears perfect, and the changes between them are pretty unavoidable without introducing a bunch of unnecessary complexity

native/chat/chat-input-bar.react.js
419–442 ↗(On Diff #46078)

The only difference in behaviour is when we call withTiming with the same target value before previous animation ends

I think there is also a difference when calling withTiming with a different target value before the previous animation ends.

Basically the difference appears to be that any animation will take 150ms from where it starts, rather than the animation takes 150ms from 0 to 1.

In the old system, if the animation is halfway through and flips, it will take 75ms to finish. And it would take the same 75ms if the animation is "restarted" (target value set to the same value it already has... which is basically a no-op).

In contrast, in the new system, in both cases it would take 150ms, and as a result the animation would be twice as slow.

This revision is now accepted and ready to land.Wed, Nov 27, 3:54 PM