Skip to content

Commit

Permalink
Add Hide Feed tab toggle (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riztard authored and cuong-tran committed Feb 19, 2024
1 parent 65c3c07 commit 729cea1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/eu/kanade/domain/ui/UiPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,6 +42,8 @@ object SettingsBrowseScreen : SearchableSettings {
val reposCount by sourcePreferences.extensionRepos().collectAsState()

// SY -->
val scope = rememberCoroutineScope()
val hideFeedTab by remember { Injekt.get<UiPreferences>().hideFeedTab().asState(scope) }
val uiPreferences = remember { Injekt.get<UiPreferences>() }
val unsortedPreferences = remember { Injekt.get<UnsortedPreferences>() }
// SY <--
Expand Down Expand Up @@ -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()
),
),
),
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/eu/kanade/tachiyomi/ui/browse/BrowseTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ data class BrowseTab(
val context = LocalContext.current
val scope = rememberCoroutineScope()
// SY -->
val feedTabInFront by remember {
Injekt.get<UiPreferences>().feedTabInFront().asState(scope)
}
val hideFeedTab by remember { Injekt.get<UiPreferences>().hideFeedTab().asState(scope) }
val feedTabInFront by remember { Injekt.get<UiPreferences>().feedTabInFront().asState(scope) }
// SY <--

// Hoisted for extensions tab's search bar
Expand All @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions i18n-sy/src/commonMain/resources/MR/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
<string name="library_group_updates_all">Launch category updates all the time</string>

<!-- 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_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>
Expand Down

0 comments on commit 729cea1

Please sign in to comment.