Revert "Do not suggest collapse if there is only one section"

This reverts commit 6787980185.
This commit is contained in:
ganfra 2022-03-23 16:09:05 +01:00
parent 4755ebfa97
commit 55b1a60f96
2 changed files with 8 additions and 23 deletions

View file

@ -295,8 +295,7 @@ class RoomListFragment @Inject constructor(
section.notificationCount.observe(viewLifecycleOwner) { counts ->
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
notificationCount = counts.totalCount,
isHighlighted = counts.isHighlight,
shouldShowExpandedArrow = shouldShowExpendedArrow()
isHighlighted = counts.isHighlight
))
}
section.isExpanded.observe(viewLifecycleOwner) { _ ->
@ -330,17 +329,14 @@ class RoomListFragment @Inject constructor(
controller.setData(list)
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
isHidden = list.isEmpty(),
isLoading = false,
shouldShowExpandedArrow = shouldShowExpendedArrow()
))
isLoading = false))
checkEmptyState()
}
observeItemCount(section, sectionAdapter)
section.notificationCount.observe(viewLifecycleOwner) { counts ->
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
notificationCount = counts.totalCount,
isHighlighted = counts.isHighlight,
shouldShowExpandedArrow = shouldShowExpendedArrow()
isHighlighted = counts.isHighlight
))
}
section.isExpanded.observe(viewLifecycleOwner) { _ ->
@ -448,10 +444,6 @@ class RoomListFragment @Inject constructor(
footerController.setData(state)
}
private fun shouldShowExpendedArrow(): Boolean {
return adapterInfosList.filter { !it.sectionHeaderAdapter.roomsSectionData.isHidden }.size >= 2
}
private fun checkEmptyState() {
val shouldShowEmpty = adapterInfosList.all { it.sectionHeaderAdapter.roomsSectionData.isHidden } &&
!adapterInfosList.any { it.sectionHeaderAdapter.roomsSectionData.isLoading }

View file

@ -17,7 +17,6 @@
package im.vector.app.features.home.room.list
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
@ -40,8 +39,7 @@ class SectionHeaderAdapter constructor(
val isHighlighted: Boolean = false,
val isHidden: Boolean = true,
// This will be false until real data has been submitted once
val isLoading: Boolean = true,
val shouldShowExpandedArrow: Boolean = false
val isLoading: Boolean = true
)
lateinit var roomsSectionData: RoomsSectionData
@ -84,16 +82,11 @@ class SectionHeaderAdapter constructor(
fun bind(roomsSectionData: RoomsSectionData) {
binding.roomCategoryTitleView.text = roomsSectionData.name
val tintColor = ThemeUtils.getColor(binding.root.context, R.attr.vctr_content_secondary)
if (roomsSectionData.shouldShowExpandedArrow) {
binding.roomCategoryCounterView.visibility = View.VISIBLE
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)
}
binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
} else {
binding.roomCategoryCounterView.visibility = View.GONE
}
binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty()
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted))
}