Skip to content

Commit

Permalink
fix - underlineColorAndroid not working on API 21
Browse files Browse the repository at this point in the history
on API 21 we change the logic as follows to fix underlineColorAndroid:
- we store the bottomBorderColor in a local variable
- we set the bottomBorderColor to the same color of
  underlineColorAndroid
- we set the underlineColorAndroid
- we re-set the bottomBorderColor to the previous color

As by Facebook design it defaults to
transparent

facebook#18938
facebook#18988

but it is important to notice how this default is now not anymore used
as JAVA sets a new default of transparent for all colors (null is not
passed to this setter)

facebook#29412 (comment)
  • Loading branch information
fabOnReact committed Feb 5, 2021
1 parent 849e0d5 commit 7c5587e
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,17 @@ public void setUnderlineColor(ReactEditText view, @Nullable Integer underlineCol
}
}

if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
setBorderColor(view, 4, Color.TRANSPARENT);
}

if (underlineColor == null) {
drawableToMutate.clearColorFilter();
} else {
drawableToMutate.setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
int bottomBorderColor = view.getBorderColor(Spacing.BOTTOM);
setBorderColor(view, Spacing.BOTTOM, underlineColor);
drawableToMutate.setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN);
setBorderColor(view, Spacing.BOTTOM, bottomBorderColor);
} else {
drawableToMutate.setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN);
}
}
}

Expand Down

0 comments on commit 7c5587e

Please sign in to comment.