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:
Cuong-Tran 2024-06-24 01:09:53 +07:00
parent 4726126c6b
commit e326358523
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
4 changed files with 35 additions and 2 deletions

View file

@ -47,6 +47,8 @@ class UiPreferences(
// KMK -->
fun expandRelatedTitles() = preferenceStore.getBoolean("expand_related_titles", true)
fun showHomeOnRelatedTitles() = preferenceStore.getBoolean("show_home_on_related_titles", true)
// KMK <--
fun recommendsInOverflow() = preferenceStore.getBoolean("recommends_in_overflow", false)

View file

@ -1,7 +1,9 @@
package eu.kanade.presentation.manga.components
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.Download
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.text.style.TextOverflow
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.AppBarActions
import eu.kanade.presentation.components.DownloadDropdownMenu
import eu.kanade.presentation.components.UpIcon
import eu.kanade.presentation.manga.DownloadAction
import eu.kanade.tachiyomi.ui.manga.MangaScreen
import eu.kanade.tachiyomi.util.system.isDevFlavor
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.i18n.sy.SYMR
import tachiyomi.presentation.core.i18n.stringResource
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
@Composable
fun MangaToolbar(
@ -60,6 +67,11 @@ fun MangaToolbar(
onPaletteScreenClick: () -> Unit,
// KMK <--
) {
// KMK -->
val navigator = LocalNavigator.current
fun onHomeClicked() = navigator?.popUntil { screen -> screen !is MangaScreen }
val isHomeEnabled = Injekt.get<UiPreferences>().showHomeOnRelatedTitles().get()
// KMK <--
Column(
modifier = modifier,
) {
@ -74,8 +86,19 @@ fun MangaToolbar(
)
},
navigationIcon = {
IconButton(onClick = onBackClicked) {
UpIcon(navigationIcon = Icons.Outlined.Close.takeIf { isActionMode })
Row {
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 = {

View file

@ -236,6 +236,12 @@ object SettingsAppearanceScreen : SearchableSettings {
subtitle = stringResource(KMR.strings.pref_expand_related_titles_summary),
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 <--
Preference.PreferenceItem.SwitchPreference(
pref = uiPreferences.recommendsInOverflow(),

View file

@ -22,6 +22,8 @@
<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_summary">If turned off, related titles won\'t automatically load &amp; 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 -->
<string name="ext_unofficial">Unofficial</string>