Use fade transition in Voyager screens to mimic existing Conductor change handler

This commit is contained in:
arkon 2022-10-21 15:29:17 -04:00
parent c61a51438d
commit 2921be620a
3 changed files with 16 additions and 19 deletions

View file

@ -266,7 +266,6 @@ dependencies {
implementation(libs.cascade)
implementation(libs.numberpicker)
implementation(libs.bundles.voyager)
implementation(libs.materialmotion.core)
// Conductor
implementation(libs.bundles.conductor)

View file

@ -1,11 +1,15 @@
package eu.kanade.tachiyomi.ui.setting
import android.os.Bundle
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.with
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.core.os.bundleOf
import cafe.adriel.voyager.core.stack.StackEvent
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.transitions.ScreenTransition
import eu.kanade.presentation.components.TwoPanelBox
@ -17,14 +21,21 @@ import eu.kanade.presentation.util.LocalBackPress
import eu.kanade.presentation.util.LocalRouter
import eu.kanade.presentation.util.calculateWindowWidthSizeClass
import eu.kanade.tachiyomi.ui.base.controller.BasicFullComposeController
import soup.compose.material.motion.animation.materialSharedAxisX
import soup.compose.material.motion.animation.rememberSlideDistance
class SettingsMainController(bundle: Bundle = bundleOf()) : BasicFullComposeController(bundle) {
private val toBackupScreen = args.getBoolean(TO_BACKUP_SCREEN)
private val toAboutScreen = args.getBoolean(TO_ABOUT_SCREEN)
/**
* Mimics [eu.kanade.tachiyomi.ui.base.controller.OneWayFadeChangeHandler]
*/
private val transition = fadeIn(
animationSpec = tween(
easing = LinearEasing,
),
) with ExitTransition.None
@Composable
override fun ComposeContent() {
CompositionLocalProvider(LocalRouter provides router) {
@ -40,15 +51,9 @@ class SettingsMainController(bundle: Bundle = bundleOf()) : BasicFullComposeCont
},
content = {
CompositionLocalProvider(LocalBackPress provides this::back) {
val slideDistance = rememberSlideDistance()
ScreenTransition(
navigator = it,
transition = {
materialSharedAxisX(
forward = it.lastEvent != StackEvent.Pop,
slideDistance = slideDistance,
)
},
transition = { transition },
)
}
},
@ -70,15 +75,9 @@ class SettingsMainController(bundle: Bundle = bundleOf()) : BasicFullComposeCont
}
},
endContent = {
val slideDistance = rememberSlideDistance()
ScreenTransition(
navigator = it,
transition = {
materialSharedAxisX(
forward = it.lastEvent != StackEvent.Pop,
slideDistance = slideDistance,
)
},
transition = { transition },
)
},
)

View file

@ -93,7 +93,6 @@ junit = "org.junit.jupiter:junit-jupiter:5.9.1"
voyager-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyager" }
materialmotion-core = "io.github.fornewid:material-motion-compose-core:0.10.2-beta"
numberpicker= "com.chargemap.compose:numberpicker:1.0.3"
[bundles]