Count the downloads under each header instead of count the number of headers (#7990)
This commit is contained in:
parent
3dea10bcb9
commit
0215b66098
@ -25,6 +25,7 @@ import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberTopAppBarState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@ -106,6 +107,9 @@ class DownloadController :
|
||||
override fun ComposeContent() {
|
||||
val context = LocalContext.current
|
||||
val downloadList by presenter.state.collectAsState()
|
||||
val downloadCount by remember {
|
||||
derivedStateOf { downloadList.sumOf { it.subItems.size } }
|
||||
}
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
var fabExpanded by remember { mutableStateOf(true) }
|
||||
@ -142,10 +146,10 @@ class DownloadController :
|
||||
modifier = Modifier.weight(1f, false),
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (downloadList.isNotEmpty()) {
|
||||
if (downloadCount > 0) {
|
||||
val pillAlpha = if (isSystemInDarkTheme()) 0.12f else 0.08f
|
||||
Pill(
|
||||
text = "${downloadList.size}",
|
||||
text = "$downloadCount",
|
||||
modifier = Modifier.padding(start = 4.dp),
|
||||
color = MaterialTheme.colorScheme.onBackground
|
||||
.copy(alpha = pillAlpha),
|
||||
|
Loading…
Reference in New Issue
Block a user