Use fade transition in Voyager screens to mimic existing Conductor change handler
This commit is contained in:
parent
c61a51438d
commit
2921be620a
3 changed files with 16 additions and 19 deletions
|
@ -266,7 +266,6 @@ dependencies {
|
||||||
implementation(libs.cascade)
|
implementation(libs.cascade)
|
||||||
implementation(libs.numberpicker)
|
implementation(libs.numberpicker)
|
||||||
implementation(libs.bundles.voyager)
|
implementation(libs.bundles.voyager)
|
||||||
implementation(libs.materialmotion.core)
|
|
||||||
|
|
||||||
// Conductor
|
// Conductor
|
||||||
implementation(libs.bundles.conductor)
|
implementation(libs.bundles.conductor)
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package eu.kanade.tachiyomi.ui.setting
|
package eu.kanade.tachiyomi.ui.setting
|
||||||
|
|
||||||
import android.os.Bundle
|
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.material3.windowsizeclass.WindowWidthSizeClass
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import cafe.adriel.voyager.core.stack.StackEvent
|
|
||||||
import cafe.adriel.voyager.navigator.Navigator
|
import cafe.adriel.voyager.navigator.Navigator
|
||||||
import cafe.adriel.voyager.transitions.ScreenTransition
|
import cafe.adriel.voyager.transitions.ScreenTransition
|
||||||
import eu.kanade.presentation.components.TwoPanelBox
|
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.LocalRouter
|
||||||
import eu.kanade.presentation.util.calculateWindowWidthSizeClass
|
import eu.kanade.presentation.util.calculateWindowWidthSizeClass
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BasicFullComposeController
|
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) {
|
class SettingsMainController(bundle: Bundle = bundleOf()) : BasicFullComposeController(bundle) {
|
||||||
|
|
||||||
private val toBackupScreen = args.getBoolean(TO_BACKUP_SCREEN)
|
private val toBackupScreen = args.getBoolean(TO_BACKUP_SCREEN)
|
||||||
private val toAboutScreen = args.getBoolean(TO_ABOUT_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
|
@Composable
|
||||||
override fun ComposeContent() {
|
override fun ComposeContent() {
|
||||||
CompositionLocalProvider(LocalRouter provides router) {
|
CompositionLocalProvider(LocalRouter provides router) {
|
||||||
|
@ -40,15 +51,9 @@ class SettingsMainController(bundle: Bundle = bundleOf()) : BasicFullComposeCont
|
||||||
},
|
},
|
||||||
content = {
|
content = {
|
||||||
CompositionLocalProvider(LocalBackPress provides this::back) {
|
CompositionLocalProvider(LocalBackPress provides this::back) {
|
||||||
val slideDistance = rememberSlideDistance()
|
|
||||||
ScreenTransition(
|
ScreenTransition(
|
||||||
navigator = it,
|
navigator = it,
|
||||||
transition = {
|
transition = { transition },
|
||||||
materialSharedAxisX(
|
|
||||||
forward = it.lastEvent != StackEvent.Pop,
|
|
||||||
slideDistance = slideDistance,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -70,15 +75,9 @@ class SettingsMainController(bundle: Bundle = bundleOf()) : BasicFullComposeCont
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
endContent = {
|
endContent = {
|
||||||
val slideDistance = rememberSlideDistance()
|
|
||||||
ScreenTransition(
|
ScreenTransition(
|
||||||
navigator = it,
|
navigator = it,
|
||||||
transition = {
|
transition = { transition },
|
||||||
materialSharedAxisX(
|
|
||||||
forward = it.lastEvent != StackEvent.Pop,
|
|
||||||
slideDistance = slideDistance,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -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-navigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
|
||||||
voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", 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"
|
numberpicker= "com.chargemap.compose:numberpicker:1.0.3"
|
||||||
|
|
||||||
[bundles]
|
[bundles]
|
||||||
|
|
Reference in a new issue