Page MenuHomePhabricator

[native] Migrate ChatInputBar component to Reanimated v2 API
ClosedPublic

Authored by angelika on Fri, Nov 22, 4:47 AM.
Tags
None
Referenced Files
F3395922: D14020.id46079.diff
Sun, Dec 1, 9:03 AM
F3394788: D14020.id46078.diff
Sat, Nov 30, 10:12 PM
F3394180: D14020.id46037.diff
Sat, Nov 30, 6:06 PM
Unknown Object (File)
Sat, Nov 30, 4:01 PM
Unknown Object (File)
Sat, Nov 30, 4:45 AM
Unknown Object (File)
Sat, Nov 30, 4:29 AM
Unknown Object (File)
Fri, Nov 29, 11:21 AM
Unknown Object (File)
Thu, Nov 28, 4:21 PM
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
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ashoat requested changes to this revision.Mon, Nov 25, 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.Mon, Nov 25, 9:02 AM
ashoat requested changes to this revision.Tue, Nov 26, 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.Tue, Nov 26, 5:34 AM
angelika added inline comments.
native/chat/chat-input-bar.react.js
419–442

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

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