From 5a83a1c858e8095353aa50fe4ea080b07bf85813 Mon Sep 17 00:00:00 2001 From: vultix Date: Thu, 3 May 2018 04:24:41 -0600 Subject: [PATCH] Css gradients (#5534) * feat(ios): Added support for css gradients. * feat(android): Added support for css gradients. * fix: Fixed gradient borders on ios * fix(gradient): added backgroundGradient to View and Style. * fix(ios-gradients): fixed ios gradients covering view content. * test(gradient): Added ui app tests for background gradients. * test(gradient): Added a test ensuring background gradient property is applied to style. * style(gradient): Fixed tslint errors. * fix(gradient): Removed the background-gradient property and added the gradient to background-image. * style: fixed a consecutive blank line tslint error. * fix(tests): fixed the bug that was causing tests to fail. * chore(linear-gradient): fix equality comparer * test(gradient): add linear gradients test app * chore(tslint): update with latest tslint rules --- .../ui-tests-app/button/border-playground.ts | 5 ++ .../ui-tests-app/button/border-playground.xml | 1 + .../css/background-image-linear-gradient.ts | 41 ++++++++++ .../css/background-image-linear-gradient.xml | 7 ++ .../ui-tests-app/css/background-shorthand.ts | 4 +- apps/app/ui-tests-app/css/gradient-border.css | 77 +++++++++++++++++++ apps/app/ui-tests-app/css/gradient-border.xml | 22 ++++++ apps/app/ui-tests-app/css/main-page.ts | 2 + tns-core-modules/ui/core/view/view-common.ts | 6 +- tns-core-modules/ui/core/view/view.d.ts | 4 +- .../ui/styling/background-common.ts | 15 +++- .../ui/styling/background.android.ts | 45 ++++++++++- tns-core-modules/ui/styling/background.d.ts | 6 +- tns-core-modules/ui/styling/background.ios.ts | 67 +++++++++++++++- .../ui/styling/linear-gradient.ts | 64 +++++++++++++++ .../ui/styling/style-properties.ts | 34 +++++++- tns-core-modules/ui/styling/style/style.d.ts | 3 +- tns-core-modules/ui/styling/style/style.ts | 5 +- .../android/org.nativescript.widgets.d.ts | 13 ++++ 19 files changed, 397 insertions(+), 24 deletions(-) create mode 100644 apps/app/ui-tests-app/css/background-image-linear-gradient.ts create mode 100644 apps/app/ui-tests-app/css/background-image-linear-gradient.xml create mode 100644 apps/app/ui-tests-app/css/gradient-border.css create mode 100644 apps/app/ui-tests-app/css/gradient-border.xml create mode 100644 tns-core-modules/ui/styling/linear-gradient.ts diff --git a/apps/app/ui-tests-app/button/border-playground.ts b/apps/app/ui-tests-app/button/border-playground.ts index 2d841bd90..b8a313dad 100644 --- a/apps/app/ui-tests-app/button/border-playground.ts +++ b/apps/app/ui-tests-app/button/border-playground.ts @@ -34,6 +34,11 @@ export function onToggle(args: EventData) { target.backgroundImage = target.backgroundImage ? undefined : `~/ui-tests-app/resources/images/test2.png`; debugConsole.text += `> background-image: ${target.backgroundImage}\n`; } + else if (button.text === "BGGradient") { + const gradient = "linear-gradient(to right, purple, red)"; + target.backgroundImage = typeof target.backgroundImage === "object" ? undefined : gradient; + debugConsole.text += `> background-image: ${gradient} \n`; + } scrollView.scrollToVerticalOffset(scrollView.scrollableHeight, true); } diff --git a/apps/app/ui-tests-app/button/border-playground.xml b/apps/app/ui-tests-app/button/border-playground.xml index 83d669808..e3a0fb624 100644 --- a/apps/app/ui-tests-app/button/border-playground.xml +++ b/apps/app/ui-tests-app/button/border-playground.xml @@ -17,6 +17,7 @@