Skip to content

Commit

Permalink
Hide bulkSelection’s “Select all” button when not used
Browse files Browse the repository at this point in the history
(cherry picked from commit 8f8214f65467cde97161a5fd9edab5b1543b333e)
  • Loading branch information
cuong-tran committed Apr 26, 2024
1 parent fddfe62 commit 097ce0e
Showing 1 changed file with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 097ce0e

Please sign in to comment.