mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
stylers fixed
This commit is contained in:
@@ -96,7 +96,7 @@ class BorderGradientDrawable extends android.graphics.drawable.GradientDrawable
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onBorderPropertyChanged(v: view.View) {
|
function onBorderPropertyChanged(v: view.View) {
|
||||||
if (!this._nativeView) {
|
if (!v._nativeView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +109,10 @@ function onBorderPropertyChanged(v: view.View) {
|
|||||||
nativeView.setBackground(bkg);
|
nativeView.setBackground(bkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var padding = v.borderWidth * utils.layout.getDisplayDensity();
|
||||||
|
|
||||||
|
nativeView.setPadding(padding, padding, padding, padding);
|
||||||
|
|
||||||
bkg.borderWidth = v.borderWidth;
|
bkg.borderWidth = v.borderWidth;
|
||||||
bkg.cornerRadius = v.borderRadius;
|
bkg.cornerRadius = v.borderRadius;
|
||||||
bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT;
|
bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT;
|
||||||
@@ -121,7 +125,7 @@ function onBorderPropertyChanged(v: view.View) {
|
|||||||
export class DefaultStyler implements definition.stylers.Styler {
|
export class DefaultStyler implements definition.stylers.Styler {
|
||||||
//Background methods
|
//Background methods
|
||||||
private static setBackgroundProperty(view: view.View, newValue: any) {
|
private static setBackgroundProperty(view: view.View, newValue: any) {
|
||||||
(<android.view.View>view.android).setBackgroundColor(newValue);
|
onBorderPropertyChanged(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static resetBackgroundProperty(view: view.View, nativeValue: any) {
|
private static resetBackgroundProperty(view: view.View, nativeValue: any) {
|
||||||
@@ -143,12 +147,7 @@ export class DefaultStyler implements definition.stylers.Styler {
|
|||||||
|
|
||||||
//Background image methods
|
//Background image methods
|
||||||
private static setBackgroundImageSourceProperty(view: view.View, newValue: any) {
|
private static setBackgroundImageSourceProperty(view: view.View, newValue: any) {
|
||||||
var nativeView = <android.view.View>view.android;
|
onBorderPropertyChanged(view);
|
||||||
var bmp = <android.graphics.Bitmap>newValue;
|
|
||||||
var d = new android.graphics.drawable.BitmapDrawable(bmp);
|
|
||||||
d.setTileModeXY(android.graphics.Shader.TileMode.REPEAT, android.graphics.Shader.TileMode.REPEAT);
|
|
||||||
d.setDither(true);
|
|
||||||
nativeView.setBackgroundDrawable(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static resetBackgroundImageSourceProperty(view: view.View, nativeValue: any) {
|
private static resetBackgroundImageSourceProperty(view: view.View, nativeValue: any) {
|
||||||
@@ -158,13 +157,7 @@ export class DefaultStyler implements definition.stylers.Styler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static getNativeBackgroundImageSourceValue(view: view.View): any {
|
private static getNativeBackgroundImageSourceValue(view: view.View): any {
|
||||||
var drawable = view.android.getBackground();
|
return view.android.getBackground();
|
||||||
|
|
||||||
if (drawable instanceof android.graphics.drawable.BitmapDrawable) {
|
|
||||||
return drawable;
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Border width methods
|
//Border width methods
|
||||||
|
|||||||
@@ -101,14 +101,14 @@ export class DefaultStyler implements definition.stylers.Styler {
|
|||||||
|
|
||||||
//Border color methods
|
//Border color methods
|
||||||
private static setBorderColorProperty(view: view.View, newValue: any) {
|
private static setBorderColorProperty(view: view.View, newValue: any) {
|
||||||
if (view._nativeView instanceof UIView && newValue instanceof color.Color) {
|
if (view._nativeView instanceof UIView && newValue instanceof UIColor) {
|
||||||
(<UIView>view._nativeView).layer.borderColor = (<color.Color>newValue).ios.CGColor;
|
(<UIView>view._nativeView).layer.borderColor = (<UIColor>newValue).CGColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static resetBorderColorProperty(view: view.View, nativeValue: any) {
|
private static resetBorderColorProperty(view: view.View, nativeValue: any) {
|
||||||
if (view._nativeView instanceof UIView && nativeValue instanceof color.Color) {
|
if (view._nativeView instanceof UIView && nativeValue instanceof UIColor) {
|
||||||
(<UIView>view._nativeView).layer.borderColor = (<color.Color>nativeValue).ios.CGColor;
|
(<UIView>view._nativeView).layer.borderColor = (<UIColor>nativeValue).CGColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user