2018-10-29 19:29:09 +00:00
|
|
|
package im.vector.riotredesign.features.home.room.list
|
|
|
|
|
2019-01-16 18:25:43 +00:00
|
|
|
import androidx.core.content.ContextCompat
|
2018-10-30 17:22:29 +00:00
|
|
|
import android.view.ViewGroup
|
|
|
|
import android.widget.TextView
|
2018-10-29 19:29:09 +00:00
|
|
|
import im.vector.riotredesign.R
|
|
|
|
import im.vector.riotredesign.core.epoxy.KotlinModel
|
|
|
|
|
|
|
|
data class RoomCategoryItem(
|
|
|
|
val title: CharSequence,
|
2018-10-30 17:22:29 +00:00
|
|
|
val isExpanded: Boolean,
|
2018-10-29 19:29:09 +00:00
|
|
|
val listener: (() -> Unit)? = null
|
|
|
|
) : KotlinModel(R.layout.item_room_category) {
|
|
|
|
|
2018-10-30 17:22:29 +00:00
|
|
|
private val titleView by bind<TextView>(R.id.roomCategoryTitleView)
|
|
|
|
private val rootView by bind<ViewGroup>(R.id.roomCategoryRootView)
|
|
|
|
|
|
|
|
private val tintColor by lazy {
|
|
|
|
ContextCompat.getColor(rootView.context, R.color.bluey_grey_two)
|
|
|
|
}
|
2018-10-29 19:29:09 +00:00
|
|
|
|
2018-10-30 17:22:29 +00:00
|
|
|
override fun bind() {
|
|
|
|
val expandedArrowDrawableRes = if (isExpanded) R.drawable.ic_expand_more_white else R.drawable.ic_expand_less_white
|
|
|
|
val expandedArrowDrawable = ContextCompat.getDrawable(rootView.context, expandedArrowDrawableRes)
|
|
|
|
expandedArrowDrawable?.setTint(tintColor)
|
|
|
|
titleView.setCompoundDrawablesWithIntrinsicBounds(expandedArrowDrawable, null, null, null)
|
|
|
|
titleView.text = title
|
|
|
|
rootView.setOnClickListener { listener?.invoke() }
|
2018-10-29 19:29:09 +00:00
|
|
|
}
|
|
|
|
}
|