2019-01-18 10:12:08 +00:00
|
|
|
/*
|
2019-01-25 13:04:59 +00:00
|
|
|
* Copyright 2019 New Vector Ltd
|
2019-01-18 10:12:08 +00:00
|
|
|
*
|
2019-01-25 13:04:59 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2019-01-18 10:12:08 +00:00
|
|
|
*
|
2019-01-25 13:04:59 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2019-01-18 10:12:08 +00:00
|
|
|
*/
|
|
|
|
|
2018-10-29 19:29:09 +00:00
|
|
|
package im.vector.riotredesign.features.home.room.list
|
|
|
|
|
2018-10-30 17:22:29 +00:00
|
|
|
import android.view.ViewGroup
|
|
|
|
import android.widget.TextView
|
2019-01-24 15:30:05 +00:00
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.core.graphics.drawable.DrawableCompat
|
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,
|
2019-01-29 13:39:23 +00:00
|
|
|
val unreadCount: Int,
|
|
|
|
val showHighlighted: Boolean,
|
2018-10-29 19:29:09 +00:00
|
|
|
val listener: (() -> Unit)? = null
|
|
|
|
) : KotlinModel(R.layout.item_room_category) {
|
|
|
|
|
2019-01-29 13:39:23 +00:00
|
|
|
private val unreadCounterBadgeView by bind<UnreadCounterBadgeView>(R.id.roomCategoryUnreadCounterBadgeView)
|
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
|
2019-01-24 15:30:05 +00:00
|
|
|
val expandedArrowDrawable = ContextCompat.getDrawable(rootView.context, expandedArrowDrawableRes)?.also {
|
|
|
|
DrawableCompat.setTint(it, tintColor)
|
|
|
|
}
|
2019-01-29 13:39:23 +00:00
|
|
|
unreadCounterBadgeView.render(unreadCount, showHighlighted)
|
2018-10-30 17:22:29 +00:00
|
|
|
titleView.setCompoundDrawablesWithIntrinsicBounds(expandedArrowDrawable, null, null, null)
|
|
|
|
titleView.text = title
|
|
|
|
rootView.setOnClickListener { listener?.invoke() }
|
2018-10-29 19:29:09 +00:00
|
|
|
}
|
|
|
|
}
|