Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: android screen stack animation #2019

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.swmansion.rnscreens

import android.content.Context
import android.graphics.Canvas
import android.os.Build
import android.view.View
import com.facebook.react.bridge.ReactContext
import com.facebook.react.uimanager.UIManagerHelper
Expand Down Expand Up @@ -335,8 +336,10 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
fragmentWrapper.screen.stackPresentation === Screen.StackPresentation.TRANSPARENT_MODAL

private fun needsDrawReordering(fragmentWrapper: ScreenFragmentWrapper): Boolean =
fragmentWrapper.screen.stackAnimation === StackAnimation.SLIDE_FROM_BOTTOM ||
// On Android sdk 33 and above the animation is different and requires draw reordering.
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU ||
Copy link
Member

@tboba tboba Feb 13, 2024

Choose a reason for hiding this comment

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

Can you add a comment here why we're comparing Android version? (just for a context, that since API 33 the default animation has changed and because of the "sliding" we need to draw reordering 👍)

fragmentWrapper.screen.stackAnimation === StackAnimation.SLIDE_FROM_BOTTOM ||
fragmentWrapper.screen.stackAnimation === StackAnimation.FADE_FROM_BOTTOM ||
fragmentWrapper.screen.stackAnimation === StackAnimation.IOS
fragmentWrapper.screen.stackAnimation === StackAnimation.IOS
}
}
1 change: 0 additions & 1 deletion android/src/main/res/v33/anim-v33/rns_default_enter_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:startOffset="0"
android:interpolator="@android:interpolator/fast_out_extra_slow_in"
android:duration="450" />

Expand Down
4 changes: 2 additions & 2 deletions android/src/main/res/v33/anim-v33/rns_default_enter_out.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@anim/rns_standard_accelerate_interpolator"
android:startOffset="0"
android:duration="83" />
android:duration="450" />

<translate
android:fromXDelta="0"
Expand Down
Loading