mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 11:17:04 +08:00
fix(android): RootLayout shade cover null color handling (#10599)
This commit is contained in:

committed by
GitHub

parent
89fa6ec84d
commit
f7b9d06e91
@ -22,7 +22,7 @@ export class RootLayout extends RootLayoutBase {
|
|||||||
onTouch: function (view, event) {
|
onTouch: function (view, event) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,9 +63,9 @@ export class RootLayout extends RootLayoutBase {
|
|||||||
rotate: 0,
|
rotate: 0,
|
||||||
opacity: options.opacity,
|
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<android.animation.Animator> {
|
private _getAnimationSet(view: View, shadeCoverAnimation: TransitionAnimation, backgroundColor: string = defaultShadeCoverOptions.color): Array<android.animation.Animator> {
|
||||||
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[0] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'translationX', [shadeCoverAnimation.translateX]);
|
||||||
animationSet[1] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'translationY', [shadeCoverAnimation.translateY]);
|
animationSet[1] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'translationY', [shadeCoverAnimation.translateY]);
|
||||||
animationSet[2] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'scaleX', [shadeCoverAnimation.scaleX]);
|
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[4] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'rotation', [shadeCoverAnimation.rotate]);
|
||||||
animationSet[5] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'alpha', [shadeCoverAnimation.opacity]);
|
animationSet[5] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'alpha', [shadeCoverAnimation.opacity]);
|
||||||
|
|
||||||
if (backgroundIsGradient) {
|
if (isBackgroundGradient) {
|
||||||
if (view.backgroundColor) {
|
if (view.backgroundColor) {
|
||||||
view.backgroundColor = undefined;
|
view.backgroundColor = undefined;
|
||||||
}
|
}
|
||||||
@ -105,8 +105,9 @@ export class RootLayout extends RootLayoutBase {
|
|||||||
|
|
||||||
private _getBackgroundColorAnimator(view: View, backgroundColor: string): android.animation.ValueAnimator {
|
private _getBackgroundColorAnimator(view: View, backgroundColor: string): android.animation.ValueAnimator {
|
||||||
const nativeArray = Array.create(java.lang.Object, 2);
|
const nativeArray = Array.create(java.lang.Object, 2);
|
||||||
nativeArray[0] = view.backgroundColor ? java.lang.Integer.valueOf((<Color>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 ? (<Color>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);
|
const backgroundColorAnimator = android.animation.ValueAnimator.ofObject(new android.animation.ArgbEvaluator(), nativeArray);
|
||||||
backgroundColorAnimator.addUpdateListener(
|
backgroundColorAnimator.addUpdateListener(
|
||||||
new android.animation.ValueAnimator.AnimatorUpdateListener({
|
new android.animation.ValueAnimator.AnimatorUpdateListener({
|
||||||
@ -114,7 +115,7 @@ export class RootLayout extends RootLayoutBase {
|
|||||||
const argb = (<java.lang.Integer>animator.getAnimatedValue()).intValue();
|
const argb = (<java.lang.Integer>animator.getAnimatedValue()).intValue();
|
||||||
view.backgroundColor = new Color(argb);
|
view.backgroundColor = new Color(argb);
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return backgroundColorAnimator;
|
return backgroundColorAnimator;
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ export class RootLayout extends RootLayoutBase {
|
|||||||
},
|
},
|
||||||
onAnimationRepeat: function (animator: android.animation.Animator): void {},
|
onAnimationRepeat: function (animator: android.animation.Animator): void {},
|
||||||
onAnimationCancel: function (animator: android.animation.Animator): void {},
|
onAnimationCancel: function (animator: android.animation.Animator): void {},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
animatorSet.start();
|
animatorSet.start();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user