Use density for clip-path calculations

This commit is contained in:
vakrilov
2017-02-21 14:14:32 +02:00
parent 4bfc8a90c2
commit b34802d7fc

View File

@ -1,6 +1,6 @@
import { View } from "./background-common"; import { View } from "./background-common";
import { isNullOrUndefined, isFunction, getClass } from "utils/types"; import { isNullOrUndefined, isFunction, getClass } from "utils/types";
import { CacheLayerType } from "utils/utils"; import { CacheLayerType, layout } from "utils/utils";
import { parse } from "css-value"; import { parse } from "css-value";
export * from "./background-common" export * from "./background-common"
@ -23,7 +23,7 @@ export module ad {
return ( return (
nativeView instanceof android.widget.Button || nativeView instanceof android.widget.Button ||
(nativeView instanceof android.support.v7.widget.Toolbar (nativeView instanceof android.support.v7.widget.Toolbar
&& getSDK() >= 21 // There is an issue with the DrawableContainer which was fixed for API version 21 and above: https://code.google.com/p/android/issues/detail?id=60183 && getSDK() >= 21 // There is an issue with the DrawableContainer which was fixed for API version 21 and above: https://code.google.com/p/android/issues/detail?id=60183
) )
); );
} }
@ -39,13 +39,13 @@ export module ad {
let cache = <CacheLayerType>view._nativeView; let cache = <CacheLayerType>view._nativeView;
if (isSetColorFilterOnlyWidget(nativeView) if (isSetColorFilterOnlyWidget(nativeView)
&& !isNullOrUndefined(backgroundDrawable) && !isNullOrUndefined(backgroundDrawable)
&& isFunction(backgroundDrawable.setColorFilter) && isFunction(backgroundDrawable.setColorFilter)
&& !background.hasBorderWidth() && !background.hasBorderWidth()
&& !background.hasBorderRadius() && !background.hasBorderRadius()
&& !background.clipPath && !background.clipPath
&& isNullOrUndefined(background.image) && isNullOrUndefined(background.image)
&& !isNullOrUndefined(background.color)) { && !isNullOrUndefined(background.color)) {
let backgroundColor = (<any>backgroundDrawable).backgroundColor = background.color.android; let backgroundColor = (<any>backgroundDrawable).backgroundColor = background.color.android;
backgroundDrawable.setColorFilter(backgroundColor, android.graphics.PorterDuff.Mode.SRC_IN); backgroundDrawable.setColorFilter(backgroundColor, android.graphics.PorterDuff.Mode.SRC_IN);
(<any>backgroundDrawable).backgroundColor = backgroundColor; (<any>backgroundDrawable).backgroundColor = backgroundColor;
@ -57,7 +57,7 @@ export module ad {
_defaultBackgrounds.set(viewClass, nativeView.getBackground()); _defaultBackgrounds.set(viewClass, nativeView.getBackground());
} }
backgroundDrawable = new org.nativescript.widgets.BorderDrawable(1, view.toString()); backgroundDrawable = new org.nativescript.widgets.BorderDrawable(layout.getDisplayDensity(), view.toString());
refreshBorderDrawable(view, <org.nativescript.widgets.BorderDrawable>backgroundDrawable); refreshBorderDrawable(view, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
if (getSDK() >= 16) { if (getSDK() >= 16) {
@ -133,7 +133,7 @@ function refreshBorderDrawable(view: View, borderDrawable: org.nativescript.widg
backgroundSizeParsedCSSValues = createNativeCSSValueArray(background.size); backgroundSizeParsedCSSValues = createNativeCSSValueArray(background.size);
} }
let blackColor = android.graphics.Color.BLACK; let blackColor = android.graphics.Color.BLACK;
borderDrawable.refresh( borderDrawable.refresh(
(background.borderTopColor && background.borderTopColor.android !== undefined) ? background.borderTopColor.android : blackColor, (background.borderTopColor && background.borderTopColor.android !== undefined) ? background.borderTopColor.android : blackColor,