Revert "Always enable predictive nav" (#616)

* Revert "Always enable predictive nav"

This reverts commit 0333a8c679.

* Disable predictive nav animations by default
This commit is contained in:
FooIbar authored and GitHub committed 2024-01-07 13:45:28 +00:00
1 parent 4ad5cef412
commit 045c6abe40
5 files changed
+18 -3

No files matched your search

@@ -29,6 +29,7 @@ import androidx.compose.animation.core.SeekableTransitionState
import androidx.compose.animation.core.rememberTransition import androidx.compose.animation.core.rememberTransition
import androidx.compose.animation.core.snap import androidx.compose.animation.core.snap
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith import androidx.compose.animation.togetherWith
@@ -55,6 +56,8 @@ import androidx.navigation.NavHostController
import androidx.navigation.Navigator import androidx.navigation.Navigator
import androidx.navigation.createGraph import androidx.navigation.createGraph
import androidx.navigation.get import androidx.navigation.get
import com.hippo.ehviewer.Settings
import com.hippo.ehviewer.collectAsState
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@@ -246,10 +249,15 @@ public fun NavHost(
val zIndices = remember { mutableMapOf<String, Float>() } val zIndices = remember { mutableMapOf<String, Float>() }
if (backStackEntry != null) { if (backStackEntry != null) {
val enablePredictiveBack by Settings.predictiveNavAnim.collectAsState()
val transitionState = remember { SeekableTransitionState(backStackEntry) } val transitionState = remember { SeekableTransitionState(backStackEntry) }
val transition = rememberTransition(transitionState, label = "entry") val transition = if (enablePredictiveBack) {
LaunchedEffect(backStackEntry) { LaunchedEffect(backStackEntry) {
transitionState.animateTo(backStackEntry) transitionState.animateTo(backStackEntry)
}
rememberTransition(transitionState, label = "entry")
} else {
updateTransition(backStackEntry, label = "entry")
} }
var inPredictiveBack by remember { mutableStateOf(false) } var inPredictiveBack by remember { mutableStateOf(false) }
@@ -109,6 +109,7 @@ object Settings : DataStorePreferences(null) {
val listThumbSize = intPref("list_tile_size", 40) val listThumbSize = intPref("list_tile_size", 40)
val languageFilter = intPref("language_filter", -1) val languageFilter = intPref("language_filter", -1)
val meteredNetworkWarning = boolPref("cellular_network_warning", false) val meteredNetworkWarning = boolPref("cellular_network_warning", false)
val predictiveNavAnim = boolPref("predictive_nav_anim_2", false)
val blackDarkTheme = boolPref("black_dark_theme", false) val blackDarkTheme = boolPref("black_dark_theme", false)
var downloadScheme by stringOrNullPref("image_scheme", null) var downloadScheme by stringOrNullPref("image_scheme", null)
@@ -179,6 +179,10 @@ fun AdvancedScreen(navigator: DestinationsNavigator) {
title = stringResource(id = R.string.preload_thumb_aggressively), title = stringResource(id = R.string.preload_thumb_aggressively),
value = Settings::preloadThumbAggressively, value = Settings::preloadThumbAggressively,
) )
SwitchPreference(
title = stringResource(id = R.string.predictive_nav_anim),
value = Settings.predictiveNavAnim::value,
)
IntSliderPreference( IntSliderPreference(
maxValue = 5, maxValue = 5,
minValue = 1, minValue = 1,
@@ -508,6 +508,7 @@
<string name="list_tile_thumb_size">详情模式下缩略图大小</string> <string name="list_tile_thumb_size">详情模式下缩略图大小</string>
<string name="account_name">账户</string> <string name="account_name">账户</string>
<string name="preload_thumb_aggressively">激进地预载缩略图</string> <string name="preload_thumb_aggressively">激进地预载缩略图</string>
<string name="predictive_nav_anim">[实验性] 预见式返回导航动画</string>
<string name="auto_updates">自动检查更新</string> <string name="auto_updates">自动检查更新</string>
<string name="update_frequency_never">从不</string> <string name="update_frequency_never">从不</string>
<string name="update_frequency_daily">每天</string> <string name="update_frequency_daily">每天</string>
+1
View File
@@ -571,6 +571,7 @@
<string name="list_tile_thumb_size">Thumb size in detail mode</string> <string name="list_tile_thumb_size">Thumb size in detail mode</string>
<string name="account_name">Account</string> <string name="account_name">Account</string>
<string name="preload_thumb_aggressively">Preload thumbs aggressively</string> <string name="preload_thumb_aggressively">Preload thumbs aggressively</string>
<string name="predictive_nav_anim">[Experimental] Predictive back navigation animations</string>
<string name="user_agent">User Agent</string> <string name="user_agent">User Agent</string>
<string name="auto_updates">Automatically check for updates</string> <string name="auto_updates">Automatically check for updates</string>
<string name="update_frequency_never">Never</string> <string name="update_frequency_never">Never</string>