textColorRes and descriptionTextColorRes aren't work correctly
CheK539 opened this issue · 3 comments
CheK539 commented
About this issue
Hi, I am trying to create a PrimaryDrawerItem with color changing textColor and desctiptionTextColor using textColorRes and desctiptionTextColorRes, but it doesn't work as I expected. Instead of changing the textColor, the selectedColor is changed.
Note that changing the textColor field manually works correctly.
Then I went through the source code and saw that textColorRes and descriptionTextColorRes are a SelectableColor extension instead of a NameableColor in NameableColor.kt:
var SelectableColor.textColorRes: Int
@Deprecated(level = DeprecationLevel.ERROR, message = "Not readable")
get() = throw UnsupportedOperationException("Please use the direct property")
set(@ColorRes value) {
selectedColor = ColorHolder.fromColorRes(value)
}
Sample code for this:
binding.slider.addItems(
PrimaryDrawerItem().apply {
nameText = "Test item"
descriptionText = "Test description"
textColorRes = R.color.teal_700
descriptionTextColorRes = R.color.teal_200
}
)
Details
- Used library version - 8.4.2
- Used support library version - 8.4.2
- Used gradle build tools version - 7.0.0
- Used tooling / Android Studio version - 2020.3.1
- Other used libraries, potential conflicting libraries
Checklist
- Searched for similar issues
- Checked out the sample application
- Read the README
- Checked out the CHANGELOG
- Read the FAQ
- Checked out the MIGRATION GUIDE
mikepenz commented
@davidhowe it should be the same extension function. due to it not having access to the context, the res
variant is no-op and it's suggested to use textColor
directly