renovate: move SelectionToolbar to its own component

This commit is contained in:
Cuong M. Tran 2024-03-07 11:29:58 +07:00 committed by Cuong Tran
parent 2df7f13e4e
commit 8d46ab8fc2
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
6 changed files with 54 additions and 67 deletions

View file

@ -4,7 +4,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ViewList
import androidx.compose.material.icons.automirrored.outlined.Help
import androidx.compose.material.icons.filled.ViewModule
import androidx.compose.material.icons.outlined.BookmarkAdd
import androidx.compose.material.icons.outlined.Checklist
import androidx.compose.material.icons.outlined.Public
import androidx.compose.material3.Text
@ -178,32 +177,3 @@ fun BrowseSourceToolbar(
scrollBehavior = scrollBehavior,
)
}
// KMK -->
@Composable
fun SelectionToolbar(
selectedCount: Int,
onClickClearSelection: () -> Unit = {},
onChangeCategoryClicked: () -> Unit = {},
) {
AppBar(
titleContent = { Text(text = "$selectedCount") },
actions = {
AppBarActions(
persistentListOf(
AppBar.Action(
title = stringResource(MR.strings.action_bookmark),
icon = Icons.Outlined.BookmarkAdd,
onClick = {
if (selectedCount > 0)
onChangeCategoryClicked()
},
),
),
)
},
isActionMode = true,
onCancelActionMode = onClickClearSelection,
)
}
// KMK <--

View file

@ -31,7 +31,7 @@ fun GlobalSearchCardRow(
onClick: (Manga) -> Unit,
onLongClick: (Manga) -> Unit,
// KMK -->
selection: List<Manga>? = null,
selection: List<Manga>,
// KMK <--
) {
if (titles.isEmpty()) {
@ -52,7 +52,7 @@ fun GlobalSearchCardRow(
onClick = { onClick(title) },
onLongClick = { onLongClick(title) },
// KMK -->
isSelected = selection?.fastAny { selected -> selected.id == title.id } ?: false,
isSelected = selection.fastAny { selected -> selected.id == title.id },
// KMK <--
)
}

View file

@ -0,0 +1,47 @@
package eu.kanade.presentation.components
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.BookmarkAdd
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
@Composable
fun SelectionToolbar(
selectedCount: Int,
onClickClearSelection: () -> Unit,
onChangeCategoryClicked: () -> Unit,
) {
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()
},
),
),
)
},
isActionMode = true,
onCancelActionMode = onClickClearSelection,
)
}
@Preview
@Composable
fun SelectionToolbarPreview() {
SelectionToolbar(
selectedCount = 9,
{},
{},
)
}

View file

@ -8,14 +8,11 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.BookmarkAdd
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.PrimaryTabRow
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
@ -31,7 +28,6 @@ import eu.kanade.tachiyomi.ui.browse.feed.FeedScreenModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.launch
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.components.material.TabText
import tachiyomi.presentation.core.i18n.stringResource
@ -126,29 +122,3 @@ data class TabContent(
val actions: ImmutableList<AppBar.AppBarAction> = persistentListOf(),
val content: @Composable (contentPadding: PaddingValues, snackbarHostState: SnackbarHostState) -> Unit,
)
// KMK -->
@Composable
private fun SelectionToolbar(
selectedCount: Int,
onClickClearSelection: () -> Unit = {},
onChangeCategoryClicked: () -> Unit = {},
) {
AppBar(
titleContent = { Text(text = "$selectedCount") },
actions = {
AppBarActions(
persistentListOf(
AppBar.Action(
title = stringResource(MR.strings.action_bookmark),
icon = Icons.Outlined.BookmarkAdd,
onClick = onChangeCategoryClicked,
),
),
)
},
isActionMode = true,
onCancelActionMode = onClickClearSelection,
)
}
// KMK <--

View file

@ -67,10 +67,10 @@ fun AllowDuplicateDialog(
onDismissRequest: () -> Unit,
onAllowAllDuplicate: () -> Unit,
onSkipAllDuplicate: () -> Unit,
onOpenManga: () -> Unit = {},
onAllowDuplicate: () -> Unit = {},
onSkipDuplicate: () -> Unit = {},
duplicatedName: String = "",
onOpenManga: () -> Unit,
onAllowDuplicate: () -> Unit,
onSkipDuplicate: () -> Unit,
duplicatedName: String,
) {
AlertDialog(
onDismissRequest = onDismissRequest,

View file

@ -43,8 +43,8 @@ import eu.kanade.presentation.browse.components.BrowseSourceToolbar
import eu.kanade.presentation.browse.components.RemoveMangaDialog
import eu.kanade.presentation.browse.components.SavedSearchCreateDialog
import eu.kanade.presentation.browse.components.SavedSearchDeleteDialog
import eu.kanade.presentation.browse.components.SelectionToolbar
import eu.kanade.presentation.category.components.ChangeCategoryDialog
import eu.kanade.presentation.components.SelectionToolbar
import eu.kanade.presentation.manga.AllowDuplicateDialog
import eu.kanade.presentation.manga.DuplicateMangaDialog
import eu.kanade.presentation.util.AssistContentScreen