Skip to content

Commit

Permalink
Added isPredictiveBack flag to stackAnimation function with selector
Browse files Browse the repository at this point in the history
  • Loading branch information
arkivanov committed Dec 9, 2024
1 parent 363192a commit 01a26c3
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public abstract interface class com/arkivanov/decompose/extensions/compose/exper

public final class com/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimationKt {
public static final fun stackAnimation (Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimator;ZLkotlin/jvm/functions/Function1;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static final fun stackAnimation (ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static final fun stackAnimation (ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static synthetic fun stackAnimation$default (Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimator;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static synthetic fun stackAnimation$default (ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static synthetic fun stackAnimation$default (ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;ILjava/lang/Object;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
}

public abstract interface class com/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimationProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final fun <#A: kotlin/Any, #B: kotlin/Any, #C: kotlin/Any, #D: kotlin/Any, #E: k
final fun <#A: kotlin/Any, #B: kotlin/Any, #C: kotlin/Any, #D: kotlin/Any> com.arkivanov.decompose.extensions.compose.experimental.panels/ChildPanels(com.arkivanov.decompose.router.panels/ChildPanels<#A, #B, #C, #D, kotlin/Nothing, kotlin/Nothing>, kotlin/Function3<com.arkivanov.decompose/Child.Created<#A, #B>, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, kotlin/Function3<com.arkivanov.decompose/Child.Created<#C, #D>, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, androidx.compose.ui/Modifier?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, com.arkivanov.decompose.extensions.compose.experimental.panels/ChildPanelsLayout?, com.arkivanov.decompose.extensions.compose.experimental.panels/ChildPanelsAnimators?, kotlin/Function1<com.arkivanov.decompose.router.panels/ChildPanels<#A, #B, #C, #D, kotlin/Nothing, kotlin/Nothing>, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/PredictiveBackParams?>?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // com.arkivanov.decompose.extensions.compose.experimental.panels/ChildPanels|ChildPanels(com.arkivanov.decompose.router.panels.ChildPanels<0:0,0:1,0:2,0:3,kotlin.Nothing,kotlin.Nothing>;kotlin.Function3<com.arkivanov.decompose.Child.Created<0:0,0:1>,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;kotlin.Function3<com.arkivanov.decompose.Child.Created<0:2,0:3>,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.ui.Modifier?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;com.arkivanov.decompose.extensions.compose.experimental.panels.ChildPanelsLayout?;com.arkivanov.decompose.extensions.compose.experimental.panels.ChildPanelsAnimators?;kotlin.Function1<com.arkivanov.decompose.router.panels.ChildPanels<0:0,0:1,0:2,0:3,kotlin.Nothing,kotlin.Nothing>,com.arkivanov.decompose.extensions.compose.experimental.stack.animation.PredictiveBackParams?>?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){0§<kotlin.Any>;1§<kotlin.Any>;2§<kotlin.Any>;3§<kotlin.Any>}[0]
final fun <#A: kotlin/Any, #B: kotlin/Any, #C: kotlin/Any, #D: kotlin/Any> com.arkivanov.decompose.extensions.compose.experimental.panels/ChildPanels(com.arkivanov.decompose.value/Value<com.arkivanov.decompose.router.panels/ChildPanels<#A, #B, #C, #D, kotlin/Nothing, kotlin/Nothing>>, kotlin/Function3<com.arkivanov.decompose/Child.Created<#A, #B>, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, kotlin/Function3<com.arkivanov.decompose/Child.Created<#C, #D>, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, androidx.compose.ui/Modifier?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, com.arkivanov.decompose.extensions.compose.experimental.panels/ChildPanelsLayout?, com.arkivanov.decompose.extensions.compose.experimental.panels/ChildPanelsAnimators?, kotlin/Function1<com.arkivanov.decompose.router.panels/ChildPanels<#A, #B, #C, #D, kotlin/Nothing, kotlin/Nothing>, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/PredictiveBackParams?>?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // com.arkivanov.decompose.extensions.compose.experimental.panels/ChildPanels|ChildPanels(com.arkivanov.decompose.value.Value<com.arkivanov.decompose.router.panels.ChildPanels<0:0,0:1,0:2,0:3,kotlin.Nothing,kotlin.Nothing>>;kotlin.Function3<com.arkivanov.decompose.Child.Created<0:0,0:1>,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;kotlin.Function3<com.arkivanov.decompose.Child.Created<0:2,0:3>,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.ui.Modifier?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;com.arkivanov.decompose.extensions.compose.experimental.panels.ChildPanelsLayout?;com.arkivanov.decompose.extensions.compose.experimental.panels.ChildPanelsAnimators?;kotlin.Function1<com.arkivanov.decompose.router.panels.ChildPanels<0:0,0:1,0:2,0:3,kotlin.Nothing,kotlin.Nothing>,com.arkivanov.decompose.extensions.compose.experimental.stack.animation.PredictiveBackParams?>?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){0§<kotlin.Any>;1§<kotlin.Any>;2§<kotlin.Any>;3§<kotlin.Any>}[0]
final fun <#A: kotlin/Any, #B: kotlin/Any> com.arkivanov.decompose.extensions.compose.experimental.stack.animation/stackAnimation(com.arkivanov.decompose.extensions.compose.experimental.stack.animation/StackAnimator? = ..., kotlin/Boolean = ..., kotlin/Function1<com.arkivanov.decompose.router.stack/ChildStack<#A, #B>, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/PredictiveBackParams?> = ...): com.arkivanov.decompose.extensions.compose.experimental.stack.animation/StackAnimation<#A, #B> // com.arkivanov.decompose.extensions.compose.experimental.stack.animation/stackAnimation|stackAnimation(com.arkivanov.decompose.extensions.compose.experimental.stack.animation.StackAnimator?;kotlin.Boolean;kotlin.Function1<com.arkivanov.decompose.router.stack.ChildStack<0:0,0:1>,com.arkivanov.decompose.extensions.compose.experimental.stack.animation.PredictiveBackParams?>){0§<kotlin.Any>;1§<kotlin.Any>}[0]
final fun <#A: kotlin/Any, #B: kotlin/Any> com.arkivanov.decompose.extensions.compose.experimental.stack.animation/stackAnimation(kotlin/Boolean = ..., kotlin/Function1<com.arkivanov.decompose.router.stack/ChildStack<#A, #B>, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/PredictiveBackParams?> = ..., kotlin/Function3<com.arkivanov.decompose/Child.Created<#A, #B>, com.arkivanov.decompose/Child.Created<#A, #B>, com.arkivanov.decompose.extensions.compose.stack.animation/Direction, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/StackAnimator?>): com.arkivanov.decompose.extensions.compose.experimental.stack.animation/StackAnimation<#A, #B> // com.arkivanov.decompose.extensions.compose.experimental.stack.animation/stackAnimation|stackAnimation(kotlin.Boolean;kotlin.Function1<com.arkivanov.decompose.router.stack.ChildStack<0:0,0:1>,com.arkivanov.decompose.extensions.compose.experimental.stack.animation.PredictiveBackParams?>;kotlin.Function3<com.arkivanov.decompose.Child.Created<0:0,0:1>,com.arkivanov.decompose.Child.Created<0:0,0:1>,com.arkivanov.decompose.extensions.compose.stack.animation.Direction,com.arkivanov.decompose.extensions.compose.experimental.stack.animation.StackAnimator?>){0§<kotlin.Any>;1§<kotlin.Any>}[0]
final fun <#A: kotlin/Any, #B: kotlin/Any> com.arkivanov.decompose.extensions.compose.experimental.stack.animation/stackAnimation(kotlin/Boolean = ..., kotlin/Function1<com.arkivanov.decompose.router.stack/ChildStack<#A, #B>, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/PredictiveBackParams?> = ..., kotlin/Function4<com.arkivanov.decompose/Child.Created<#A, #B>, com.arkivanov.decompose/Child.Created<#A, #B>, com.arkivanov.decompose.extensions.compose.stack.animation/Direction, kotlin/Boolean, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/StackAnimator?>): com.arkivanov.decompose.extensions.compose.experimental.stack.animation/StackAnimation<#A, #B> // com.arkivanov.decompose.extensions.compose.experimental.stack.animation/stackAnimation|stackAnimation(kotlin.Boolean;kotlin.Function1<com.arkivanov.decompose.router.stack.ChildStack<0:0,0:1>,com.arkivanov.decompose.extensions.compose.experimental.stack.animation.PredictiveBackParams?>;kotlin.Function4<com.arkivanov.decompose.Child.Created<0:0,0:1>,com.arkivanov.decompose.Child.Created<0:0,0:1>,com.arkivanov.decompose.extensions.compose.stack.animation.Direction,kotlin.Boolean,com.arkivanov.decompose.extensions.compose.experimental.stack.animation.StackAnimator?>){0§<kotlin.Any>;1§<kotlin.Any>}[0]
final fun <#A: kotlin/Any, #B: kotlin/Any> com.arkivanov.decompose.extensions.compose.experimental.stack/ChildStack(com.arkivanov.decompose.router.stack/ChildStack<#A, #B>, androidx.compose.ui/Modifier?, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/StackAnimation<#A, #B>?, kotlin/Function4<androidx.compose.animation/AnimatedVisibilityScope, com.arkivanov.decompose/Child.Created<#A, #B>, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // com.arkivanov.decompose.extensions.compose.experimental.stack/ChildStack|ChildStack(com.arkivanov.decompose.router.stack.ChildStack<0:0,0:1>;androidx.compose.ui.Modifier?;com.arkivanov.decompose.extensions.compose.experimental.stack.animation.StackAnimation<0:0,0:1>?;kotlin.Function4<androidx.compose.animation.AnimatedVisibilityScope,com.arkivanov.decompose.Child.Created<0:0,0:1>,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){0§<kotlin.Any>;1§<kotlin.Any>}[0]
final fun <#A: kotlin/Any, #B: kotlin/Any> com.arkivanov.decompose.extensions.compose.experimental.stack/ChildStack(com.arkivanov.decompose.value/Value<com.arkivanov.decompose.router.stack/ChildStack<#A, #B>>, androidx.compose.ui/Modifier?, com.arkivanov.decompose.extensions.compose.experimental.stack.animation/StackAnimation<#A, #B>?, kotlin/Function4<androidx.compose.animation/AnimatedVisibilityScope, com.arkivanov.decompose/Child.Created<#A, #B>, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // com.arkivanov.decompose.extensions.compose.experimental.stack/ChildStack|ChildStack(com.arkivanov.decompose.value.Value<com.arkivanov.decompose.router.stack.ChildStack<0:0,0:1>>;androidx.compose.ui.Modifier?;com.arkivanov.decompose.extensions.compose.experimental.stack.animation.StackAnimation<0:0,0:1>?;kotlin.Function4<androidx.compose.animation.AnimatedVisibilityScope,com.arkivanov.decompose.Child.Created<0:0,0:1>,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){0§<kotlin.Any>;1§<kotlin.Any>}[0]
final fun com.arkivanov.decompose.extensions.compose.experimental.panels/com_arkivanov_decompose_extensions_compose_experimental_panels_ChildPanelsAnimators$stableprop_getter(): kotlin/Int // com.arkivanov.decompose.extensions.compose.experimental.panels/com_arkivanov_decompose_extensions_compose_experimental_panels_ChildPanelsAnimators$stableprop_getter|com_arkivanov_decompose_extensions_compose_experimental_panels_ChildPanelsAnimators$stableprop_getter(){}[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public abstract interface class com/arkivanov/decompose/extensions/compose/exper

public final class com/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimationKt {
public static final fun stackAnimation (Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimator;ZLkotlin/jvm/functions/Function1;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static final fun stackAnimation (ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static final fun stackAnimation (ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static synthetic fun stackAnimation$default (Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimator;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static synthetic fun stackAnimation$default (ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
public static synthetic fun stackAnimation$default (ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;ILjava/lang/Object;)Lcom/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimation;
}

public abstract interface class com/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimationProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ import kotlinx.coroutines.launch
internal class DefaultStackAnimation<C : Any, T : Any>(
private val disableInputDuringAnimation: Boolean,
private val predictiveBackParams: (ChildStack<C, T>) -> PredictiveBackParams?,
private val selector: (child: Child.Created<C, T>, otherChild: Child.Created<C, T>, direction: Direction) -> StackAnimator?,
private val selector: (
child: Child.Created<C, T>,
otherChild: Child.Created<C, T>,
direction: Direction,
isPredictiveBack: Boolean,
) -> StackAnimator?,
) : StackAnimation<C, T> {

@Composable
Expand Down Expand Up @@ -223,13 +228,14 @@ internal class DefaultStackAnimation<C : Any, T : Any>(
direction: Direction,
transitionState: TransitionState<EnterExitState>,
otherChild: Child.Created<C, T>,
isPredictiveBack: Boolean = false,
predictiveBackAnimator: StackAnimator? = null,
): AnimationItem<C, T> =
AnimationItem(
child = child,
direction = direction,
transitionState = transitionState,
animator = predictiveBackAnimator ?: selector(child, otherChild, direction),
animator = predictiveBackAnimator ?: selector(child, otherChild, direction, isPredictiveBack),
)

private inner class PredictiveBackCallback(
Expand Down Expand Up @@ -269,13 +275,15 @@ internal class DefaultStackAnimation<C : Any, T : Any>(
direction = Direction.ENTER_BACK,
transitionState = animationHandler.enterTransitionState,
otherChild = exitChild,
isPredictiveBack = true,
predictiveBackAnimator = animationHandler.animatable?.let { anim -> SimpleStackAnimator { anim.enterModifier } },
),
AnimationItem(
child = exitChild,
direction = Direction.EXIT_FRONT,
transitionState = animationHandler.exitTransitionState,
otherChild = enterChild,
isPredictiveBack = true,
predictiveBackAnimator = animationHandler.animatable?.let { anim -> SimpleStackAnimator { anim.exitModifier } },
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ fun interface StackAnimation<C : Any, T : Any> {
* @param predictiveBackParams a function that returns [PredictiveBackParams] for the specified [ChildStack],
* or `null`. The predictive back gesture is enabled if the value returned for the specified [ChildStack]
* is *not* `null`, and disabled if the returned value is `null`.
* @param selector provides an optional [StackAnimator] for the current [Child], other [Child] and [Direction].
* @param selector provides an optional [StackAnimator] for the current [Child], other [Child], [Direction] and
* `isPredictiveBack` flag.
*/
@ExperimentalDecomposeApi
fun <C : Any, T : Any> stackAnimation(
disableInputDuringAnimation: Boolean = true,
predictiveBackParams: (ChildStack<C, T>) -> PredictiveBackParams? = { null },
selector: (child: Child.Created<C, T>, otherChild: Child.Created<C, T>, direction: Direction) -> StackAnimator?,
selector: (
child: Child.Created<C, T>,
otherChild: Child.Created<C, T>,
direction: Direction,
isPredictiveBack: Boolean,
) -> StackAnimator?,
): StackAnimation<C, T> =
DefaultStackAnimation(
disableInputDuringAnimation = disableInputDuringAnimation,
Expand All @@ -61,5 +67,5 @@ fun <C : Any, T : Any> stackAnimation(
DefaultStackAnimation(
disableInputDuringAnimation = disableInputDuringAnimation,
predictiveBackParams = predictiveBackParams,
selector = { _, _, _ -> animator },
selector = { _, _, _, _ -> animator },
)
Loading

0 comments on commit 01a26c3

Please sign in to comment.