do not display default group if it is empty (#756)

This commit is contained in:
aualbert 2024-06-19 09:12:45 +00:00 committed by GitHub
parent 9324511c9f
commit 384684e77c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 24 deletions

View File

@ -66,6 +66,7 @@ import me.ash.reader.ui.ext.collectAsStateValue
import me.ash.reader.ui.ext.currentAccountId import me.ash.reader.ui.ext.currentAccountId
import me.ash.reader.ui.ext.findActivity import me.ash.reader.ui.ext.findActivity
import me.ash.reader.ui.ext.getCurrentVersion import me.ash.reader.ui.ext.getCurrentVersion
import me.ash.reader.ui.ext.getDefaultGroupId
import me.ash.reader.ui.page.common.RouteName import me.ash.reader.ui.page.common.RouteName
import me.ash.reader.ui.page.home.FilterState import me.ash.reader.ui.page.home.FilterState
import me.ash.reader.ui.page.home.HomeViewModel import me.ash.reader.ui.page.home.HomeViewModel
@ -232,6 +233,7 @@ fun FeedsPage(
) )
} }
} }
item { item {
Spacer(modifier = Modifier.height(24.dp)) Spacer(modifier = Modifier.height(24.dp))
Subtitle( Subtitle(
@ -240,38 +242,45 @@ fun FeedsPage(
) )
Spacer(modifier = Modifier.height(8.dp)) Spacer(modifier = Modifier.height(8.dp))
} }
val defaultGroupId = context.currentAccountId.getDefaultGroupId()
itemsIndexed(groupWithFeedList) { index, groupWithFeed -> itemsIndexed(groupWithFeedList) { index, groupWithFeed ->
when (groupWithFeed) { when (groupWithFeed) {
is GroupFeedsView.Group -> { is GroupFeedsView.Group -> {
if (index != 0) { if (index != 0) {
Spacer(modifier = Modifier.height(16.dp)) Spacer(modifier = Modifier.height(16.dp))
} }
GroupItem(
isExpanded = { if (groupWithFeed.group.id != defaultGroupId || groupWithFeed.group.feeds > 0) {
groupsVisible.getOrPut( GroupItem(
groupWithFeed.group.id, isExpanded = {
groupListExpand::value groupsVisible.getOrPut(
groupWithFeed.group.id,
groupListExpand::value
)
},
group = groupWithFeed.group,
alpha = groupAlpha,
indicatorAlpha = groupIndicatorAlpha,
roundedBottomCorner = { index == groupWithFeedList.lastIndex || groupWithFeed.group.feeds == 0 },
onExpanded = {
groupsVisible[groupWithFeed.group.id] =
groupsVisible.getOrPut(
groupWithFeed.group.id,
groupListExpand::value
).not()
}
) {
filterChange(
navController = navController,
homeViewModel = homeViewModel,
filterState = filterUiState.copy(
group = groupWithFeed.group,
feed = null,
)
) )
},
group = groupWithFeed.group,
alpha = groupAlpha,
indicatorAlpha = groupIndicatorAlpha,
roundedBottomCorner = { index == groupWithFeedList.lastIndex || groupWithFeed.group.feeds == 0 },
onExpanded = {
groupsVisible[groupWithFeed.group.id] = groupsVisible.getOrPut(
groupWithFeed.group.id,
groupListExpand::value
).not()
} }
) {
filterChange(
navController = navController,
homeViewModel = homeViewModel,
filterState = filterUiState.copy(
group = groupWithFeed.group,
feed = null,
)
)
} }
} }