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

Fix animated icon glitches #4722

Merged
merged 1 commit into from
Jan 17, 2024
Merged

Fix animated icon glitches #4722

merged 1 commit into from
Jan 17, 2024

Conversation

swansontec
Copy link
Contributor

@swansontec swansontec commented Jan 17, 2024

Swapping the eye icon was leading to color glitches, due to some bug deep within react-native-reanimated.

The solution involves rendering a single Animated.Text component, and simply changing the text content inside. This avoids re-wiring the Reanimated dependency graph, which is what seems to be causing the problem.

We achieve this with almost the same icon API as before by adding an off property to the eye icon, to switch between the two variants. We also refactor the animated icon implementation to use a raw text element, instead of the react-native-vector-icon wrapper component.

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

Copy link
Contributor

@samholmes samholmes left a comment

Choose a reason for hiding this comment

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

Awesome!

Comment on lines +54 to +61
return (
<Animated.Text accessible={accessible} style={style}>
{String.fromCodePoint(glyphMap[name])}
</Animated.Text>
)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should document this approach with comments. Something to mention is the importance of using a single Animated.Text component for animated icons to avoid the buggy behavior in reanimated. Also, mention the limitation that switching between animated icons should be avoided completely in favor of parameterizing the icon name prop instead; this may limit our ability to switch between icons in different typesets.

Swapping the eye icon was leading to color glitches, due to some bug deep within react-native-reanimated.

The solution involves rendering a single `Animated.Text` component, and simply changing the text content inside. This avoids re-wiring the Reanimated dependency graph, which is what seems to be causing the problem.

We achieve this with *almost* the same icon API as before by adding an `off` property to the eye icon, to switch between the two variants. We also refactor the animated icon implementation to use a raw text element, instead of the react-native-vector-icon wrapper component.
@swansontec swansontec merged commit dabe8d6 into develop Jan 17, 2024
2 checks passed
@swansontec swansontec deleted the william/fix-pinkeye branch January 17, 2024 19:03
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