Fixed
Status Update
Comments
ra...@google.com <ra...@google.com>
ap...@google.com <ap...@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),
)
```
ap...@google.com <ap...@google.com> #4
I found the same error while working for my current company and it was caused by a missing CompositionLocal. In my case, I wasn't using the app theme and the error was not explicit at all with that missing implicit dependency. May that be your same case?
ra...@google.com <ra...@google.com>
pr...@google.com <pr...@google.com> #5
After updating the libraries the error eventually went away. It's ok to close this issue now
Description
Re-implement Modifier.focusTarget using the new Modifier.Node system.