Refactor AppBarActions and clean up code (#1635)
* remove parentheses * Refactor AppBarActions to improve readability and maintainability * Refactor callback parameters in AppBar actions for clarity
This commit is contained in:
parent
dc3d034109
commit
21cb1921a3
6 changed files with 108 additions and 112 deletions
|
|
@ -336,15 +336,14 @@ fun SourceFeedToolbar(
|
|||
// KMK -->
|
||||
actions = {
|
||||
AppBarActions(
|
||||
actions = persistentListOf<AppBar.AppBarAction>().builder()
|
||||
.apply {
|
||||
actions = persistentListOf<AppBar.AppBarAction>().builder().apply {
|
||||
add(bulkSelectionButton(isRunning, toggleSelectionMode))
|
||||
|
||||
onWebViewClick?.let {
|
||||
onWebViewClick?.let { func ->
|
||||
add(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.action_web_view),
|
||||
onClick = { onWebViewClick() },
|
||||
onClick = { func() },
|
||||
icon = Icons.Outlined.Public,
|
||||
),
|
||||
)
|
||||
|
|
@ -359,20 +358,20 @@ fun SourceFeedToolbar(
|
|||
)
|
||||
// KMK <--
|
||||
|
||||
onSortFeedClick?.let {
|
||||
onSortFeedClick?.let { func ->
|
||||
add(
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(KMR.strings.action_sort_feed),
|
||||
onClick = { onSortFeedClick() },
|
||||
onClick = { func() },
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
onSourceSettingClick?.let {
|
||||
onSourceSettingClick?.let { func ->
|
||||
add(
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.label_settings),
|
||||
onClick = { onSourceSettingClick() },
|
||||
onClick = { func() },
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ fun BrowseSourceEHentaiListItem(
|
|||
MangaCoverHide.Book(
|
||||
modifier = Modifier
|
||||
.fillMaxHeight(),
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
)
|
||||
} else {
|
||||
|
|
@ -219,7 +219,7 @@ fun BrowseSourceEHentaiListItem(
|
|||
.fillMaxHeight(),
|
||||
// KMK -->
|
||||
alpha = if (isSelected) GRID_SELECTED_COVER_ALPHA else coverAlpha,
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
// KMK <--
|
||||
data = coverData,
|
||||
|
|
|
|||
|
|
@ -39,13 +39,12 @@ fun BrowseSourceSimpleToolbar(
|
|||
var selectingDisplayMode by remember { mutableStateOf(false) }
|
||||
// KMK -->
|
||||
AppBarActions(
|
||||
actions = persistentListOf<AppBar.AppBarAction>().builder()
|
||||
.apply {
|
||||
displayMode?.let {
|
||||
actions = persistentListOf<AppBar.AppBarAction>().builder().apply {
|
||||
displayMode?.let { mode ->
|
||||
add(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.action_display_mode),
|
||||
icon = if (displayMode == LibraryDisplayMode.List) {
|
||||
icon = if (mode == LibraryDisplayMode.List) {
|
||||
Icons.AutoMirrored.Filled.ViewList
|
||||
} else {
|
||||
Icons.Filled.ViewModule
|
||||
|
|
@ -54,9 +53,9 @@ fun BrowseSourceSimpleToolbar(
|
|||
),
|
||||
)
|
||||
}
|
||||
toggleSelectionMode?.let {
|
||||
toggleSelectionMode?.let { mode ->
|
||||
add(
|
||||
bulkSelectionButton(isRunning, toggleSelectionMode),
|
||||
bulkSelectionButton(isRunning, mode),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ fun BulkSelectionToolbar(
|
|||
titleContent = { Text(text = "$selectedCount") },
|
||||
actions = {
|
||||
AppBarActions(
|
||||
actions = persistentListOf<AppBar.AppBarAction>()
|
||||
.builder()
|
||||
.apply {
|
||||
actions = persistentListOf<AppBar.AppBarAction>().builder().apply {
|
||||
if (onSelectAll != null) {
|
||||
add(
|
||||
AppBar.Action(
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ fun MangaCompactGridItem(
|
|||
MangaCoverHide.Book(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
)
|
||||
} else {
|
||||
|
|
@ -119,7 +119,7 @@ fun MangaCompactGridItem(
|
|||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = if (isSelected) GRID_SELECTED_COVER_ALPHA else coverAlpha,
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
// KMK <--
|
||||
)
|
||||
|
|
@ -241,7 +241,7 @@ fun MangaComfortableGridItem(
|
|||
MangaCoverHide.Book(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
)
|
||||
} else {
|
||||
|
|
@ -255,7 +255,7 @@ fun MangaComfortableGridItem(
|
|||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = if (isSelected) GRID_SELECTED_COVER_ALPHA else coverAlpha,
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
onCoverLoaded = { _, result ->
|
||||
val image = result.result.image
|
||||
|
|
@ -274,7 +274,7 @@ fun MangaComfortableGridItem(
|
|||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = if (isSelected) GRID_SELECTED_COVER_ALPHA else coverAlpha,
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
onCoverLoaded = { _, result ->
|
||||
val image = result.result.image
|
||||
|
|
@ -461,7 +461,7 @@ fun MangaListItem(
|
|||
MangaCoverHide.Square(
|
||||
modifier = Modifier
|
||||
.fillMaxHeight(),
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
)
|
||||
} else {
|
||||
|
|
@ -475,7 +475,7 @@ fun MangaListItem(
|
|||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = coverAlpha,
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { isSelected },
|
||||
tint = onBgColor,
|
||||
size = MangaCover.Size.Big,
|
||||
// KMK <--
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ private fun UpdatesUiItem(
|
|||
MangaCoverHide.Book(
|
||||
modifier = Modifier
|
||||
.width(UpdateItemWidth),
|
||||
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { selected }),
|
||||
bgColor = bgColor ?: MaterialTheme.colorScheme.surface.takeIf { selected },
|
||||
tint = onBgColor,
|
||||
size = MangaCover.Size.Medium,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue