forked from github/szkolny
[UI] Add icons for done and manual events.
This commit is contained in:
parent
12619f6bde
commit
5eaa754401
@ -6,8 +6,15 @@ package pl.szczodrzynski.edziennik.ui.modules.agenda.event
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
||||
import com.mikepenz.iconics.IconicsDrawable
|
||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||
import com.mikepenz.iconics.utils.colorInt
|
||||
import com.mikepenz.iconics.utils.sizeDp
|
||||
import com.mikepenz.iconics.view.IconicsTextView
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventBinding
|
||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventCompactBinding
|
||||
@ -22,14 +29,33 @@ class AgendaEventRenderer(
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun render(view: View, aEvent: AgendaEvent) {
|
||||
if (isCompact) {
|
||||
val b = AgendaWrappedEventCompactBinding.bind(view).item
|
||||
bindView(aEvent, b.card, b.title, null, b.badgeBackground, b.badge)
|
||||
} else {
|
||||
val b = AgendaWrappedEventBinding.bind(view).item
|
||||
bindView(aEvent, b.card, b.title, b.subtitle, b.badgeBackground, b.badge)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindView(
|
||||
aEvent: AgendaEvent,
|
||||
card: FrameLayout,
|
||||
title: IconicsTextView,
|
||||
subtitle: TextView?,
|
||||
badgeBackground: View,
|
||||
badge: View
|
||||
) {
|
||||
val event = aEvent.event
|
||||
|
||||
val textColor = Colors.legibleTextColor(event.eventColor)
|
||||
|
||||
val timeText = if (event.time == null)
|
||||
view.context.getString(R.string.agenda_event_all_day)
|
||||
card.context.getString(R.string.agenda_event_all_day)
|
||||
else
|
||||
event.time!!.stringHM
|
||||
|
||||
val eventTitle = "${event.typeName ?: "wydarzenie"} - ${event.topic}"
|
||||
var eventTitle = "${event.typeName ?: "wydarzenie"} - ${event.topic}"
|
||||
|
||||
val eventSubtitle = listOfNotNull(
|
||||
timeText,
|
||||
@ -38,36 +64,33 @@ class AgendaEventRenderer(
|
||||
event.teamName
|
||||
).join(", ")
|
||||
|
||||
if (isCompact) {
|
||||
val b = AgendaWrappedEventCompactBinding.bind(view).item
|
||||
|
||||
b.card.foreground.setTintColor(event.eventColor)
|
||||
b.card.background.setTintColor(event.eventColor)
|
||||
b.title.text = eventTitle
|
||||
b.title.setTextColor(Colors.legibleTextColor(event.eventColor))
|
||||
|
||||
b.badgeBackground.isVisible = aEvent.showItemBadge
|
||||
b.badgeBackground.background.setTintColor(
|
||||
android.R.attr.colorBackground.resolveAttr(view.context)
|
||||
)
|
||||
b.badge.isVisible = aEvent.showItemBadge
|
||||
if (event.addedManually) {
|
||||
eventTitle = "{cmd-clipboard-edit-outline} $eventTitle"
|
||||
}
|
||||
else {
|
||||
val b = AgendaWrappedEventBinding.bind(view).item
|
||||
|
||||
b.card.foreground.setTintColor(event.eventColor)
|
||||
b.card.background.setTintColor(event.eventColor)
|
||||
b.title.text = eventTitle
|
||||
b.title.setTextColor(Colors.legibleTextColor(event.eventColor))
|
||||
b.subtitle.text = eventSubtitle
|
||||
b.subtitle.setTextColor(Colors.legibleTextColor(event.eventColor))
|
||||
card.foreground.setTintColor(event.eventColor)
|
||||
card.background.setTintColor(event.eventColor)
|
||||
title.text = eventTitle
|
||||
title.setTextColor(textColor)
|
||||
subtitle?.text = eventSubtitle
|
||||
subtitle?.setTextColor(textColor)
|
||||
|
||||
b.badgeBackground.isVisible = aEvent.showItemBadge
|
||||
b.badgeBackground.background.setTintColor(
|
||||
android.R.attr.colorBackground.resolveAttr(view.context)
|
||||
title.setCompoundDrawables(
|
||||
null,
|
||||
null,
|
||||
if (event.isDone) IconicsDrawable(card.context).apply {
|
||||
icon = CommunityMaterial.Icon.cmd_check
|
||||
colorInt = textColor
|
||||
sizeDp = 24
|
||||
} else null,
|
||||
null
|
||||
)
|
||||
b.badge.isVisible = aEvent.showItemBadge
|
||||
}
|
||||
|
||||
badgeBackground.isVisible = aEvent.showItemBadge
|
||||
badgeBackground.background.setTintColor(
|
||||
android.R.attr.colorBackground.resolveAttr(card.context)
|
||||
)
|
||||
badge.isVisible = aEvent.showItemBadge
|
||||
}
|
||||
|
||||
override fun getEventLayout() = if (isCompact)
|
||||
|
@ -17,13 +17,14 @@ class LessonChangesEventRenderer : EventRenderer<LessonChangesEvent>() {
|
||||
|
||||
override fun render(view: View, event: LessonChangesEvent) {
|
||||
val b = AgendaWrappedCounterBinding.bind(view).item
|
||||
val textColor = Colors.legibleTextColor(event.color)
|
||||
|
||||
b.card.foreground.setTintColor(event.color)
|
||||
b.card.background.setTintColor(event.color)
|
||||
b.name.setText(R.string.agenda_lesson_changes)
|
||||
b.name.setTextColor(Colors.legibleTextColor(event.color))
|
||||
b.name.setTextColor(textColor)
|
||||
b.count.text = event.count.toString()
|
||||
b.count.setTextColor(b.name.currentTextColor)
|
||||
b.count.setTextColor(textColor)
|
||||
|
||||
b.badgeBackground.isVisible = event.showItemBadge
|
||||
b.badgeBackground.background.setTintColor(
|
||||
|
@ -16,13 +16,14 @@ class TeacherAbsenceEventRenderer : EventRenderer<TeacherAbsenceEvent>() {
|
||||
|
||||
override fun render(view: View, event: TeacherAbsenceEvent) {
|
||||
val b = AgendaWrappedCounterBinding.bind(view).item
|
||||
val textColor = Colors.legibleTextColor(event.color)
|
||||
|
||||
b.card.foreground.setTintColor(event.color)
|
||||
b.card.background.setTintColor(event.color)
|
||||
b.name.setText(R.string.agenda_teacher_absence)
|
||||
b.name.setTextColor(Colors.legibleTextColor(event.color))
|
||||
b.name.setTextColor(textColor)
|
||||
b.count.text = event.count.toString()
|
||||
b.count.setTextColor(b.name.currentTextColor)
|
||||
b.count.setTextColor(textColor)
|
||||
|
||||
b.badgeBackground.isVisible = false
|
||||
b.badge.isVisible = false
|
||||
|
@ -25,7 +25,7 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
<com.mikepenz.iconics.view.IconicsTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -25,7 +25,7 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
<com.mikepenz.iconics.view.IconicsTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user