From 11d3884243001ef1c6f51ebb334d90abe6cff7b0 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Tue, 27 Nov 2018 06:44:34 -0200 Subject: [PATCH] fix(android-styling): correctly detect if drawable uses ColorFilter (#6342) * fix(android-styling): correctly detect if drawable uses ColorFilter Treat a widget with a BorderDrawable background as any other, even if it's FilterOnly If the drawable has been replaced with a new one, clear _cachedDrawable Fixes #6341 * test(button): add test for changing border-radius and color in button * test: fix test checks for IOS * keep original drawable cached --- tests/app/ui/button/button-tests.ts | 15 +++++++++++++++ tns-core-modules/ui/styling/background.android.ts | 1 + 2 files changed, 16 insertions(+) diff --git a/tests/app/ui/button/button-tests.ts b/tests/app/ui/button/button-tests.ts index e9f4caeff..1af31325d 100644 --- a/tests/app/ui/button/button-tests.ts +++ b/tests/app/ui/button/button-tests.ts @@ -404,3 +404,18 @@ export function test_setting_formattedText_With_UnknownFont_DoesNotCrash() { TKUnit.waitUntilReady(() => btn.isLayoutValid); }); } + +export function test_Native_Background_Color_BorderRadius_Change() { + let view = new buttonModule.Button(); + view.text = "TEST"; + helper.buildUIAndRunTest(view, function (views: Array) { + let page = views[1]; + page.css = ".border { background-color: #00FF00; border-radius: 1; } .colorfilter { background-color: #FF0000; }"; + view.className = "border"; + helper.waitUntilLayoutReady(view); + TKUnit.assertEqual(buttonTestsNative.getNativeBackgroundColor(view).hex, "#00FF00"); + view.className = "colorfilter"; + helper.waitUntilLayoutReady(view); + TKUnit.assertEqual(buttonTestsNative.getNativeBackgroundColor(view).hex, "#FF0000"); + }); +} diff --git a/tns-core-modules/ui/styling/background.android.ts b/tns-core-modules/ui/styling/background.android.ts index 9f3e9ed77..123357b5d 100644 --- a/tns-core-modules/ui/styling/background.android.ts +++ b/tns-core-modules/ui/styling/background.android.ts @@ -50,6 +50,7 @@ export module ad { if (isSetColorFilterOnlyWidget(nativeView) && drawable + && !(drawable instanceof org.nativescript.widgets.BorderDrawable) && !background.hasBorderWidth() && !background.hasBorderRadius() && !background.clipPath