Use AppBarActions in more places
This commit is contained in:
parent
0810d3db69
commit
44609c494c
4 changed files with 86 additions and 83 deletions
|
@ -16,6 +16,7 @@ import androidx.compose.material.icons.outlined.Search
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.PlainTooltipBox
|
import androidx.compose.material3.PlainTooltipBox
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -33,6 +34,7 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.SolidColor
|
import androidx.compose.ui.graphics.SolidColor
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
|
@ -190,6 +192,7 @@ fun AppBarActions(
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = it.icon,
|
imageVector = it.icon,
|
||||||
|
tint = it.iconTint ?: LocalContentColor.current,
|
||||||
contentDescription = it.title,
|
contentDescription = it.title,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -363,6 +366,7 @@ sealed interface AppBar {
|
||||||
data class Action(
|
data class Action(
|
||||||
val title: String,
|
val title: String,
|
||||||
val icon: ImageVector,
|
val icon: ImageVector,
|
||||||
|
val iconTint: Color? = null,
|
||||||
val onClick: () -> Unit,
|
val onClick: () -> Unit,
|
||||||
val enabled: Boolean = true,
|
val enabled: Boolean = true,
|
||||||
) : AppBarAction
|
) : AppBarAction
|
||||||
|
|
|
@ -6,9 +6,6 @@ import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.FilterList
|
import androidx.compose.material.icons.outlined.FilterList
|
||||||
import androidx.compose.material.icons.outlined.FlipToBack
|
import androidx.compose.material.icons.outlined.FlipToBack
|
||||||
import androidx.compose.material.icons.outlined.SelectAll
|
import androidx.compose.material.icons.outlined.SelectAll
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -22,7 +19,6 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import eu.kanade.presentation.components.AppBar
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.components.AppBarActions
|
import eu.kanade.presentation.components.AppBarActions
|
||||||
import eu.kanade.presentation.components.OverflowMenu
|
|
||||||
import eu.kanade.presentation.components.SearchToolbar
|
import eu.kanade.presentation.components.SearchToolbar
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import tachiyomi.presentation.core.components.Pill
|
import tachiyomi.presentation.core.components.Pill
|
||||||
|
@ -98,33 +94,28 @@ private fun LibraryRegularToolbar(
|
||||||
onChangeSearchQuery = onSearchQueryChange,
|
onChangeSearchQuery = onSearchQueryChange,
|
||||||
actions = {
|
actions = {
|
||||||
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
||||||
IconButton(onClick = onClickFilter) {
|
AppBarActions(
|
||||||
Icon(Icons.Outlined.FilterList, contentDescription = stringResource(R.string.action_filter), tint = filterTint)
|
listOf(
|
||||||
}
|
AppBar.Action(
|
||||||
|
title = stringResource(R.string.action_filter),
|
||||||
OverflowMenu { closeMenu ->
|
icon = Icons.Outlined.FilterList,
|
||||||
DropdownMenuItem(
|
iconTint = filterTint,
|
||||||
text = { Text(text = stringResource(R.string.action_update_library)) },
|
onClick = onClickFilter,
|
||||||
onClick = {
|
),
|
||||||
onClickGlobalUpdate()
|
AppBar.OverflowAction(
|
||||||
closeMenu()
|
title = stringResource(R.string.action_update_library),
|
||||||
},
|
onClick = onClickGlobalUpdate,
|
||||||
|
),
|
||||||
|
AppBar.OverflowAction(
|
||||||
|
title = stringResource(R.string.action_update_category),
|
||||||
|
onClick = onClickRefresh,
|
||||||
|
),
|
||||||
|
AppBar.OverflowAction(
|
||||||
|
title = stringResource(R.string.action_open_random_manga),
|
||||||
|
onClick = onClickOpenRandomManga,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(text = stringResource(R.string.action_update_category)) },
|
|
||||||
onClick = {
|
|
||||||
onClickRefresh()
|
|
||||||
closeMenu()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(text = stringResource(R.string.action_open_random_manga)) },
|
|
||||||
onClick = {
|
|
||||||
onClickOpenRandomManga()
|
|
||||||
closeMenu()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
scrollBehavior = scrollBehavior,
|
scrollBehavior = scrollBehavior,
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,6 +43,8 @@ import coil.imageLoader
|
||||||
import coil.request.CachePolicy
|
import coil.request.CachePolicy
|
||||||
import coil.request.ImageRequest
|
import coil.request.ImageRequest
|
||||||
import coil.size.Size
|
import coil.size.Size
|
||||||
|
import eu.kanade.presentation.components.AppBar
|
||||||
|
import eu.kanade.presentation.components.AppBarActions
|
||||||
import eu.kanade.presentation.components.DropdownMenu
|
import eu.kanade.presentation.components.DropdownMenu
|
||||||
import eu.kanade.presentation.manga.EditCoverAction
|
import eu.kanade.presentation.manga.EditCoverAction
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
@ -88,18 +90,24 @@ fun MangaCoverDialog(
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
ActionsPill {
|
ActionsPill {
|
||||||
IconButton(onClick = onShareClick) {
|
AppBarActions(
|
||||||
Icon(
|
actions = buildList {
|
||||||
imageVector = Icons.Outlined.Share,
|
add(
|
||||||
contentDescription = stringResource(R.string.action_share),
|
AppBar.Action(
|
||||||
|
title = stringResource(R.string.action_share),
|
||||||
|
icon = Icons.Outlined.Share,
|
||||||
|
onClick = onShareClick,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
add(
|
||||||
IconButton(onClick = onSaveClick) {
|
AppBar.Action(
|
||||||
Icon(
|
title = stringResource(R.string.action_save),
|
||||||
imageVector = Icons.Outlined.Save,
|
icon = Icons.Outlined.Save,
|
||||||
contentDescription = stringResource(R.string.action_save),
|
onClick = onSaveClick,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
if (onEditClick != null) {
|
if (onEditClick != null) {
|
||||||
Box {
|
Box {
|
||||||
var expanded by remember { mutableStateOf(false) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
|
|
@ -9,7 +9,6 @@ import androidx.compose.material.icons.outlined.Download
|
||||||
import androidx.compose.material.icons.outlined.FilterList
|
import androidx.compose.material.icons.outlined.FilterList
|
||||||
import androidx.compose.material.icons.outlined.FlipToBack
|
import androidx.compose.material.icons.outlined.FlipToBack
|
||||||
import androidx.compose.material.icons.outlined.SelectAll
|
import androidx.compose.material.icons.outlined.SelectAll
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
|
@ -29,7 +28,6 @@ import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.presentation.components.AppBar
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.components.AppBarActions
|
import eu.kanade.presentation.components.AppBarActions
|
||||||
import eu.kanade.presentation.components.DownloadDropdownMenu
|
import eu.kanade.presentation.components.DownloadDropdownMenu
|
||||||
import eu.kanade.presentation.components.OverflowMenu
|
|
||||||
import eu.kanade.presentation.manga.DownloadAction
|
import eu.kanade.presentation.manga.DownloadAction
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import tachiyomi.presentation.core.theme.active
|
import tachiyomi.presentation.core.theme.active
|
||||||
|
@ -110,46 +108,48 @@ fun MangaToolbar(
|
||||||
}
|
}
|
||||||
|
|
||||||
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
||||||
IconButton(onClick = onClickFilter) {
|
AppBarActions(
|
||||||
Icon(Icons.Outlined.FilterList, contentDescription = stringResource(R.string.action_filter), tint = filterTint)
|
actions = buildList {
|
||||||
}
|
add(
|
||||||
|
AppBar.Action(
|
||||||
OverflowMenu { closeMenu ->
|
title = stringResource(R.string.action_filter),
|
||||||
DropdownMenuItem(
|
icon = Icons.Outlined.FilterList,
|
||||||
text = { Text(text = stringResource(R.string.action_webview_refresh)) },
|
iconTint = filterTint,
|
||||||
onClick = {
|
onClick = onClickFilter,
|
||||||
onClickRefresh()
|
),
|
||||||
closeMenu()
|
)
|
||||||
},
|
add(
|
||||||
|
AppBar.OverflowAction(
|
||||||
|
title = stringResource(R.string.action_webview_refresh),
|
||||||
|
onClick = onClickRefresh,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
if (onClickEditCategory != null) {
|
if (onClickEditCategory != null) {
|
||||||
DropdownMenuItem(
|
add(
|
||||||
text = { Text(text = stringResource(R.string.action_edit_categories)) },
|
AppBar.OverflowAction(
|
||||||
onClick = {
|
title = stringResource(R.string.action_edit_categories),
|
||||||
onClickEditCategory()
|
onClick = onClickEditCategory,
|
||||||
closeMenu()
|
),
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (onClickMigrate != null) {
|
if (onClickMigrate != null) {
|
||||||
DropdownMenuItem(
|
add(
|
||||||
text = { Text(text = stringResource(R.string.action_migrate)) },
|
AppBar.OverflowAction(
|
||||||
onClick = {
|
title = stringResource(R.string.action_migrate),
|
||||||
onClickMigrate()
|
onClick = onClickMigrate,
|
||||||
closeMenu()
|
),
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (onClickShare != null) {
|
if (onClickShare != null) {
|
||||||
DropdownMenuItem(
|
add(
|
||||||
text = { Text(text = stringResource(R.string.action_share)) },
|
AppBar.OverflowAction(
|
||||||
onClick = {
|
title = stringResource(R.string.action_share),
|
||||||
onClickShare()
|
onClick = onClickShare,
|
||||||
closeMenu()
|
),
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
|
|
Reference in a new issue