mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-09 08:38:43 +01:00
Fix arrow visibility on section header
This commit is contained in:
parent
745382cdfa
commit
a362d5427d
@ -148,9 +148,10 @@ class RoomListFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun refreshCollapseStates() {
|
||||
val sectionsCount = adapterInfosList.count { !it.sectionHeaderAdapter.roomsSectionData.isHidden }
|
||||
roomListViewModel.sections.forEachIndexed { index, roomsSection ->
|
||||
val actualBlock = adapterInfosList[index]
|
||||
val isRoomSectionExpanded = roomsSection.isExpanded.value.orTrue()
|
||||
val isRoomSectionExpanded = roomsSection.isExpanded.value.orTrue() || sectionsCount == 1
|
||||
if (actualBlock.section.isExpanded && !isRoomSectionExpanded) {
|
||||
// mark controller as collapsed
|
||||
actualBlock.contentEpoxyController.setCollapsed(true)
|
||||
@ -162,7 +163,10 @@ class RoomListFragment @Inject constructor(
|
||||
isExpanded = isRoomSectionExpanded
|
||||
)
|
||||
actualBlock.sectionHeaderAdapter.updateSection(
|
||||
actualBlock.sectionHeaderAdapter.roomsSectionData.copy(isExpanded = isRoomSectionExpanded)
|
||||
actualBlock.sectionHeaderAdapter.roomsSectionData.copy(
|
||||
isExpanded = isRoomSectionExpanded,
|
||||
shouldShowExpandedArrow = sectionsCount > 1
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -289,6 +293,7 @@ class RoomListFragment @Inject constructor(
|
||||
isHidden = pl.isEmpty(),
|
||||
isLoading = false
|
||||
))
|
||||
refreshCollapseStates()
|
||||
checkEmptyState()
|
||||
}
|
||||
observeItemCount(section, sectionAdapter)
|
||||
@ -296,7 +301,6 @@ class RoomListFragment @Inject constructor(
|
||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||
notificationCount = counts.totalCount,
|
||||
isHighlighted = counts.isHighlight,
|
||||
shouldShowExpandedArrow = shouldShowExpendedArrow()
|
||||
))
|
||||
}
|
||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
||||
@ -314,6 +318,7 @@ class RoomListFragment @Inject constructor(
|
||||
isHidden = info.rooms.isEmpty(),
|
||||
isLoading = false
|
||||
))
|
||||
refreshCollapseStates()
|
||||
checkEmptyState()
|
||||
}
|
||||
observeItemCount(section, sectionAdapter)
|
||||
@ -331,16 +336,15 @@ class RoomListFragment @Inject constructor(
|
||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||
isHidden = list.isEmpty(),
|
||||
isLoading = false,
|
||||
shouldShowExpandedArrow = shouldShowExpendedArrow()
|
||||
))
|
||||
refreshCollapseStates()
|
||||
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 +452,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 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user