Select All for GlobalSearch

(cherry picked from commit a28233735cac5bce5a630de84555b501ffcccc8d)
This commit is contained in:
Cuong M. Tran 2024-03-12 15:03:52 +07:00
parent 5d870559e7
commit fddfe6280a
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
2 changed files with 23 additions and 0 deletions

View file

@ -52,6 +52,20 @@ fun GlobalSearchScreen(
selectedCount = bulkFavoriteState.selection.size,
onClickClearSelection = bulkFavoriteScreenModel::toggleSelectionMode,
onChangeCategoryClicked = bulkFavoriteScreenModel::addFavorite,
onSelectAll = {
state.filteredItems.forEach { (_, result) ->
when (result) {
is SearchItemResult.Success -> {
result.result.map{manga ->
if (!bulkFavoriteState.selection.contains(manga))
bulkFavoriteScreenModel.toggleSelection(manga)
}
}
else -> {}
}
}
},
)
} else {
// KMK <--

View file

@ -2,6 +2,7 @@ package eu.kanade.presentation.components
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.BookmarkAdd
import androidx.compose.material.icons.filled.SelectAll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
@ -14,6 +15,7 @@ fun SelectionToolbar(
selectedCount: Int,
onClickClearSelection: () -> Unit,
onChangeCategoryClicked: () -> Unit,
onSelectAll: () -> Unit = {},
) {
AppBar(
titleContent = { Text(text = "$selectedCount") },
@ -29,6 +31,13 @@ fun SelectionToolbar(
}
},
),
AppBar.Action(
title = stringResource(MR.strings.action_select_all),
icon = Icons.Filled.SelectAll,
onClick = {
onSelectAll.invoke()
},
),
),
)
},