Fix lateness color in attendance (#2481)

This commit is contained in:
Rafał Borcz 2024-03-11 23:38:17 +01:00 committed by Mikołaj Pich
parent 78e28ad791
commit 8623b53357
No known key found for this signature in database
2 changed files with 17 additions and 13 deletions

View File

@ -1,5 +1,6 @@
package io.github.wulkanowy.ui.modules.attendance
import android.content.res.ColorStateList
import android.graphics.Typeface
import android.view.LayoutInflater
import android.view.View
@ -33,17 +34,17 @@ class AttendanceAdapter @Inject constructor() :
)
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
val context = holder.binding.root.context
val item = items[position]
with(holder.binding) {
attendanceItemNumber.text = item.number.toString()
attendanceItemSubject.text = item.subject.ifBlank {
root.context.getString(R.string.all_no_data)
}
attendanceItemSubject.text = item.subject
.ifBlank { context.getString(R.string.all_no_data) }
attendanceItemDescription.setText(item.descriptionRes)
attendanceItemDescription.setTextColor(
root.context.getThemeAttrColor(
context.getThemeAttrColor(
when {
item.absence && !item.excused -> R.attr.colorAttendanceAbsence
item.lateness && !item.excused -> R.attr.colorAttendanceLateness
@ -61,13 +62,15 @@ class AttendanceAdapter @Inject constructor() :
attendanceItemAlert.isVisible =
item.let { (it.absence && !it.excused) || (it.lateness && !it.excused) }
attendanceItemAlert.setColorFilter(root.context.getThemeAttrColor(
when{
item.absence && !item.excused -> R.attr.colorAttendanceAbsence
item.lateness && !item.excused -> R.attr.colorAttendanceLateness
else -> android.R.attr.colorPrimary
}
))
attendanceItemAlert.imageTintList = ColorStateList.valueOf(
context.getThemeAttrColor(
when {
item.absence && !item.excused -> R.attr.colorAttendanceAbsence
item.lateness && !item.excused -> R.attr.colorAttendanceLateness
else -> android.R.attr.colorPrimary
}
)
)
attendanceItemNumber.visibility = View.GONE
attendanceItemExcuseInfo.visibility = View.GONE
attendanceItemExcuseCheckbox.visibility = View.GONE

View File

@ -46,14 +46,15 @@
<color name="timetable_canceled_light">#d32f2f</color>
<color name="timetable_canceled_dark">#e57373</color>
<color name="timetable_change_light">#ff8f00</color>
<color name="timetable_change_dark">#ffd54f</color>
<color name="attendance_absence_light">#d32f2f</color>
<color name="attendance_absence_dark">#e57373</color>
<color name="attendance_lateness_light">#cd2a01</color>
<color name="attendance_lateness_dark">#f05d0e</color>
<color name="attendance_lateness_light">#ff8f00</color>
<color name="attendance_lateness_dark">#ffd54f</color>
<color name="colorDivider">#1f000000</color>
<color name="colorDividerInverse">#1fffffff</color>