8000 feat(layouts): rootlayout gradient shadecover android by williamjuan027 · Pull Request #9702 · NativeScript/NativeScript · GitHub
[go: up one dir, main page]

Skip to content

feat(layouts): rootlayout gradient shadecover android #9702

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

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
2 changes: 1 addition & 1 deletion apps/toolbox/src/pages/root-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class RootLayoutModel extends Observable {
view: this.getPopup('#EA5936', 110, -30),
options: {
shadeCover: {
color: '#FFF',
color: 'linear-gradient(to bottom, red, blue)',
opacity: 0.7,
tapToClose: true,
},
Expand Down
20 changes: 18 additions & 2 deletions packages/core/ui/layouts/root-layout/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Color } from '../../../color';
import { View } from '../../core/view';
import { RootLayoutBase, defaultShadeCoverOptions } from './root-layout-common';
import { TransitionAnimation, ShadeCoverOptions } from '.';
import { parseLinearGradient } from '../../../css/parser';
import { LinearGradient } from '../../styling/linear-gradient';

export * from './root-layout-common';

Expand Down Expand Up @@ -74,14 +76,28 @@ export class RootLayout extends RootLayoutBase {
}

private _getAnimationSet(view: View, shadeCoverAnimation: TransitionAnimation, backgroundColor: string = defaultShadeCoverOptions.color): Array<android.animation.Animator> {
const animationSet = Array.create(android.animation.Animator, 7);
const backgroundIsGradient = backgroundColor.startsWith('linear-gradient');

const animationSet = Array.create(android.animation.Animator, backgroundIsGradient ? 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]);
animationSet[3] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'scaleY', [shadeCoverAnimation.scaleY]);
animationSet[4] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'rotation', [shadeCoverAnimation.rotate]);
animationSet[5] = android.animation.ObjectAnimator.ofFloat(view.nativeViewProtected, 'alpha', [shadeCoverAnimation.opacity]);
animationSet[6] = this._getBackgroundColorAnimator(view, backgroundColor);

if (backgroundIsGradient) {
if (view.backgroundColor) {
view.backgroundColor = undefined;
}
const parsedGradient = parseLinearGradient(backgroundColor);
view.backgroundImage = LinearGradient.parse(parsedGradient.value);
} else {
if (view.backgroundImage) {
view.backgroundImage = undefined;
}
animationSet[6] = this._getBackgroundColorAnimator(view, backgroundColor);
}
return animationSet;
}

Expand Down
0