Hide bulkSelection’s “Select all” button when not used

(cherry picked from commit 8f8214f65467cde97161a5fd9edab5b1543b333e)
This commit is contained in:
Cuong Tran 2024-04-25 22:02:55 +07:00 committed by Cuong M. Tran
parent fddfe6280a
commit 097ce0e2c3
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -15,30 +15,38 @@ fun SelectionToolbar(
selectedCount: Int,
onClickClearSelection: () -> Unit,
onChangeCategoryClicked: () -> Unit,
onSelectAll: () -> Unit = {},
onSelectAll: (() -> Unit)? = null,
) {
AppBar(
titleContent = { Text(text = "$selectedCount") },
actions = {
AppBarActions(
persistentListOf(
AppBar.Action(
title = stringResource(MR.strings.action_bookmark),
icon = Icons.Filled.BookmarkAdd,
onClick = {
if (selectedCount > 0) {
onChangeCategoryClicked()
}
},
),
AppBar.Action(
title = stringResource(MR.strings.action_select_all),
icon = Icons.Filled.SelectAll,
onClick = {
onSelectAll.invoke()
},
),
),
actions = persistentListOf<AppBar.AppBarAction>().builder()
.apply {
if (onSelectAll != null) {
add(
AppBar.Action(
title = stringResource(MR.strings.action_select_all),
icon = Icons.Filled.SelectAll,
onClick = {
onSelectAll.invoke()
},
),
)
}
add(
AppBar.Action(
title = stringResource(MR.strings.action_bookmark),
icon = Icons.Filled.BookmarkAdd,
onClick = {
if (selectedCount > 0) {
onChangeCategoryClicked()
}
},
),
)
}
.build(),
)
},
isActionMode = true,