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.annotation.SuppressLint
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.github.tibolte.agendacalendarview.render.EventRenderer
|
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.R
|
||||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventBinding
|
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventBinding
|
||||||
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventCompactBinding
|
import pl.szczodrzynski.edziennik.databinding.AgendaWrappedEventCompactBinding
|
||||||
@ -22,14 +29,33 @@ class AgendaEventRenderer(
|
|||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun render(view: View, aEvent: AgendaEvent) {
|
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 event = aEvent.event
|
||||||
|
|
||||||
|
val textColor = Colors.legibleTextColor(event.eventColor)
|
||||||
|
|
||||||
val timeText = if (event.time == null)
|
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
|
else
|
||||||
event.time!!.stringHM
|
event.time!!.stringHM
|
||||||
|
|
||||||
val eventTitle = "${event.typeName ?: "wydarzenie"} - ${event.topic}"
|
var eventTitle = "${event.typeName ?: "wydarzenie"} - ${event.topic}"
|
||||||
|
|
||||||
val eventSubtitle = listOfNotNull(
|
val eventSubtitle = listOfNotNull(
|
||||||
timeText,
|
timeText,
|
||||||
@ -38,36 +64,33 @@ class AgendaEventRenderer(
|
|||||||
event.teamName
|
event.teamName
|
||||||
).join(", ")
|
).join(", ")
|
||||||
|
|
||||||
if (isCompact) {
|
if (event.addedManually) {
|
||||||
val b = AgendaWrappedEventCompactBinding.bind(view).item
|
eventTitle = "{cmd-clipboard-edit-outline} $eventTitle"
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
val b = AgendaWrappedEventBinding.bind(view).item
|
|
||||||
|
|
||||||
b.card.foreground.setTintColor(event.eventColor)
|
card.foreground.setTintColor(event.eventColor)
|
||||||
b.card.background.setTintColor(event.eventColor)
|
card.background.setTintColor(event.eventColor)
|
||||||
b.title.text = eventTitle
|
title.text = eventTitle
|
||||||
b.title.setTextColor(Colors.legibleTextColor(event.eventColor))
|
title.setTextColor(textColor)
|
||||||
b.subtitle.text = eventSubtitle
|
subtitle?.text = eventSubtitle
|
||||||
b.subtitle.setTextColor(Colors.legibleTextColor(event.eventColor))
|
subtitle?.setTextColor(textColor)
|
||||||
|
|
||||||
b.badgeBackground.isVisible = aEvent.showItemBadge
|
title.setCompoundDrawables(
|
||||||
b.badgeBackground.background.setTintColor(
|
null,
|
||||||
android.R.attr.colorBackground.resolveAttr(view.context)
|
null,
|
||||||
)
|
if (event.isDone) IconicsDrawable(card.context).apply {
|
||||||
b.badge.isVisible = aEvent.showItemBadge
|
icon = CommunityMaterial.Icon.cmd_check
|
||||||
}
|
colorInt = textColor
|
||||||
|
sizeDp = 24
|
||||||
|
} else null,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
|
||||||
|
badgeBackground.isVisible = aEvent.showItemBadge
|
||||||
|
badgeBackground.background.setTintColor(
|
||||||
|
android.R.attr.colorBackground.resolveAttr(card.context)
|
||||||
|
)
|
||||||
|
badge.isVisible = aEvent.showItemBadge
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getEventLayout() = if (isCompact)
|
override fun getEventLayout() = if (isCompact)
|
||||||
|
@ -17,13 +17,14 @@ class LessonChangesEventRenderer : EventRenderer<LessonChangesEvent>() {
|
|||||||
|
|
||||||
override fun render(view: View, event: LessonChangesEvent) {
|
override fun render(view: View, event: LessonChangesEvent) {
|
||||||
val b = AgendaWrappedCounterBinding.bind(view).item
|
val b = AgendaWrappedCounterBinding.bind(view).item
|
||||||
|
val textColor = Colors.legibleTextColor(event.color)
|
||||||
|
|
||||||
b.card.foreground.setTintColor(event.color)
|
b.card.foreground.setTintColor(event.color)
|
||||||
b.card.background.setTintColor(event.color)
|
b.card.background.setTintColor(event.color)
|
||||||
b.name.setText(R.string.agenda_lesson_changes)
|
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.text = event.count.toString()
|
||||||
b.count.setTextColor(b.name.currentTextColor)
|
b.count.setTextColor(textColor)
|
||||||
|
|
||||||
b.badgeBackground.isVisible = event.showItemBadge
|
b.badgeBackground.isVisible = event.showItemBadge
|
||||||
b.badgeBackground.background.setTintColor(
|
b.badgeBackground.background.setTintColor(
|
||||||
|
@ -16,13 +16,14 @@ class TeacherAbsenceEventRenderer : EventRenderer<TeacherAbsenceEvent>() {
|
|||||||
|
|
||||||
override fun render(view: View, event: TeacherAbsenceEvent) {
|
override fun render(view: View, event: TeacherAbsenceEvent) {
|
||||||
val b = AgendaWrappedCounterBinding.bind(view).item
|
val b = AgendaWrappedCounterBinding.bind(view).item
|
||||||
|
val textColor = Colors.legibleTextColor(event.color)
|
||||||
|
|
||||||
b.card.foreground.setTintColor(event.color)
|
b.card.foreground.setTintColor(event.color)
|
||||||
b.card.background.setTintColor(event.color)
|
b.card.background.setTintColor(event.color)
|
||||||
b.name.setText(R.string.agenda_teacher_absence)
|
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.text = event.count.toString()
|
||||||
b.count.setTextColor(b.name.currentTextColor)
|
b.count.setTextColor(textColor)
|
||||||
|
|
||||||
b.badgeBackground.isVisible = false
|
b.badgeBackground.isVisible = false
|
||||||
b.badge.isVisible = false
|
b.badge.isVisible = false
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="10dp">
|
android:padding="10dp">
|
||||||
|
|
||||||
<TextView
|
<com.mikepenz.iconics.view.IconicsTextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="10dp">
|
android:padding="10dp">
|
||||||
|
|
||||||
<TextView
|
<com.mikepenz.iconics.view.IconicsTextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user