fix: Ensure poll option text is visible against the background (#86)

Draw poll bars using the container colour variants to ensure that the
text drawn on top is also visible against the background.

Fixes #85
This commit is contained in:
Nik Clayton 2023-09-23 11:58:00 +02:00 committed by GitHub
parent 5fd15852fb
commit 0b74b073a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,12 +97,14 @@ class PollAdapter : RecyclerView.Adapter<BindingHolder<ItemPollBinding>>() {
val level = percent * 100
val optionColor: Int
val textColor: Int
// Use the "container" colours to ensure the text is visible on the container
// and on the background, per https://github.com/pachli/pachli-android/issues/85
if (option.voted) {
optionColor = MaterialColors.getColor(resultTextView, com.google.android.material.R.attr.colorPrimary)
textColor = MaterialColors.getColor(resultTextView, com.google.android.material.R.attr.colorOnPrimary)
optionColor = MaterialColors.getColor(resultTextView, com.google.android.material.R.attr.colorPrimaryContainer)
textColor = MaterialColors.getColor(resultTextView, com.google.android.material.R.attr.colorOnPrimaryContainer)
} else {
optionColor = MaterialColors.getColor(resultTextView, com.google.android.material.R.attr.colorSecondary)
textColor = MaterialColors.getColor(resultTextView, com.google.android.material.R.attr.colorOnSecondary)
optionColor = MaterialColors.getColor(resultTextView, com.google.android.material.R.attr.colorSecondaryContainer)
textColor = MaterialColors.getColor(resultTextView, com.google.android.material.R.attr.colorOnSecondaryContainer)
}
resultTextView.background.level = level