forked from github/wulkanowy-mirror
Add colors to attendance and ! to unexcused lateness (#2412)
This commit is contained in:
parent
e58a60410c
commit
a05f1f70f7
@ -1,5 +1,6 @@
|
||||
package io.github.wulkanowy.ui.modules.attendance
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -10,6 +11,7 @@ import io.github.wulkanowy.data.db.entities.Attendance
|
||||
import io.github.wulkanowy.data.enums.SentExcuseStatus
|
||||
import io.github.wulkanowy.databinding.ItemAttendanceBinding
|
||||
import io.github.wulkanowy.utils.descriptionRes
|
||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||
import io.github.wulkanowy.utils.isExcusableOrNotExcused
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -39,7 +41,33 @@ class AttendanceAdapter @Inject constructor() :
|
||||
root.context.getString(R.string.all_no_data)
|
||||
}
|
||||
attendanceItemDescription.setText(item.descriptionRes)
|
||||
attendanceItemAlert.isVisible = item.let { it.absence && !it.excused }
|
||||
|
||||
attendanceItemDescription.setTextColor(
|
||||
root.context.getThemeAttrColor(
|
||||
when {
|
||||
item.absence && !item.excused -> R.attr.colorAttendanceAbsence
|
||||
item.lateness && !item.excused -> R.attr.colorAttendanceLateness
|
||||
else -> android.R.attr.textColorSecondary
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
if (item.exemption || item.excused) {
|
||||
attendanceItemDescription.setTypeface(null, Typeface.BOLD)
|
||||
} else {
|
||||
attendanceItemDescription.setTypeface(null, Typeface.NORMAL)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
))
|
||||
attendanceItemNumber.visibility = View.GONE
|
||||
attendanceItemExcuseInfo.visibility = View.GONE
|
||||
attendanceItemExcuseCheckbox.visibility = View.GONE
|
||||
@ -54,10 +82,12 @@ class AttendanceAdapter @Inject constructor() :
|
||||
attendanceItemExcuseInfo.visibility = View.VISIBLE
|
||||
attendanceItemAlert.visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
SentExcuseStatus.DENIED -> {
|
||||
attendanceItemExcuseInfo.setImageResource(R.drawable.ic_excuse_denied)
|
||||
attendanceItemExcuseInfo.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (item.isExcusableOrNotExcused && excuseActionMode) {
|
||||
attendanceItemNumber.visibility = View.GONE
|
||||
|
@ -6,10 +6,12 @@ import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Attendance
|
||||
import io.github.wulkanowy.databinding.DialogAttendanceBinding
|
||||
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
||||
import io.github.wulkanowy.utils.descriptionRes
|
||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||
import io.github.wulkanowy.utils.serializable
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
|
||||
@ -44,6 +46,16 @@ class AttendanceDialog : BaseDialogFragment<DialogAttendanceBinding>() {
|
||||
with(binding) {
|
||||
attendanceDialogSubjectValue.text = attendance.subject
|
||||
attendanceDialogDescriptionValue.setText(attendance.descriptionRes)
|
||||
attendanceDialogDescriptionValue.setTextColor(
|
||||
root.context.getThemeAttrColor(
|
||||
when {
|
||||
attendance.absence && !attendance.excused -> R.attr.colorAttendanceAbsence
|
||||
attendance.lateness && !attendance.excused -> R.attr.colorAttendanceLateness
|
||||
else -> android.R.attr.textColorSecondary
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
attendanceDialogDateValue.text = attendance.date.toFormattedString()
|
||||
attendanceDialogNumberValue.text = attendance.number.toString()
|
||||
attendanceDialogClose.setOnClickListener { dismiss() }
|
||||
|
@ -32,6 +32,9 @@
|
||||
<item name="colorPrimaryInverse">@color/material_dynamic_primary40</item>
|
||||
<item name="colorTimetableCanceled">@color/timetable_canceled_dark</item>
|
||||
<item name="colorTimetableChange">@color/timetable_change_dark</item>
|
||||
<item name="colorAttendanceAbsence">@color/attendance_absence_dark</item>
|
||||
<item name="colorAttendanceLateness">@color/attendance_lateness_dark</item>
|
||||
|
||||
<item name="colorError">@color/colorErrorLight</item>
|
||||
<item name="colorDivider">@color/colorDividerInverse</item>
|
||||
<item name="colorSwipeRefresh">@color/material_dynamic_secondary20</item>
|
||||
|
@ -21,6 +21,8 @@
|
||||
<item name="colorSurface">@color/colorSurfaceDark</item>
|
||||
<item name="colorTimetableCanceled">@color/timetable_canceled_dark</item>
|
||||
<item name="colorTimetableChange">@color/timetable_change_dark</item>
|
||||
<item name="colorAttendanceAbsence">@color/attendance_absence_dark</item>
|
||||
<item name="colorAttendanceLateness">@color/attendance_lateness_dark</item>
|
||||
<item name="colorError">@color/colorErrorLight</item>
|
||||
<item name="colorDivider">@color/colorDividerInverse</item>
|
||||
<item name="colorSwipeRefresh">@color/colorSwipeRefreshDark</item>
|
||||
|
@ -34,6 +34,9 @@
|
||||
<item name="colorPrimaryInverse">@color/material_dynamic_primary80</item>
|
||||
<item name="colorTimetableCanceled">@color/timetable_canceled_light</item>
|
||||
<item name="colorTimetableChange">@color/timetable_change_light</item>
|
||||
<item name="colorAttendanceAbsence">@color/attendance_absence_light</item>
|
||||
<item name="colorAttendanceLateness">@color/attendance_lateness_light</item>
|
||||
|
||||
<item name="colorError">@color/colorError</item>
|
||||
<item name="colorDivider">@color/colorDivider</item>
|
||||
<item name="colorSwipeRefresh">@color/material_dynamic_secondary90</item>
|
||||
|
@ -7,4 +7,6 @@
|
||||
<attr name="colorMessageMedium" format="color" />
|
||||
<attr name="colorMessageHigh" format="color" />
|
||||
<attr name="colorOnMessageHigh" format="color" />
|
||||
<attr name="colorAttendanceAbsence" format="color" />
|
||||
<attr name="colorAttendanceLateness" format="color" />
|
||||
</resources>
|
||||
|
@ -49,6 +49,12 @@
|
||||
<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="colorDivider">#1f000000</color>
|
||||
<color name="colorDividerInverse">#1fffffff</color>
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
<item name="colorSurface">@color/colorSurface</item>
|
||||
<item name="colorTimetableCanceled">@color/timetable_canceled_light</item>
|
||||
<item name="colorTimetableChange">@color/timetable_change_light</item>
|
||||
<item name="colorAttendanceAbsence">@color/attendance_absence_light</item>
|
||||
<item name="colorAttendanceLateness">@color/attendance_lateness_light</item>
|
||||
<item name="colorError">@color/colorError</item>
|
||||
<item name="colorDivider">@color/colorDivider</item>
|
||||
<item name="colorSwipeRefresh">@color/colorSwipeRefresh</item>
|
||||
|
Loading…
Reference in New Issue
Block a user