Do not suggest collapse if there is only one section
This commit is contained in:
parent
073475854e
commit
6787980185
|
@ -0,0 +1 @@
|
||||||
|
[Rooms list] Do not suggest collapse the unique section
|
|
@ -295,7 +295,8 @@ class RoomListFragment @Inject constructor(
|
||||||
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
||||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||||
notificationCount = counts.totalCount,
|
notificationCount = counts.totalCount,
|
||||||
isHighlighted = counts.isHighlight
|
isHighlighted = counts.isHighlight,
|
||||||
|
shouldShowExpandedArrow = shouldShowExpendedArrow()
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
||||||
|
@ -329,14 +330,17 @@ class RoomListFragment @Inject constructor(
|
||||||
controller.setData(list)
|
controller.setData(list)
|
||||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||||
isHidden = list.isEmpty(),
|
isHidden = list.isEmpty(),
|
||||||
isLoading = false))
|
isLoading = false,
|
||||||
|
shouldShowExpandedArrow = shouldShowExpendedArrow()
|
||||||
|
))
|
||||||
checkEmptyState()
|
checkEmptyState()
|
||||||
}
|
}
|
||||||
observeItemCount(section, sectionAdapter)
|
observeItemCount(section, sectionAdapter)
|
||||||
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
||||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||||
notificationCount = counts.totalCount,
|
notificationCount = counts.totalCount,
|
||||||
isHighlighted = counts.isHighlight
|
isHighlighted = counts.isHighlight,
|
||||||
|
shouldShowExpandedArrow = shouldShowExpendedArrow()
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
||||||
|
@ -444,6 +448,10 @@ class RoomListFragment @Inject constructor(
|
||||||
footerController.setData(state)
|
footerController.setData(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun shouldShowExpendedArrow(): Boolean {
|
||||||
|
return adapterInfosList.filter { !it.sectionHeaderAdapter.roomsSectionData.isHidden }.size >= 2
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkEmptyState() {
|
private fun checkEmptyState() {
|
||||||
val shouldShowEmpty = adapterInfosList.all { it.sectionHeaderAdapter.roomsSectionData.isHidden } &&
|
val shouldShowEmpty = adapterInfosList.all { it.sectionHeaderAdapter.roomsSectionData.isHidden } &&
|
||||||
!adapterInfosList.any { it.sectionHeaderAdapter.roomsSectionData.isLoading }
|
!adapterInfosList.any { it.sectionHeaderAdapter.roomsSectionData.isLoading }
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package im.vector.app.features.home.room.list
|
package im.vector.app.features.home.room.list
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.drawable.DrawableCompat
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
|
@ -39,7 +40,8 @@ class SectionHeaderAdapter constructor(
|
||||||
val isHighlighted: Boolean = false,
|
val isHighlighted: Boolean = false,
|
||||||
val isHidden: Boolean = true,
|
val isHidden: Boolean = true,
|
||||||
// This will be false until real data has been submitted once
|
// This will be false until real data has been submitted once
|
||||||
val isLoading: Boolean = true
|
val isLoading: Boolean = true,
|
||||||
|
val shouldShowExpandedArrow: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
lateinit var roomsSectionData: RoomsSectionData
|
lateinit var roomsSectionData: RoomsSectionData
|
||||||
|
@ -82,11 +84,16 @@ class SectionHeaderAdapter constructor(
|
||||||
fun bind(roomsSectionData: RoomsSectionData) {
|
fun bind(roomsSectionData: RoomsSectionData) {
|
||||||
binding.roomCategoryTitleView.text = roomsSectionData.name
|
binding.roomCategoryTitleView.text = roomsSectionData.name
|
||||||
val tintColor = ThemeUtils.getColor(binding.root.context, R.attr.vctr_content_secondary)
|
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
|
if (roomsSectionData.shouldShowExpandedArrow) {
|
||||||
val expandedArrowDrawable = ContextCompat.getDrawable(binding.root.context, expandedArrowDrawableRes)?.also {
|
binding.roomCategoryCounterView.visibility = View.VISIBLE
|
||||||
DrawableCompat.setTint(it, tintColor)
|
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.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
|
|
||||||
binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty()
|
binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty()
|
||||||
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted))
|
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue