From 729cea16119a71fa6fde8d04ebe37cbbf421a9c2 Mon Sep 17 00:00:00 2001 From: Luqman <16263232+Riztard@users.noreply.github.com> Date: Sun, 18 Feb 2024 03:50:38 +0700 Subject: [PATCH] Add Hide Feed tab toggle (#1058) --- .../main/java/eu/kanade/domain/ui/UiPreferences.kt | 2 ++ .../more/settings/screen/SettingsBrowseScreen.kt | 9 +++++++++ .../java/eu/kanade/tachiyomi/ui/browse/BrowseTab.kt | 13 +++++++++---- .../src/commonMain/resources/MR/base/strings.xml | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt b/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt index ec29e392e3..7e0cc65b78 100644 --- a/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt +++ b/app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt @@ -38,6 +38,8 @@ class UiPreferences( fun expandFilters() = preferenceStore.getBoolean("eh_expand_filters", false) + fun hideFeedTab() = preferenceStore.getBoolean("hide_latest_tab", false) + fun feedTabInFront() = preferenceStore.getBoolean("latest_tab_position", false) fun recommendsInOverflow() = preferenceStore.getBoolean("recommends_in_overflow", false) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt index 7fc40f8df8..4deff07a2b 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt @@ -4,10 +4,12 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.platform.LocalContext import androidx.fragment.app.FragmentActivity import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.core.preference.asState import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.ui.UiPreferences import eu.kanade.presentation.more.settings.Preference @@ -40,6 +42,8 @@ object SettingsBrowseScreen : SearchableSettings { val reposCount by sourcePreferences.extensionRepos().collectAsState() // SY --> + val scope = rememberCoroutineScope() + val hideFeedTab by remember { Injekt.get().hideFeedTab().asState(scope) } val uiPreferences = remember { Injekt.get() } val unsortedPreferences = remember { Injekt.get() } // SY <-- @@ -78,10 +82,15 @@ object SettingsBrowseScreen : SearchableSettings { Preference.PreferenceGroup( title = stringResource(SYMR.strings.feed), preferenceItems = persistentListOf( + Preference.PreferenceItem.SwitchPreference( + pref = uiPreferences.hideFeedTab(), + title = stringResource(SYMR.strings.pref_hide_feed), + ), Preference.PreferenceItem.SwitchPreference( pref = uiPreferences.feedTabInFront(), title = stringResource(SYMR.strings.pref_feed_position), subtitle = stringResource(SYMR.strings.pref_feed_position_summery), + enabled = hideFeedTab.not() ), ), ), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseTab.kt index ec9daa07cf..20c9e79d6a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseTab.kt @@ -57,9 +57,8 @@ data class BrowseTab( val context = LocalContext.current val scope = rememberCoroutineScope() // SY --> - val feedTabInFront by remember { - Injekt.get().feedTabInFront().asState(scope) - } + val hideFeedTab by remember { Injekt.get().hideFeedTab().asState(scope) } + val feedTabInFront by remember { Injekt.get().feedTabInFront().asState(scope) } // SY <-- // Hoisted for extensions tab's search bar @@ -69,7 +68,13 @@ data class BrowseTab( TabbedScreen( titleRes = MR.strings.browse, // SY --> - tabs = if (feedTabInFront) { + tabs = if (hideFeedTab) { + persistentListOf( + sourcesTab(), + extensionsTab(extensionsScreenModel), + migrateSourceTab(), + ) + } else if (feedTabInFront) { persistentListOf( feedTab(), sourcesTab(), diff --git a/i18n-sy/src/commonMain/resources/MR/base/strings.xml b/i18n-sy/src/commonMain/resources/MR/base/strings.xml index 8304c6f8f1..a3a273cc49 100644 --- a/i18n-sy/src/commonMain/resources/MR/base/strings.xml +++ b/i18n-sy/src/commonMain/resources/MR/base/strings.xml @@ -184,6 +184,7 @@ Launch category updates all the time + Hide Feed tab Feed tab position Do you want the feed tab to be the first tab in browse? This will make it the default tab when opening browse, not recommended if you\'re on data or a metered network Filter sources in categories