mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 15:01:52 +01:00
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.material3.rememberTopAppBarState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@ -106,6 +107,9 @@ class DownloadController :
|
|||||||
override fun ComposeContent() {
|
override fun ComposeContent() {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val downloadList by presenter.state.collectAsState()
|
val downloadList by presenter.state.collectAsState()
|
||||||
|
val downloadCount by remember {
|
||||||
|
derivedStateOf { downloadList.sumOf { it.subItems.size } }
|
||||||
|
}
|
||||||
|
|
||||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||||
var fabExpanded by remember { mutableStateOf(true) }
|
var fabExpanded by remember { mutableStateOf(true) }
|
||||||
@ -142,10 +146,10 @@ class DownloadController :
|
|||||||
modifier = Modifier.weight(1f, false),
|
modifier = Modifier.weight(1f, false),
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
if (downloadList.isNotEmpty()) {
|
if (downloadCount > 0) {
|
||||||
val pillAlpha = if (isSystemInDarkTheme()) 0.12f else 0.08f
|
val pillAlpha = if (isSystemInDarkTheme()) 0.12f else 0.08f
|
||||||
Pill(
|
Pill(
|
||||||
text = "${downloadList.size}",
|
text = "$downloadCount",
|
||||||
modifier = Modifier.padding(start = 4.dp),
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
color = MaterialTheme.colorScheme.onBackground
|
color = MaterialTheme.colorScheme.onBackground
|
||||||
.copy(alpha = pillAlpha),
|
.copy(alpha = pillAlpha),
|
||||||
|
Loading…
Reference in New Issue
Block a user