From 2368c50ebb7405a1b3978a6f2eb97b61e395b1af Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 26 Feb 2023 10:23:07 -0500 Subject: [PATCH] Add menu shortcut to source settings in BrowseSourceScreen Adapted from TachiyomiSY. Co-authored-by: jobobby04 --- .../browse/components/BrowseSourceToolbar.kt | 23 +++++++++++-------- .../source/browse/BrowseSourceScreen.kt | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt index e0d4bc51a9..508cccbef4 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/components/BrowseSourceToolbar.kt @@ -3,8 +3,6 @@ package eu.kanade.presentation.browse.components import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ViewList import androidx.compose.material.icons.filled.ViewModule -import androidx.compose.material.icons.outlined.Help -import androidx.compose.material.icons.outlined.Public import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable @@ -20,6 +18,7 @@ import eu.kanade.presentation.components.DropdownMenu import eu.kanade.presentation.components.RadioMenuItem import eu.kanade.presentation.components.SearchToolbar import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.Source import tachiyomi.domain.library.model.LibraryDisplayMode @@ -34,12 +33,16 @@ fun BrowseSourceToolbar( navigateUp: () -> Unit, onWebViewClick: () -> Unit, onHelpClick: () -> Unit, + onSettingsClick: () -> Unit, onSearch: (String) -> Unit, scrollBehavior: TopAppBarScrollBehavior? = null, ) { // Avoid capturing unstable source in actions lambda val title = source?.name val isLocalSource = source is LocalSource + val isConfigurableSource = source is ConfigurableSource + + var selectingDisplayMode by remember { mutableStateOf(false) } SearchToolbar( navigateUp = navigateUp, @@ -49,29 +52,31 @@ fun BrowseSourceToolbar( onSearch = onSearch, onClickCloseSearch = navigateUp, actions = { - var selectingDisplayMode by remember { mutableStateOf(false) } AppBarActions( - actions = listOf( + actions = listOfNotNull( AppBar.Action( title = stringResource(R.string.action_display_mode), icon = if (displayMode == LibraryDisplayMode.List) Icons.Filled.ViewList else Icons.Filled.ViewModule, onClick = { selectingDisplayMode = true }, ), if (isLocalSource) { - AppBar.Action( + AppBar.OverflowAction( title = stringResource(R.string.label_help), - icon = Icons.Outlined.Help, onClick = onHelpClick, ) } else { - AppBar.Action( - title = stringResource(R.string.action_web_view), - icon = Icons.Outlined.Public, + AppBar.OverflowAction( + title = stringResource(R.string.action_open_in_web_view), onClick = onWebViewClick, ) }, + AppBar.OverflowAction( + title = stringResource(R.string.action_settings), + onClick = onSettingsClick, + ).takeIf { isConfigurableSource }, ), ) + DropdownMenu( expanded = selectingDisplayMode, onDismissRequest = { selectingDisplayMode = false }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt index 6e5342cbf7..e8a01a8f1d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt @@ -48,6 +48,7 @@ import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.online.HttpSource +import eu.kanade.tachiyomi.ui.browse.extension.details.SourcePreferencesScreen import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreenModel.Listing import eu.kanade.tachiyomi.ui.category.CategoryScreen import eu.kanade.tachiyomi.ui.manga.MangaScreen @@ -124,6 +125,7 @@ data class BrowseSourceScreen( navigateUp = navigateUp, onWebViewClick = onWebViewClick, onHelpClick = onHelpClick, + onSettingsClick = { navigator.push(SourcePreferencesScreen(sourceId)) }, onSearch = { screenModel.search(it) }, )