Skip to content

Added StackAnimator.inverted extension function#993

Merged
arkivanov merged 4 commits intoarkivanov:masterfrom
TopsyCretts:feat/slide-animation-direction
Mar 26, 2026
Merged

Added StackAnimator.inverted extension function#993
arkivanov merged 4 commits intoarkivanov:masterfrom
TopsyCretts:feat/slide-animation-direction

Conversation

@TopsyCretts
Copy link
Copy Markdown
Contributor

@TopsyCretts TopsyCretts commented Mar 24, 2026

Add extra parameter to reverse slide animation direction.

Summary by CodeRabbit

  • New Features
    • Added an option to invert the direction of stack slide animations, enabling reversed enter/exit flows during transitions.
  • Documentation
    • Updated public documentation to note that slide direction can be inverted via the new inversion option.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

Added a new StackAnimator.inverted() extension that returns an animator which remaps animation directions (ENTER_FRONT↔ENTER_BACK, EXIT_FRONT↔EXIT_BACK). Also updated KDoc for slide(...) to mention inversion via StackAnimator.inverted(); no runtime behavior changes to slide.

Changes

Cohort / File(s) Summary
Animator inversion implementation
extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/stack/animation/StackAnimator.kt
Added fun StackAnimator.inverted(): StackAnimator that delegates to the original animator while remapping Direction values (ENTER_FRONT↔ENTER_BACK, EXIT_FRONT↔EXIT_BACK).
KDoc update
extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/stack/animation/Slide.kt
Updated KDoc for slide(...) to note that sliding direction can be inverted by applying StackAnimator.inverted(); no functional changes.
Public API surface additions (manifests)
extensions-compose-experimental/api/android/extensions-compose-experimental.api, extensions-compose-experimental/api/extensions-compose-experimental.klib.api, extensions-compose-experimental/api/jvm/extensions-compose-experimental.api
Exposed new public function/factory inverted(StackAnimator): StackAnimator (K/JVM) and inverted() extension (KLib) in the public API manifests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a new inverted() extension function to StackAnimator. It is concise, specific, and directly reflects the primary modification across all changed files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/stack/animation/Slide.kt`:
- Around line 14-24: The public API has changed for function
slide(animationSpec:..., orientation:..., reverseDirection: Boolean = false) in
Slide.kt but the API dump files were not regenerated; run the Gradle task that
regenerates API dumps (e.g., the project's API dump/validate task) so the
updated signature for slide (including the reverseDirection parameter) is
written into the extensions-compose-experimental API dump files, then commit the
updated dump files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f85aacfb-35e2-4db2-8a6f-73d503c81356

📥 Commits

Reviewing files that changed from the base of the PR and between d36078d and 7e136b2.

📒 Files selected for processing (1)
  • extensions-compose-experimental/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/experimental/stack/animation/Slide.kt

@arkivanov
Copy link
Copy Markdown
Owner

Thanks! I think this could be done in a more generic way. And we could also avoid changing the existing API. Let me know what do you think.

Also, don't forget to update API dump files: ./gradlew apiDump.

@ExperimentalDecomposeApi
fun StackAnimator.inverted(): StackAnimator =
    StackAnimator { direction ->
        animate(
            direction = when (direction) {
                Direction.ENTER_FRONT -> Direction.ENTER_BACK
                Direction.EXIT_FRONT -> Direction.EXIT_BACK
                Direction.ENTER_BACK -> Direction.ENTER_FRONT
                Direction.EXIT_BACK -> Direction.EXIT_FRONT
            },
        )
    }

@TopsyCretts
Copy link
Copy Markdown
Contributor Author

Thanks! I agree your solution is better and cleaner. My apologies for missing the doc comments regarding negative values for the factor in different directions.

Added doc comment pointed to StackAnimator.inverted() to Slide.kt
Dumped api files
@arkivanov arkivanov changed the title Additional parameter reverseDirection to slide() StackAnimator Added StackAnimator.inverted extension function Mar 26, 2026
@arkivanov arkivanov merged commit 495bbb7 into arkivanov:master Mar 26, 2026
3 checks passed
@arkivanov
Copy link
Copy Markdown
Owner

Thank you!

@TopsyCretts TopsyCretts deleted the feat/slide-animation-direction branch March 26, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants