mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 16:09:17 +01:00
use Saver to save to state of expanded map
This commit is contained in:
parent
a6f35dda4d
commit
d4ad60515b
@ -26,6 +26,8 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateMapOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.Saver
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@ -235,9 +237,17 @@ fun CategoryList(
|
||||
onSelected: (DownloadStatManga, Boolean, Boolean, Boolean) -> Unit,
|
||||
categoryMap: Map<String, List<DownloadStatManga>>,
|
||||
) {
|
||||
val expanded = remember {
|
||||
mutableStateMapOf(*categoryMap.keys.toList().map { it to false }.toTypedArray())
|
||||
}
|
||||
val categoryExpandedMapSaver: Saver<MutableMap<String, Boolean>, *> = Saver(
|
||||
save = { map -> map.toMap() },
|
||||
restore = { map -> mutableStateMapOf(*map.toList().toTypedArray()) },
|
||||
)
|
||||
|
||||
val expanded = rememberSaveable(
|
||||
saver = categoryExpandedMapSaver,
|
||||
key = "CategoryExpandedMap",
|
||||
init = { mutableStateMapOf(*categoryMap.keys.toList().map { it to false }.toTypedArray()) },
|
||||
)
|
||||
|
||||
FastScrollLazyColumn(contentPadding = contentPadding) {
|
||||
categoryMap.forEach { (category, items) ->
|
||||
downloadStatGroupUiItem(
|
||||
|
Loading…
Reference in New Issue
Block a user