From e344ea3aa09cdc65e1abf6c722390aabfb1ca769 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Mon, 5 Aug 2024 15:32:36 +0300 Subject: [PATCH] fix(android): RootLayout shade cover null color handling --- .../ui/layouts/root-layout/index.android.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/core/ui/layouts/root-layout/index.android.ts b/packages/core/ui/layouts/root-layout/index.android.ts index e043f57fd8..d5146b555c 100644 --- a/packages/core/ui/layouts/root-layout/index.android.ts +++ b/packages/core/ui/layouts/root-layout/index.android.ts @@ -22,7 +22,7 @@ export class RootLayout extends RootLayoutBase { onTouch: function (view, event) { return true; }, - }) + }), ); } } @@ -63,9 +63,9 @@ export class RootLayout extends RootLayoutBase { rotate: 0, opacity: options.opacity, }, - options.color + options.color, ), - duration + duration, ); } @@ -78,9 +78,9 @@ export class RootLayout extends RootLayoutBase { } private _getAnimationSet(view: View, shadeCoverAnimation: TransitionAnimation, backgroundColor: string = defaultShadeCoverOptions.color): Array { - const backgroundIsGradient = backgroundColor.startsWith('linear-gradient'); + const isBackgroundGradient = backgroundColor && backgroundColor.startsWith('linear-gradient'); - const animationSet = Array.create(android.animation.Animator, backgroundIsGradient ? 6 : 7); + const animationSet = Array.create(android.animation.Animator, isBackgroundGradient ? 6 : 7); animationSet[0] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'translationX', [shadeCoverAnimation.translateX]); animationSet[1] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'translationY', [shadeCoverAnimation.translateY]); animationSet[2] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'scaleX', [shadeCoverAnimation.scaleX]); @@ -88,7 +88,7 @@ export class RootLayout extends RootLayoutBase { animationSet[4] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'rotation', [shadeCoverAnimation.rotate]); animationSet[5] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'alpha', [shadeCoverAnimation.opacity]); - if (backgroundIsGradient) { + if (isBackgroundGradient) { if (view.backgroundColor) { view.backgroundColor = undefined; } @@ -105,8 +105,9 @@ export class RootLayout extends RootLayoutBase { private _getBackgroundColorAnimator(view: View, backgroundColor: string): android.animation.ValueAnimator { const nativeArray = Array.create(java.lang.Object, 2); - nativeArray[0] = view.backgroundColor ? java.lang.Integer.valueOf((view.backgroundColor).argb) : java.lang.Integer.valueOf(-1); - nativeArray[1] = java.lang.Integer.valueOf(new Color(backgroundColor).argb); + + nativeArray[0] = java.lang.Integer.valueOf(view.backgroundColor ? (view.backgroundColor).argb : -1); + nativeArray[1] = java.lang.Integer.valueOf(backgroundColor ? new Color(backgroundColor).argb : -1); const backgroundColorAnimator = android.animation.ValueAnimator.ofObject(new android.animation.ArgbEvaluator(), nativeArray); backgroundColorAnimator.addUpdateListener( new android.animation.ValueAnimator.AnimatorUpdateListener({ @@ -114,7 +115,7 @@ export class RootLayout extends RootLayoutBase { const argb = (animator.getAnimatedValue()).intValue(); view.backgroundColor = new Color(argb); }, - }) + }), ); return backgroundColorAnimator; } @@ -132,7 +133,7 @@ export class RootLayout extends RootLayoutBase { }, onAnimationRepeat: function (animator: android.animation.Animator): void {}, onAnimationCancel: function (animator: android.animation.Animator): void {}, - }) + }), ); animatorSet.start(); });