2019-01-18 10:12:08 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* * Copyright 2019 New Vector Ltd
|
|
|
|
* *
|
|
|
|
* * 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
|
|
|
|
* *
|
|
|
|
* * 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|