Verified
Status Update
Comments
je...@google.com <je...@google.com>
je...@google.com <je...@google.com> #2
There's some code in the tracers:
com.swissborg.app.common.compose.navigation.NavigationAnimationsKt$offsetXFactor$1 in invoke-3p2s80s at line 24
com.swissborg.app.common.compose.navigation.NavigationAnimationsKt$offsetXFactor$1 in invoke at line 23
Woudl you be able to link it or provide a similar code to what you have to help us debug further? How offsetXFactor looks like as well as your custom navigation logic and how it swaps the screens
ap...@google.com <ap...@google.com> #3
this is how offsetXFactor looks like:
```
private fun Modifier.offsetXFactor(
offsetX: (fullWidth: Int) -> Int,
factor: Float,
): Modifier = layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
layout(placeable.width, placeable.height) {
placeable.placeRelative(
x = lerp(0f, offsetX(placeable.width).toFloat(), factor).toInt(),
y = 0,
)
}
}
```
and this is how we swap the screens:
```
fun slideHorizontally(
offsetX: (fullWidth: Int) -> Int,
animationSpec: FiniteAnimationSpec<Float> = tween(),
): StackAnimator = stackAnimator(animationSpec = animationSpec) { factor, _, content ->
content(Modifier.offsetXFactor(offsetX, factor))
}
```
we use different enter/exit transition animations, i.e.
```
open fun enterTransition(): StackAnimator = slideHorizontally(
offsetX = { it },
animationSpec = tween(ScreenTransitionAnimationDuration),
)
```
```
private fun Modifier.offsetXFactor(
offsetX: (fullWidth: Int) -> Int,
factor: Float,
): Modifier = layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
layout(placeable.width, placeable.height) {
placeable.placeRelative(
x = lerp(0f, offsetX(placeable.width).toFloat(), factor).toInt(),
y = 0,
)
}
}
```
and this is how we swap the screens:
```
fun slideHorizontally(
offsetX: (fullWidth: Int) -> Int,
animationSpec: FiniteAnimationSpec<Float> = tween(),
): StackAnimator = stackAnimator(animationSpec = animationSpec) { factor, _, content ->
content(Modifier.offsetXFactor(offsetX, factor))
}
```
we use different enter/exit transition animations, i.e.
```
open fun enterTransition(): StackAnimator = slideHorizontally(
offsetX = { it },
animationSpec = tween(ScreenTransitionAnimationDuration),
)
```
Description
No description yet.