From b1d1090d1df4e75a55fe54aed7ca3a1ed41ca6c7 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Thu, 3 Feb 2022 16:47:17 +0100 Subject: [PATCH] Adding number of items (UI part) --- .../home/room/list/SectionHeaderAdapter.kt | 22 +++++++++---------- .../main/res/layout/item_room_category.xml | 22 ++++++++++++++----- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt b/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt index 560e0d00a3..7eb063eece 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt @@ -18,14 +18,10 @@ package im.vector.app.features.home.room.list import android.view.LayoutInflater import android.view.ViewGroup -import androidx.core.content.ContextCompat -import androidx.core.graphics.drawable.DrawableCompat import androidx.recyclerview.widget.RecyclerView import im.vector.app.R import im.vector.app.core.epoxy.ClickListener -import im.vector.app.core.epoxy.onClick import im.vector.app.databinding.ItemRoomCategoryBinding -import im.vector.app.features.themes.ThemeUtils class SectionHeaderAdapter constructor( private val onClickAction: ClickListener @@ -33,6 +29,7 @@ class SectionHeaderAdapter constructor( data class RoomsSectionData( val name: String, + val itemCount: Int = 0, val isExpanded: Boolean = true, val notificationCount: Int = 0, val isHighlighted: Boolean = false, @@ -79,14 +76,17 @@ class SectionHeaderAdapter constructor( } fun bind(roomsSectionData: RoomsSectionData) { - binding.roomCategoryTitleView.text = roomsSectionData.name - val tintColor = ThemeUtils.getColor(binding.root.context, R.attr.vctr_content_secondary) - val expandedArrowDrawableRes = if (roomsSectionData.isExpanded) R.drawable.ic_expand_more else R.drawable.ic_expand_less - val expandedArrowDrawable = ContextCompat.getDrawable(binding.root.context, expandedArrowDrawableRes)?.also { - DrawableCompat.setTint(it, tintColor) + with(binding) { + roomCategoryTitleView.text = roomsSectionData.name + val tintColor = ThemeUtils.getColor(root.context, R.attr.vctr_content_secondary) + val expandedArrowDrawableRes = if (roomsSectionData.isExpanded) R.drawable.ic_expand_more else R.drawable.ic_expand_less + val expandedArrowDrawable = ContextCompat.getDrawable(root.context, expandedArrowDrawableRes)?.also { + DrawableCompat.setTint(it, tintColor) + } + roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) + roomCategoryCounterView.text = roomsSectionData.itemCount.toString() + roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted)) } - binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted)) - binding.roomCategoryTitleView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) } companion object { diff --git a/vector/src/main/res/layout/item_room_category.xml b/vector/src/main/res/layout/item_room_category.xml index e9baf4ceb4..14d7118e43 100644 --- a/vector/src/main/res/layout/item_room_category.xml +++ b/vector/src/main/res/layout/item_room_category.xml @@ -11,8 +11,8 @@ android:foreground="?attr/selectableItemBackground" android:gravity="center_vertical" android:orientation="horizontal" - android:paddingStart="16dp" android:paddingVertical="8dp" + android:paddingStart="16dp" android:paddingEnd="@dimen/layout_horizontal_margin"> - +