Skip to content

Commit

Permalink
do not display default group if it is empty (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
aualbert committed Jun 19, 2024
1 parent 9324511 commit 384684e
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import me.ash.reader.ui.ext.collectAsStateValue
import me.ash.reader.ui.ext.currentAccountId
import me.ash.reader.ui.ext.findActivity
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.home.FilterState
import me.ash.reader.ui.page.home.HomeViewModel
Expand Down Expand Up @@ -232,6 +233,7 @@ fun FeedsPage(
)
}
}

item {
Spacer(modifier = Modifier.height(24.dp))
Subtitle(
Expand All @@ -240,38 +242,45 @@ fun FeedsPage(
)
Spacer(modifier = Modifier.height(8.dp))
}

val defaultGroupId = context.currentAccountId.getDefaultGroupId()

itemsIndexed(groupWithFeedList) { index, groupWithFeed ->
when (groupWithFeed) {
is GroupFeedsView.Group -> {
if (index != 0) {
Spacer(modifier = Modifier.height(16.dp))
}
GroupItem(
isExpanded = {
groupsVisible.getOrPut(
groupWithFeed.group.id,
groupListExpand::value

if (groupWithFeed.group.id != defaultGroupId || groupWithFeed.group.feeds > 0) {
GroupItem(
isExpanded = {
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,
)
)
}
}

Expand Down

0 comments on commit 384684e

Please sign in to comment.