8000 fix(android): RootLayout shade cover null color handling (#10599) · NativeScript/NativeScript@f7b9d06 · GitHub
[go: up one dir, main page]

Skip to content

Commit f7b9d06

Browse files
authored
fix(android): RootLayout shade cover null color handling (#10599)
1 parent 89fa6ec commit f7b9d06

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

packages/core/ui/layouts/root-layout/index.android.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class RootLayout extends RootLayoutBase {
2222
onTouch: function (view, event) {
2323
return true;
2424
},
25-
})
25+
}),
2626
);
2727
}
2828
}
@@ -63,9 +63,9 @@ export class RootLayout extends RootLayoutBase {
6363
rotate: 0,
6464
opacity: options.opacity,
6565
},
66-
options.color
66+
options.color,
6767
),
68-
duration
68+
duration,
6969
);
7070
}
7171

@@ -78,17 +78,17 @@ export class RootLayout extends RootLayoutBase {
7878
}
7979

8080
private _getAnimationSet(view: View, shadeCoverAnimation: TransitionAnimation, backgroundColor: string = defaultShadeCoverOptions.color): Array<android.animation.Animator> {
81-
const backgroundIsGradient = backgroundColor.startsWith('linear-gradient');
81+
const isBackgroundGradient = backgroundColor && backgroundColor.startsWith('linear-gradient');
8282

83-
const animationSet = Array.create(android.animation.Animator, backgroundIsGradient ? 6 : 7);
83+
const animationSet = Array.create(android.animation.Animator, isBackgroundGradient ? 6 : 7);
8484
animationSet[0] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'translationX', [shadeCoverAnimation.translateX]);
8585
animationSet[1] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'translationY', [shadeCoverAnimation.translateY]);
8686
animationSet[2] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'scaleX', [shadeCoverAnimation.scaleX]);
8787
animationSet[3] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'scaleY', [shadeCoverAnimation.scaleY]);
8888
animationSet[4] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'rotation', [shadeCoverAnimation.rotate]);
8989
animationSet[5] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'alpha', [shadeCoverAnimation.opacity]);
9090

91-
if (backgroundIsGradient) {
91+
if (isBackgroundGradient) {
9292
if (view.backgroundColor) {
9393
view.backgroundColor = undefined;
9494
}
@@ -105,16 +105,17 @@ export class RootLayout extends RootLayoutBase {
105105

106106
private _getBackgroundColorAnimator(view: View, backgroundColor: string): android.animation.ValueAnimator {
107107
const nativeArray = Array.create(java.lang.Object, 2);
108-
nativeArray[0] = view.backgroundColor ? java.lang.Integer.valueOf((<Color>view.backgroundColor).argb) : java.lang.Integer.valueOf(-1);
109-
nativeArray[1] = java.lang.Integer.valueOf(new Color(backgroundColor).argb);
108+
109+
nativeArray[0] = java.lang.Integer.valueOf(view.backgroundColor ? (<Color>view.backgroundColor).argb : -1);
110+
nativeArray[1] = java.lang.Integer.valueOf(backgroundColor ? new Color(backgroundColor).argb : -1);
110111
const backgroundColorAnimator = android.animation.ValueAnimator.ofObject(new android.animation.ArgbEvaluator(), nativeArray);
111112
backgroundColorAnimator.addUpdateListener(
112113
new android.animation.ValueAnimator.AnimatorUpdateListener({
113114
onAnimationUpdate(animator: android.animation.ValueAnimator) {
114115
const argb = (<java.lang.Integer>animator.getAnimatedValue()).intValue();
115116
view.backgroundColor = new Color(argb);
116117
},
117-
})
118+
}),
118119
);
119120
return backgroundColorAnimator;
120121
}
@@ -132,7 +133,7 @@ export class RootLayout extends RootLayoutBase {
132133
},
133134
onAnimationRepeat: function (animator: android.animation.Animator): void {},
134135
onAnimationCancel: function (animator: android.animation.Animator): void {},
135-
})
136+
}),
136137
);
137138
animatorSet.start();
138139
});

0 commit comments

Comments
 (0)
0