From 097ce0e2c33131f62468867ff6531ae7ac0f05b3 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Thu, 25 Apr 2024 22:02:55 +0700 Subject: [PATCH] =?UTF-8?q?Hide=20bulkSelection=E2=80=99s=20=E2=80=9CSelec?= =?UTF-8?q?t=20all=E2=80=9D=20button=20when=20not=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 8f8214f65467cde97161a5fd9edab5b1543b333e) --- .../components/SelectionToolbar.kt | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/components/SelectionToolbar.kt b/app/src/main/java/eu/kanade/presentation/components/SelectionToolbar.kt index 76a585291..432ee1079 100644 --- a/app/src/main/java/eu/kanade/presentation/components/SelectionToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/components/SelectionToolbar.kt @@ -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().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,