Skip to content

Commit f0575f1

Browse files
Adding an else for task UI color
1 parent b225c13 commit f0575f1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

app/src/main/java/com/codelab/android/datastore/ui/TaskViewHolder.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,17 @@ class TaskViewHolder(
4545
setTaskPriority(todo)
4646
binding.deadline.text = dateFormat.format(todo.deadline)
4747
// if a task was completed, show it grayed out
48-
if (todo.completed) {
49-
itemView.setBackgroundColor(
50-
ContextCompat.getColor(
51-
itemView.context,
52-
R.color.greyAlpha
53-
)
54-
)
48+
val color = if (todo.completed) {
49+
R.color.greyAlpha
50+
} else {
51+
R.color.white
5552
}
53+
itemView.setBackgroundColor(
54+
ContextCompat.getColor(
55+
itemView.context,
56+
color
57+
)
58+
)
5659
}
5760

5861
private fun setTaskPriority(todo: Task) {

0 commit comments

Comments
 (0)