feat: Add option to show home icon on related titles
Add an option to show a home icon while browsing related titles, allowing users to navigate directly back to home screen.
This commit is contained in:
parent
4726126c6b
commit
e326358523
4 changed files with 35 additions and 2 deletions
|
|
@ -47,6 +47,8 @@ class UiPreferences(
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
fun expandRelatedTitles() = preferenceStore.getBoolean("expand_related_titles", true)
|
fun expandRelatedTitles() = preferenceStore.getBoolean("expand_related_titles", true)
|
||||||
|
|
||||||
|
fun showHomeOnRelatedTitles() = preferenceStore.getBoolean("show_home_on_related_titles", true)
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
||||||
fun recommendsInOverflow() = preferenceStore.getBoolean("recommends_in_overflow", false)
|
fun recommendsInOverflow() = preferenceStore.getBoolean("recommends_in_overflow", false)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package eu.kanade.presentation.manga.components
|
package eu.kanade.presentation.manga.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Home
|
||||||
import androidx.compose.material.icons.outlined.Close
|
import androidx.compose.material.icons.outlined.Close
|
||||||
import androidx.compose.material.icons.outlined.Download
|
import androidx.compose.material.icons.outlined.Download
|
||||||
import androidx.compose.material.icons.outlined.FlipToBack
|
import androidx.compose.material.icons.outlined.FlipToBack
|
||||||
|
|
@ -21,16 +23,21 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
|
import eu.kanade.domain.ui.UiPreferences
|
||||||
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.UpIcon
|
import eu.kanade.presentation.components.UpIcon
|
||||||
import eu.kanade.presentation.manga.DownloadAction
|
import eu.kanade.presentation.manga.DownloadAction
|
||||||
|
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||||
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.sy.SYMR
|
import tachiyomi.i18n.sy.SYMR
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MangaToolbar(
|
fun MangaToolbar(
|
||||||
|
|
@ -60,6 +67,11 @@ fun MangaToolbar(
|
||||||
onPaletteScreenClick: () -> Unit,
|
onPaletteScreenClick: () -> Unit,
|
||||||
// KMK <--
|
// KMK <--
|
||||||
) {
|
) {
|
||||||
|
// KMK -->
|
||||||
|
val navigator = LocalNavigator.current
|
||||||
|
fun onHomeClicked() = navigator?.popUntil { screen -> screen !is MangaScreen }
|
||||||
|
val isHomeEnabled = Injekt.get<UiPreferences>().showHomeOnRelatedTitles().get()
|
||||||
|
// KMK <--
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
|
|
@ -74,8 +86,19 @@ fun MangaToolbar(
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = onBackClicked) {
|
Row {
|
||||||
UpIcon(navigationIcon = Icons.Outlined.Close.takeIf { isActionMode })
|
IconButton(onClick = onBackClicked) {
|
||||||
|
UpIcon(navigationIcon = Icons.Outlined.Close.takeIf { isActionMode })
|
||||||
|
}
|
||||||
|
// KMK -->
|
||||||
|
navigator?.let {
|
||||||
|
if (isHomeEnabled && navigator.size >= 3) {
|
||||||
|
IconButton(onClick = { onHomeClicked() }) {
|
||||||
|
UpIcon(navigationIcon = Icons.Filled.Home)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// KMK <--
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,12 @@ object SettingsAppearanceScreen : SearchableSettings {
|
||||||
subtitle = stringResource(KMR.strings.pref_expand_related_titles_summary),
|
subtitle = stringResource(KMR.strings.pref_expand_related_titles_summary),
|
||||||
enabled = sourcePreferences.relatedMangas().get(),
|
enabled = sourcePreferences.relatedMangas().get(),
|
||||||
),
|
),
|
||||||
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
|
pref = uiPreferences.showHomeOnRelatedTitles(),
|
||||||
|
title = stringResource(KMR.strings.pref_show_home_on_related_titles),
|
||||||
|
subtitle = stringResource(KMR.strings.pref_show_home_on_related_titles_summary),
|
||||||
|
enabled = sourcePreferences.relatedMangas().get(),
|
||||||
|
),
|
||||||
// KMK <--
|
// KMK <--
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
pref = uiPreferences.recommendsInOverflow(),
|
pref = uiPreferences.recommendsInOverflow(),
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
<string name="pref_theme_cover_based_style_content">Content</string>
|
<string name="pref_theme_cover_based_style_content">Content</string>
|
||||||
<string name="pref_expand_related_titles">Expand Related titles</string>
|
<string name="pref_expand_related_titles">Expand Related titles</string>
|
||||||
<string name="pref_expand_related_titles_summary">If turned off, related titles won\'t automatically load & show expanded</string>
|
<string name="pref_expand_related_titles_summary">If turned off, related titles won\'t automatically load & show expanded</string>
|
||||||
|
<string name="pref_show_home_on_related_titles">Home from Related titles</string>
|
||||||
|
<string name="pref_show_home_on_related_titles_summary">Show an icon while browsing Related titles to navigate directly back to Home</string>
|
||||||
|
|
||||||
<!-- Extension section -->
|
<!-- Extension section -->
|
||||||
<string name="ext_unofficial">Unofficial</string>
|
<string name="ext_unofficial">Unofficial</string>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue