Count the downloads under each header instead of count the number of headers (#7990)
Cette révision appartient à :
Parent
3dea10bcb9
révision
0215b66098
1 fichiers modifiés avec 6 ajouts et 2 suppressions
|
@ -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),
|
||||
|
|
Référencer dans un nouveau ticket