@@ -6,6 +6,7 @@ import android.graphics.Paint
6
6
import android.os.Parcelable
7
7
import android.util.SparseArray
8
8
import android.util.TypedValue
9
+ import android.view.View
9
10
import android.view.ViewGroup
10
11
import android.view.WindowManager
11
12
import android.webkit.WebView
@@ -37,6 +38,7 @@ class Screen(
37
38
var screenOrientation: Int? = null
38
39
private set
39
40
var isStatusBarAnimated: Boolean? = null
41
+ var isBeingRemoved = false
40
42
41
43
init {
42
44
// we set layout params as WindowManager.LayoutParams to workaround the issue with TextInputs
@@ -280,6 +282,40 @@ class Screen(
280
282
281
283
var nativeBackButtonDismissalEnabled: Boolean = true
282
284
285
+ fun startRemovalTransition () {
286
+ if (! isBeingRemoved) {
287
+ isBeingRemoved = true
288
+ startTransitionRecursive(this )
289
+ }
290
+ }
291
+
292
+ private fun startTransitionRecursive (parent : ViewGroup ? ) {
293
+ parent?.let {
294
+ for (i in 0 until it.childCount) {
295
+ val child = it.getChildAt(i)
296
+ if (child.javaClass.simpleName.equals(" CircleImageView" )) {
297
+ // SwipeRefreshLayout class which has CircleImageView as a child,
298
+ // does not handle `startViewTransition` properly.
299
+ // It has a custom `getChildDrawingOrder` method which returns
300
+ // wrong index if we called `startViewTransition` on the views on new arch.
301
+ // We add a simple View to bump the number of children to make it work.
302
+ // TODO: find a better way to handle this scenario
303
+ it.addView(View (context), i)
304
+ } else {
305
+ child?.let { view -> it.startViewTransition(view) }
306
+ }
307
+ if (child is ScreenStackHeaderConfig ) {
308
+ // we want to start transition on children of the toolbar too,
309
+ // which is not a child of ScreenStackHeaderConfig
310
+ startTransitionRecursive(child.toolbar)
311
+ }
312
+ if (child is ViewGroup ) {
313
+ startTransitionRecursive(child)
314
+ }
315
+ }
316
+ }
317
+ }
318
+
283
319
private fun calculateHeaderHeight (): Pair <Double , Double > {
284
320
val actionBarTv = TypedValue ()
285
321
val resolvedActionBarSize =
0 commit comments