From e6ff9739c0025bd7be3dc3ea5d67c86fe831fc55 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Wed, 19 Dec 2018 18:39:06 -0200 Subject: [PATCH 1/7] just elevation, no shape --- .../nativescript-ngx-shadow/common/shadow.ts | 113 +++++++++--------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/lib/src/nativescript-ngx-shadow/common/shadow.ts b/lib/src/nativescript-ngx-shadow/common/shadow.ts index cb96fe7..4068a91 100755 --- a/lib/src/nativescript-ngx-shadow/common/shadow.ts +++ b/lib/src/nativescript-ngx-shadow/common/shadow.ts @@ -62,65 +62,66 @@ export class Shadow { private static applyOnAndroid(tnsView: any, data: AndroidData) { const nativeView = tnsView.android; - let shape; - let overrideBackground = true; + // let shape; + // let overrideBackground = true; let currentBg = nativeView.getBackground(); - - if (currentBg instanceof android.graphics.drawable.RippleDrawable) { // play nice if a ripple is wrapping a shadow - let rippleBg = currentBg.getDrawable(0); - if (rippleBg instanceof android.graphics.drawable.InsetDrawable) { - overrideBackground = false; // this is a button with it's own shadow - } else if (Shadow.isShadow(rippleBg)) { // if the ripple is wrapping a shadow, strip it - currentBg = rippleBg; - } - } - if (overrideBackground) { - if (Shadow.isShadow(currentBg)) { // make sure to have the right background - currentBg = currentBg instanceof LayeredShadow ? // if layered, get the original background - currentBg.getDrawable(1) : null; - } - - const outerRadii = Array.create("float", 8); - if (data.cornerRadius === undefined) { - outerRadii[0] = outerRadii[1] = Length.toDevicePixels(tnsView.borderTopLeftRadius, 0); - outerRadii[2] = outerRadii[3] = Length.toDevicePixels(tnsView.borderTopRightRadius, 0); - outerRadii[4] = outerRadii[5] = Length.toDevicePixels(tnsView.borderBottomRightRadius, 0); - outerRadii[6] = outerRadii[7] = Length.toDevicePixels(tnsView.borderBottomLeftRadius, 0); - } else { - java.util.Arrays.fill(outerRadii, Shadow.androidDipToPx(nativeView, data.cornerRadius as number)); - } - - // use the user defined color or the default in case the color is TRANSPARENT - const bgColor = currentBg ? - (currentBg instanceof android.graphics.drawable.ColorDrawable && currentBg.getColor() ? - currentBg.getColor() : android.graphics.Color.parseColor(data.bgcolor || Shadow.DEFAULT_BGCOLOR)) : - android.graphics.Color.parseColor(data.bgcolor || Shadow.DEFAULT_BGCOLOR); - - let newBg; - - if (data.shape !== ShapeEnum.RECTANGLE || data.bgcolor || !currentBg) { // replace background - shape = new PlainShadow(); - shape.setShape( - android.graphics.drawable.GradientDrawable[data.shape], - ); - shape.setCornerRadii(outerRadii); - shape.setColor(bgColor); - newBg = shape; - } else { // add a layer - const r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - shape = new android.graphics.drawable.ShapeDrawable(r); - shape.getPaint().setColor(bgColor); - var arr = Array.create(android.graphics.drawable.Drawable, 2); - arr[0] = shape; - arr[1] = currentBg; - const drawable = new LayeredShadow(arr); - newBg = drawable; - } - - nativeView.setBackgroundDrawable(newBg); - } + console.log(tnsView, tnsView.text, "Background: " + (currentBg ? currentBg.getClass().toString() : null)); + + // if (currentBg instanceof android.graphics.drawable.RippleDrawable) { // play nice if a ripple is wrapping a shadow + // let rippleBg = currentBg.getDrawable(0); + // if (rippleBg instanceof android.graphics.drawable.InsetDrawable) { + // overrideBackground = false; // this is a button with it's own shadow + // } else if (Shadow.isShadow(rippleBg)) { // if the ripple is wrapping a shadow, strip it + // currentBg = rippleBg; + // } + // } + // if (overrideBackground) { + // if (Shadow.isShadow(currentBg)) { // make sure to have the right background + // currentBg = currentBg instanceof LayeredShadow ? // if layered, get the original background + // currentBg.getDrawable(1) : null; + // } + + // const outerRadii = Array.create("float", 8); + // if (data.cornerRadius === undefined) { + // outerRadii[0] = outerRadii[1] = Length.toDevicePixels(tnsView.borderTopLeftRadius, 0); + // outerRadii[2] = outerRadii[3] = Length.toDevicePixels(tnsView.borderTopRightRadius, 0); + // outerRadii[4] = outerRadii[5] = Length.toDevicePixels(tnsView.borderBottomRightRadius, 0); + // outerRadii[6] = outerRadii[7] = Length.toDevicePixels(tnsView.borderBottomLeftRadius, 0); + // } else { + // java.util.Arrays.fill(outerRadii, Shadow.androidDipToPx(nativeView, data.cornerRadius as number)); + // } + + // // use the user defined color or the default in case the color is TRANSPARENT + // const bgColor = currentBg ? + // (currentBg instanceof android.graphics.drawable.ColorDrawable && currentBg.getColor() ? + // currentBg.getColor() : android.graphics.Color.parseColor(data.bgcolor || Shadow.DEFAULT_BGCOLOR)) : + // android.graphics.Color.parseColor(data.bgcolor || Shadow.DEFAULT_BGCOLOR); + + // let newBg; + + // if (data.shape !== ShapeEnum.RECTANGLE || data.bgcolor || !currentBg) { // replace background + // shape = new PlainShadow(); + // shape.setShape( + // android.graphics.drawable.GradientDrawable[data.shape], + // ); + // shape.setCornerRadii(outerRadii); + // shape.setColor(bgColor); + // newBg = shape; + // } else { // add a layer + // const r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); + // shape = new android.graphics.drawable.ShapeDrawable(r); + // shape.getPaint().setColor(bgColor); + // var arr = Array.create(android.graphics.drawable.Drawable, 2); + // arr[0] = shape; + // arr[1] = currentBg; + // const drawable = new LayeredShadow(arr); + // newBg = drawable; + // } + + // nativeView.setBackgroundDrawable(newBg); + // } nativeView.setElevation( Shadow.androidDipToPx(nativeView, data.elevation as number), From e84067bc8336d6ef9b16556f2f154a6649132b59 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Wed, 19 Dec 2018 20:06:43 -0200 Subject: [PATCH 2/7] set outline provider with owner --- .../nativescript-ngx-shadow/common/shadow.ts | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/src/nativescript-ngx-shadow/common/shadow.ts b/lib/src/nativescript-ngx-shadow/common/shadow.ts index 4068a91..6013228 100755 --- a/lib/src/nativescript-ngx-shadow/common/shadow.ts +++ b/lib/src/nativescript-ngx-shadow/common/shadow.ts @@ -12,6 +12,7 @@ declare const CGSizeMake: any; declare const UIScreen: any; declare const Array: any; declare const UIBezierPath: any; +const OutProvider: { new() } = android.view.ViewOutlineProvider; let LayeredShadow; let PlainShadow; @@ -21,6 +22,29 @@ if (isAndroid) { PlainShadow = android.graphics.drawable.GradientDrawable.extend({}); } +class MyProvider extends OutProvider { + owner; + constructor(owner) { + super(); + this.owner = owner; + return global.__native(this); + } + + getOutline(view, outline) { + console.log("getOutline"); + const outerRadii = Array.create("float", 8); + outerRadii[0] = outerRadii[1] = Length.toDevicePixels(this.owner.borderTopLeftRadius, 0); + outerRadii[2] = outerRadii[3] = Length.toDevicePixels(this.owner.borderTopRightRadius, 0); + outerRadii[4] = outerRadii[5] = Length.toDevicePixels(this.owner.borderBottomRightRadius, 0); + outerRadii[6] = outerRadii[7] = Length.toDevicePixels(this.owner.borderBottomLeftRadius, 0); + const test = new android.graphics.Path(); + test.addRoundRect(new android.graphics.RectF(0, 0, view.getWidth(), view.getHeight()), outerRadii, android.graphics.Path.Direction.CW) + test.close(); + // outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), view.getHeight() / 2); + outline.setConvexPath(test); + } +} + export class Shadow { static DEFAULT_SHAPE = ShapeEnum.RECTANGLE; static DEFAULT_BGCOLOR = '#FFFFFF'; @@ -123,6 +147,15 @@ export class Shadow { // nativeView.setBackgroundDrawable(newBg); // } + + + // const outl = new android.graphics.Outline(); + // nativeView.getOutlineProvider() && nativeView.getOutlineProvider().getOutline(nativeView, outl); + // console.log(nativeView.getOutlineProvider(), nativeView.getOutlineProvider() ? nativeView.getOutlineProvider().getClass() : null, + // outl.isEmpty()); + // TODO: how to detect if view doesn't need this? (button) + nativeView.setOutlineProvider(new MyProvider(tnsView)); + nativeView.setElevation( Shadow.androidDipToPx(nativeView, data.elevation as number), ); @@ -198,7 +231,7 @@ export class Shadow { nativeView.layer.shouldRasterize = data.rasterize; nativeView.layer.rasterizationScale = screen.mainScreen.scale; let shadowPath = null; - if(data.useShadowPath) { + if (data.useShadowPath) { shadowPath = UIBezierPath.bezierPathWithRoundedRectCornerRadius(nativeView.bounds, nativeView.layer.shadowRadius).cgPath; } nativeView.layer.shadowPath = shadowPath; From f37cdeded3a1353d3dcbec0f59a83d53119920f9 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Tue, 26 Feb 2019 10:58:11 -0300 Subject: [PATCH 3/7] weakref and cleanup --- .../nativescript-ngx-shadow/common/shadow.ts | 128 +++++------------- 1 file changed, 36 insertions(+), 92 deletions(-) diff --git a/lib/src/nativescript-ngx-shadow/common/shadow.ts b/lib/src/nativescript-ngx-shadow/common/shadow.ts index 6013228..108600b 100755 --- a/lib/src/nativescript-ngx-shadow/common/shadow.ts +++ b/lib/src/nativescript-ngx-shadow/common/shadow.ts @@ -12,36 +12,32 @@ declare const CGSizeMake: any; declare const UIScreen: any; declare const Array: any; declare const UIBezierPath: any; -const OutProvider: { new() } = android.view.ViewOutlineProvider; - -let LayeredShadow; -let PlainShadow; - -if (isAndroid) { - LayeredShadow = android.graphics.drawable.LayerDrawable.extend({}); - PlainShadow = android.graphics.drawable.GradientDrawable.extend({}); -} - -class MyProvider extends OutProvider { - owner; - constructor(owner) { +const ViewOutlineProvider: { new(); BACKGROUND: any } = android.view.ViewOutlineProvider; + +class ShadowOutlineProvider extends ViewOutlineProvider { + owner: WeakRef; + /** + * Create an outline from a tns view + * @param owner tns view + */ + constructor(owner: any) { super(); - this.owner = owner; + this.owner = new WeakRef(owner); return global.__native(this); } getOutline(view, outline) { - console.log("getOutline"); - const outerRadii = Array.create("float", 8); - outerRadii[0] = outerRadii[1] = Length.toDevicePixels(this.owner.borderTopLeftRadius, 0); - outerRadii[2] = outerRadii[3] = Length.toDevicePixels(this.owner.borderTopRightRadius, 0); - outerRadii[4] = outerRadii[5] = Length.toDevicePixels(this.owner.borderBottomRightRadius, 0); - outerRadii[6] = outerRadii[7] = Length.toDevicePixels(this.owner.borderBottomLeftRadius, 0); - const test = new android.graphics.Path(); - test.addRoundRect(new android.graphics.RectF(0, 0, view.getWidth(), view.getHeight()), outerRadii, android.graphics.Path.Direction.CW) - test.close(); - // outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), view.getHeight() / 2); - outline.setConvexPath(test); + const owner = this.owner.get(); + if (owner) { + const outerRadii = Array.create("float", 8); + outerRadii[0] = outerRadii[1] = Length.toDevicePixels(owner.borderTopLeftRadius, 0); + outerRadii[2] = outerRadii[3] = Length.toDevicePixels(owner.borderTopRightRadius, 0); + outerRadii[4] = outerRadii[5] = Length.toDevicePixels(owner.borderBottomRightRadius, 0); + outerRadii[6] = outerRadii[7] = Length.toDevicePixels(owner.borderBottomLeftRadius, 0); + const backgroundPath = new android.graphics.Path(); + backgroundPath.addRoundRect(new android.graphics.RectF(0, 0, view.getWidth(), view.getHeight()), outerRadii, android.graphics.Path.Direction.CW) + outline.setConvexPath(backgroundPath); + } } } @@ -80,81 +76,29 @@ export class Shadow { ); } - private static isShadow(drawable: any): boolean { - return (drawable instanceof LayeredShadow || drawable instanceof PlainShadow); - } - private static applyOnAndroid(tnsView: any, data: AndroidData) { const nativeView = tnsView.android; - // let shape; - // let overrideBackground = true; let currentBg = nativeView.getBackground(); console.log(tnsView, tnsView.text, "Background: " + (currentBg ? currentBg.getClass().toString() : null)); - // if (currentBg instanceof android.graphics.drawable.RippleDrawable) { // play nice if a ripple is wrapping a shadow - // let rippleBg = currentBg.getDrawable(0); - // if (rippleBg instanceof android.graphics.drawable.InsetDrawable) { - // overrideBackground = false; // this is a button with it's own shadow - // } else if (Shadow.isShadow(rippleBg)) { // if the ripple is wrapping a shadow, strip it - // currentBg = rippleBg; - // } - // } - // if (overrideBackground) { - // if (Shadow.isShadow(currentBg)) { // make sure to have the right background - // currentBg = currentBg instanceof LayeredShadow ? // if layered, get the original background - // currentBg.getDrawable(1) : null; - // } - - // const outerRadii = Array.create("float", 8); - // if (data.cornerRadius === undefined) { - // outerRadii[0] = outerRadii[1] = Length.toDevicePixels(tnsView.borderTopLeftRadius, 0); - // outerRadii[2] = outerRadii[3] = Length.toDevicePixels(tnsView.borderTopRightRadius, 0); - // outerRadii[4] = outerRadii[5] = Length.toDevicePixels(tnsView.borderBottomRightRadius, 0); - // outerRadii[6] = outerRadii[7] = Length.toDevicePixels(tnsView.borderBottomLeftRadius, 0); - // } else { - // java.util.Arrays.fill(outerRadii, Shadow.androidDipToPx(nativeView, data.cornerRadius as number)); - // } - - // // use the user defined color or the default in case the color is TRANSPARENT - // const bgColor = currentBg ? - // (currentBg instanceof android.graphics.drawable.ColorDrawable && currentBg.getColor() ? - // currentBg.getColor() : android.graphics.Color.parseColor(data.bgcolor || Shadow.DEFAULT_BGCOLOR)) : - // android.graphics.Color.parseColor(data.bgcolor || Shadow.DEFAULT_BGCOLOR); - - // let newBg; - - // if (data.shape !== ShapeEnum.RECTANGLE || data.bgcolor || !currentBg) { // replace background - // shape = new PlainShadow(); - // shape.setShape( - // android.graphics.drawable.GradientDrawable[data.shape], - // ); - // shape.setCornerRadii(outerRadii); - // shape.setColor(bgColor); - // newBg = shape; - // } else { // add a layer - // const r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - // shape = new android.graphics.drawable.ShapeDrawable(r); - // shape.getPaint().setColor(bgColor); - // var arr = Array.create(android.graphics.drawable.Drawable, 2); - // arr[0] = shape; - // arr[1] = currentBg; - // const drawable = new LayeredShadow(arr); - // newBg = drawable; - // } - - // nativeView.setBackgroundDrawable(newBg); - // } - - - - // const outl = new android.graphics.Outline(); - // nativeView.getOutlineProvider() && nativeView.getOutlineProvider().getOutline(nativeView, outl); - // console.log(nativeView.getOutlineProvider(), nativeView.getOutlineProvider() ? nativeView.getOutlineProvider().getClass() : null, - // outl.isEmpty()); // TODO: how to detect if view doesn't need this? (button) - nativeView.setOutlineProvider(new MyProvider(tnsView)); + let shouldOverrideOutline = true; + if (currentBg instanceof android.graphics.drawable.RippleDrawable) { // play nice if a ripple is wrapping a shadow + let rippleBg = currentBg.getDrawable(0); + if (rippleBg instanceof android.graphics.drawable.InsetDrawable) { + shouldOverrideOutline = false; + } + } + if (shouldOverrideOutline) { + if (!(nativeView.getOutlineProvider() instanceof ShadowOutlineProvider)) { + nativeView.setOutlineProvider(new ShadowOutlineProvider(tnsView)); + } + } else if (nativeView.getOutlineProvider() instanceof ShadowOutlineProvider) { + // if we shouldn't be overrinding, but are, reset to default + nativeView.setOutlineProvider(ViewOutlineProvider.BACKGROUND); + } nativeView.setElevation( Shadow.androidDipToPx(nativeView, data.elevation as number), From b7875ff1be26dc2937a88d0f5040ba5560fae211 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sat, 6 Apr 2019 01:14:21 -0300 Subject: [PATCH 4/7] always override but respect background --- .../nativescript-ngx-shadow/common/shadow.ts | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/lib/src/nativescript-ngx-shadow/common/shadow.ts b/lib/src/nativescript-ngx-shadow/common/shadow.ts index 108600b..3698dc2 100755 --- a/lib/src/nativescript-ngx-shadow/common/shadow.ts +++ b/lib/src/nativescript-ngx-shadow/common/shadow.ts @@ -12,33 +12,49 @@ declare const CGSizeMake: any; declare const UIScreen: any; declare const Array: any; declare const UIBezierPath: any; -const ViewOutlineProvider: { new(); BACKGROUND: any } = android.view.ViewOutlineProvider; - -class ShadowOutlineProvider extends ViewOutlineProvider { - owner: WeakRef; - /** - * Create an outline from a tns view - * @param owner tns view - */ - constructor(owner: any) { - super(); - this.owner = new WeakRef(owner); - return global.__native(this); - } - getOutline(view, outline) { - const owner = this.owner.get(); - if (owner) { - const outerRadii = Array.create("float", 8); - outerRadii[0] = outerRadii[1] = Length.toDevicePixels(owner.borderTopLeftRadius, 0); - outerRadii[2] = outerRadii[3] = Length.toDevicePixels(owner.borderTopRightRadius, 0); - outerRadii[4] = outerRadii[5] = Length.toDevicePixels(owner.borderBottomRightRadius, 0); - outerRadii[6] = outerRadii[7] = Length.toDevicePixels(owner.borderBottomLeftRadius, 0); - const backgroundPath = new android.graphics.Path(); - backgroundPath.addRoundRect(new android.graphics.RectF(0, 0, view.getWidth(), view.getHeight()), outerRadii, android.graphics.Path.Direction.CW) - outline.setConvexPath(backgroundPath); +const ViewOutlineProvider: { new(); BACKGROUND?: any } = android.view.ViewOutlineProvider; + +let ShadowOutlineProvider: any; + +function initializeShadowOutlineProvider() { + if (ShadowOutlineProvider) { return; } + class ShadowOutlineProviderImpl extends ViewOutlineProvider { + owner: WeakRef; + /** + * Create an outline from a tns view + * @param owner tns view + */ + constructor(owner: any) { + super(); + this.owner = new WeakRef(owner); + return global.__native(this); + } + + getOutline(view: any, outline: any) { + const owner = this.owner.get(); + const viewBg = view.getBackground(); + if (viewBg) { + viewBg.getOutline(outline); + if (!outline.isEmpty() && outline.getAlpha() !== 0) { + return; + } + outline.setEmpty(); + outline.setAlpha(1); + } + if (owner) { + const outerRadii = Array.create("float", 8); + outerRadii[0] = outerRadii[1] = Length.toDevicePixels(owner.borderTopLeftRadius, 0); + outerRadii[2] = outerRadii[3] = Length.toDevicePixels(owner.borderTopRightRadius, 0); + outerRadii[4] = outerRadii[5] = Length.toDevicePixels(owner.borderBottomRightRadius, 0); + outerRadii[6] = outerRadii[7] = Length.toDevicePixels(owner.borderBottomLeftRadius, 0); + const backgroundPath = new android.graphics.Path(); + backgroundPath.addRoundRect(new android.graphics.RectF(0, 0, view.getWidth(), view.getHeight()), outerRadii, android.graphics.Path.Direction.CW) + outline.setConvexPath(backgroundPath); + } } } + ShadowOutlineProvider = ShadowOutlineProviderImpl; } export class Shadow { @@ -79,25 +95,9 @@ export class Shadow { private static applyOnAndroid(tnsView: any, data: AndroidData) { const nativeView = tnsView.android; - - let currentBg = nativeView.getBackground(); - console.log(tnsView, tnsView.text, "Background: " + (currentBg ? currentBg.getClass().toString() : null)); - - // TODO: how to detect if view doesn't need this? (button) - let shouldOverrideOutline = true; - if (currentBg instanceof android.graphics.drawable.RippleDrawable) { // play nice if a ripple is wrapping a shadow - let rippleBg = currentBg.getDrawable(0); - if (rippleBg instanceof android.graphics.drawable.InsetDrawable) { - shouldOverrideOutline = false; - } - } - if (shouldOverrideOutline) { - if (!(nativeView.getOutlineProvider() instanceof ShadowOutlineProvider)) { - nativeView.setOutlineProvider(new ShadowOutlineProvider(tnsView)); - } - } else if (nativeView.getOutlineProvider() instanceof ShadowOutlineProvider) { - // if we shouldn't be overrinding, but are, reset to default - nativeView.setOutlineProvider(ViewOutlineProvider.BACKGROUND); + initializeShadowOutlineProvider(); + if (nativeView.getOutlineProvider() === ViewOutlineProvider.BACKGROUND && !(nativeView.getOutlineProvider() instanceof ShadowOutlineProvider)) { // override all background providers + nativeView.setOutlineProvider(new ShadowOutlineProvider(tnsView)); } nativeView.setElevation( From 316c19461aa5733ef192f5ff4ccad7efe3f6d2d6 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sat, 6 Apr 2019 01:51:58 -0300 Subject: [PATCH 5/7] monkey patch is no longer needed --- .../ng-shadow.directive.ts | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts b/lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts index 81adc1d..9cd8a3b 100755 --- a/lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts +++ b/lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts @@ -47,11 +47,7 @@ export class NativeShadowDirective implements OnInit, OnChanges, AfterViewInit, private iosShadowRapper: View; private eventsBound = false; - constructor(private el: ElementRef, private render: Renderer2) { - if (isAndroid) { - this.originalNSFn = this.el.nativeElement._redrawNativeBackground; //always store the original method - } - } + constructor(private el: ElementRef, private render: Renderer2) { } ngOnInit() { // RadListView calls this multiple times for the same view if (!this.initialized) { @@ -117,10 +113,6 @@ export class NativeShadowDirective implements OnInit, OnChanges, AfterViewInit, this.ngOnInit(); } this.applyShadow(); - if (isAndroid) { - this.previousNSFn = this.el.nativeElement._redrawNativeBackground; // just to maintain compatibility with other patches - this.el.nativeElement._redrawNativeBackground = this.monkeyPatch; - } } private addIosWrapper() { @@ -141,10 +133,6 @@ export class NativeShadowDirective implements OnInit, OnChanges, AfterViewInit, onUnloaded() { this.loaded = false; - - if (isAndroid) { - this.el.nativeElement._redrawNativeBackground = this.originalNSFn; // always revert to the original method - } } ngAfterViewInit() { this.addIosWrapper(); @@ -189,11 +177,6 @@ export class NativeShadowDirective implements OnInit, OnChanges, AfterViewInit, } } - private monkeyPatch = val => { - this.previousNSFn.call(this.el.nativeElement, val); - this.applyShadow(); - }; - private applyShadow() { if ( this.shadow === null || From b6ad5940d39018bc689908ef4efa49a877c47014 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sat, 6 Apr 2019 02:14:29 -0300 Subject: [PATCH 6/7] the extra check isn't needed --- lib/src/nativescript-ngx-shadow/common/shadow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/nativescript-ngx-shadow/common/shadow.ts b/lib/src/nativescript-ngx-shadow/common/shadow.ts index 3698dc2..200e567 100755 --- a/lib/src/nativescript-ngx-shadow/common/shadow.ts +++ b/lib/src/nativescript-ngx-shadow/common/shadow.ts @@ -96,7 +96,7 @@ export class Shadow { const nativeView = tnsView.android; initializeShadowOutlineProvider(); - if (nativeView.getOutlineProvider() === ViewOutlineProvider.BACKGROUND && !(nativeView.getOutlineProvider() instanceof ShadowOutlineProvider)) { // override all background providers + if (nativeView.getOutlineProvider() === ViewOutlineProvider.BACKGROUND) { // override all background providers nativeView.setOutlineProvider(new ShadowOutlineProvider(tnsView)); } From 9d62f96ab6e390bd0dfde9af11f25fafa58f8729 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Tue, 14 May 2019 11:10:30 -0300 Subject: [PATCH 7/7] remove unused variables --- lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts b/lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts index 9cd8a3b..f0a8629 100755 --- a/lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts +++ b/lib/src/nativescript-ngx-shadow/ng-shadow.directive.ts @@ -1,7 +1,6 @@ import { Directive, ElementRef, - HostListener, Input, OnChanges, OnInit, @@ -42,8 +41,6 @@ export class NativeShadowDirective implements OnInit, OnChanges, AfterViewInit, private loaded = false; private initialized = false; - private originalNSFn: any; - private previousNSFn: any; private iosShadowRapper: View; private eventsBound = false;