Add Hide Feed tab toggle (#1058)

This commit is contained in:
Luqman 2024-02-18 03:50:38 +07:00 committed by GitHub
parent c835140fe8
commit aebc15d4e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 4 deletions

View File

@ -38,6 +38,8 @@ class UiPreferences(
fun expandFilters() = preferenceStore.getBoolean("eh_expand_filters", false) 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 feedTabInFront() = preferenceStore.getBoolean("latest_tab_position", false)
fun recommendsInOverflow() = preferenceStore.getBoolean("recommends_in_overflow", false) fun recommendsInOverflow() = preferenceStore.getBoolean("recommends_in_overflow", false)

View File

@ -4,10 +4,12 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.core.preference.asState
import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.source.service.SourcePreferences
import eu.kanade.domain.ui.UiPreferences import eu.kanade.domain.ui.UiPreferences
import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.more.settings.Preference
@ -40,6 +42,8 @@ object SettingsBrowseScreen : SearchableSettings {
val reposCount by sourcePreferences.extensionRepos().collectAsState() val reposCount by sourcePreferences.extensionRepos().collectAsState()
// SY --> // SY -->
val scope = rememberCoroutineScope()
val hideFeedTab by remember { Injekt.get<UiPreferences>().hideFeedTab().asState(scope) }
val uiPreferences = remember { Injekt.get<UiPreferences>() } val uiPreferences = remember { Injekt.get<UiPreferences>() }
val unsortedPreferences = remember { Injekt.get<UnsortedPreferences>() } val unsortedPreferences = remember { Injekt.get<UnsortedPreferences>() }
// SY <-- // SY <--
@ -78,10 +82,15 @@ object SettingsBrowseScreen : SearchableSettings {
Preference.PreferenceGroup( Preference.PreferenceGroup(
title = stringResource(SYMR.strings.feed), title = stringResource(SYMR.strings.feed),
preferenceItems = persistentListOf( preferenceItems = persistentListOf(
Preference.PreferenceItem.SwitchPreference(
pref = uiPreferences.hideFeedTab(),
title = stringResource(SYMR.strings.pref_hide_feed),
),
Preference.PreferenceItem.SwitchPreference( Preference.PreferenceItem.SwitchPreference(
pref = uiPreferences.feedTabInFront(), pref = uiPreferences.feedTabInFront(),
title = stringResource(SYMR.strings.pref_feed_position), title = stringResource(SYMR.strings.pref_feed_position),
subtitle = stringResource(SYMR.strings.pref_feed_position_summery), subtitle = stringResource(SYMR.strings.pref_feed_position_summery),
enabled = hideFeedTab.not()
), ),
), ),
), ),

View File

@ -57,9 +57,8 @@ data class BrowseTab(
val context = LocalContext.current val context = LocalContext.current
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
// SY --> // SY -->
val feedTabInFront by remember { val hideFeedTab by remember { Injekt.get<UiPreferences>().hideFeedTab().asState(scope) }
Injekt.get<UiPreferences>().feedTabInFront().asState(scope) val feedTabInFront by remember { Injekt.get<UiPreferences>().feedTabInFront().asState(scope) }
}
// SY <-- // SY <--
// Hoisted for extensions tab's search bar // Hoisted for extensions tab's search bar
@ -69,7 +68,13 @@ data class BrowseTab(
TabbedScreen( TabbedScreen(
titleRes = MR.strings.browse, titleRes = MR.strings.browse,
// SY --> // SY -->
tabs = if (feedTabInFront) { tabs = if (hideFeedTab) {
persistentListOf(
sourcesTab(),
extensionsTab(extensionsScreenModel),
migrateSourceTab(),
)
} else if (feedTabInFront) {
persistentListOf( persistentListOf(
feedTab(), feedTab(),
sourcesTab(), sourcesTab(),

View File

@ -184,6 +184,7 @@
<string name="library_group_updates_all">Launch category updates all the time</string> <string name="library_group_updates_all">Launch category updates all the time</string>
<!-- Browse settings --> <!-- Browse settings -->
<string name="pref_hide_feed">Hide Feed tab</string>
<string name="pref_feed_position">Feed tab position</string> <string name="pref_feed_position">Feed tab position</string>
<string name="pref_feed_position_summery">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</string> <string name="pref_feed_position_summery">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</string>
<string name="pref_source_source_filtering">Filter sources in categories</string> <string name="pref_source_source_filtering">Filter sources in categories</string>