-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[Android] Allows to set individual (left,top,right,bottom) dotted/dashed borders #29099
Closed
+45
−11
Closed
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is generally recommended against creating new instances in functions called in
onDraw
. You may want to consider creating thePath
wheremPaint
is created and reset it before using it here.This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benoitdion I will try to implement your suggestions and improve this solution. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @benoitdion
I just noticed that the changes required in your message are included in commit cbc9f45
The Path
mPathForSingleBorder
is created wheremPaint
is createdreact-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java
Line 92 in cbc9f45
react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java
Line 106 in cbc9f45
mPathForSingleBorder
is resetted before drawing the borderreact-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java
Line 1114 in cbc9f45
moveTo
andlineTo
withdrawLine
, but thedotted
style is not appliedI decided to not commit those changes as they do not make the code more readable, more clear and easier to search. Moving the logic to a separate function requires other developers to read/memorize an additional function.
The only reason to have a
drawSide
function below would be:drawSide(width, start, end, spy)
and set an expectation on thespy
canvas parameter.I would expect that
spy
received method:drawPath
with parametersmPathForSingleBorder
andmPaint
(test-spy). I would verifymPathForSingleBorder
and thatmPaint
is dotted.left
,top
,right
,bottom
). The below code repetition could be avoided with a fifth parameter indrawSide
. The fifth parameter would be alambda
, the lambda would useinvoke
to send a message (:left
,:top
,:right
,:bottom
) toborderWidth
andreturn
from thedrawSide
method if the result is 0. The same could be done to calculatestart
andend
Point.But I would not use reflection with this class as it would make the code less readable and harder to search.
I would prefer to write those changes in a separate Pull Request and give clear explanation of those changes.
I also believe that I should focus on fixing existing issues in react-native, for this reason I did not persist on the above changes.
This afternoon I will test further this functionality to detect any other potential issues
I remain available for further changes
Thanks a lot
Fabrizio Bertoglio