-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Refactor right buttons #6090
Merged
Merged
Refactor right buttons #6090
Conversation
This file contains 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
yogevbd
previously approved these changes
Mar 31, 2020
When calling Navigation.mergeOptions to add/remove buttons to a screen, existing buttons flicker since we clear all buttons and set them again.
* Buttons which should not be removed - won't be removed from the menu * Add new buttons to correct position with orderInCategory
mergeRightButtons mergeLeftButtons mergeBackButton
Keep components if they are already in correct position
guyca
force-pushed
the
mergeButtonsFlicker
branch
from
March 31, 2020 12:48
4a4c847
to
99105d8
Compare
guyca
force-pushed
the
mergeButtonsFlicker
branch
from
March 31, 2020 15:58
5e75988
to
ce59149
Compare
stachu2k
pushed a commit
to stachu2k/react-native-navigation
that referenced
this pull request
Apr 8, 2020
Refactor right buttons This pr started with an attempt to eliminate button flickering entirely when updating buttons which contain react components via mergeOptions. While the attempt wasn't 100% successful, I dit get some insights in the process. * It's not possible to add buttons at specific indices. Buttons contain an order property which determines the order of the button in the TopBar. To somewhat overcome this limitation, we can let users control button order via options. * When a right most component button is replaced with another component button, the rest of the buttons shift to the right since the newly added component isn't measured when it's added to the menu and its width is zero. We usually handle this situation with the `waitForRender` option but since buttons are measured with `MeasureSpec.UNSPECIFIED`, their dimensions are zero. Because of this, I've added options to set button dimensions. * When updating buttons via mergeOptions, if a component button is already added to the menu with the same order we will not remove and added it again. This mitigates flickering in some situations. * Textual button style properties were applied by traversing the view hierarchy and searching for the TextView corresponding to the button and updating its styles directly. There was an inherent bug in this logic where if two buttons contained the same text, styles could have been applied to the wrong TextView. We now apply styles directly on the button using spans.
stachu2k
pushed a commit
to stachu2k/react-native-navigation
that referenced
this pull request
Apr 8, 2020
This reverts commit c389411.
stachu2k
pushed a commit
to stachu2k/react-native-navigation
that referenced
this pull request
Apr 8, 2020
This reverts commit c389411.
guyca
added a commit
that referenced
this pull request
May 17, 2020
Updating button options with mergeOptions stopped working in 6.5.0. The regression was introduced by #6090. When updating buttons, RNN didn't take button options into account when checking if two buttons are equal, instead it checked only by button id. closes #6205 Co-authored-by: Yogev Ben David <[email protected]>
guyca
added a commit
that referenced
this pull request
May 18, 2020
Updating button options with mergeOptions stopped working in 6.5.0. The regression was introduced by #6090. When updating buttons, RNN didn't take button options into account when checking if two buttons are equal, instead it checked only by button id. closes #6205 Co-authored-by: Yogev Ben David <[email protected]>
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.
This pr started with an attempt to eliminate button flickering entirely when updating buttons which contain react components via mergeOptions. While the attempt wasn't 100% successful, I dit get some insights in the process.
It's not possible to add buttons at specific indices. Buttons contain an order property which determines the order of the button in the TopBar. To somewhat overcome this limitation, we can let users control button order via options.
When a right most component button is replaced with another component button, the rest of the buttons shift to the right since the newly added component isn't measured when it's added to the menu and its width is zero.
We usually handle this situation with the
waitForRender
option but since buttons are measured withMeasureSpec.UNSPECIFIED
, their dimensions are zero. Because of this, I've added options to set button dimensions.When updating buttons via mergeOptions, if a component button is already added to the menu with the same order we will not remove and added it again. This mitigates flickering in some situations.
Textual button style properties were applied by traversing the view hierarchy and searching for the TextView corresponding to the button and updating its styles directly.
There was an inherent bug in this logic where if two buttons contained the same text, styles could have been applied to the wrong TextView. We now apply styles directly on the button using spans.