mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
stylers removed
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import proxy = require("ui/core/proxy");
|
||||
import * as enumsModule from "ui/enums";
|
||||
import style = require("ui/styling/style");
|
||||
import font = require("ui/styling/font");
|
||||
import styling = require("ui/styling");
|
||||
import view = require("ui/core/view");
|
||||
import background = require("ui/styling/background");
|
||||
import utils = require("utils/utils");
|
||||
|
||||
global.moduleMerge(imageCommon, exports);
|
||||
|
||||
@@ -58,3 +64,57 @@ export class Image extends imageCommon.Image {
|
||||
this.android.setImageBitmap(nativeImage);
|
||||
}
|
||||
}
|
||||
|
||||
export class ImageStyler implements style.Styler {
|
||||
// Corner radius
|
||||
private static setBorderRadiusProperty(v: view.View, newValue: any, defaultValue?: any) {
|
||||
if (!v._nativeView) {
|
||||
return;
|
||||
}
|
||||
var val = Math.round(newValue * utils.layout.getDisplayDensity());
|
||||
(<org.nativescript.widgets.ImageView>v._nativeView).setCornerRadius(val);
|
||||
background.ad.onBackgroundOrBorderPropertyChanged(v);
|
||||
}
|
||||
|
||||
private static resetBorderRadiusProperty(v: view.View, nativeValue: any) {
|
||||
if (!v._nativeView) {
|
||||
return;
|
||||
}
|
||||
(<org.nativescript.widgets.ImageView>v._nativeView).setCornerRadius(0);
|
||||
background.ad.onBackgroundOrBorderPropertyChanged(v);
|
||||
}
|
||||
|
||||
// Border width
|
||||
private static setBorderWidthProperty(v: view.View, newValue: any, defaultValue?: any) {
|
||||
if (!v._nativeView) {
|
||||
return;
|
||||
}
|
||||
|
||||
var val = Math.round(newValue * utils.layout.getDisplayDensity());
|
||||
(<org.nativescript.widgets.ImageView>v._nativeView).setBorderWidth(val);
|
||||
background.ad.onBackgroundOrBorderPropertyChanged(v);
|
||||
}
|
||||
|
||||
private static resetBorderWidthProperty(v: view.View, nativeValue: any) {
|
||||
if (!v._nativeView) {
|
||||
return;
|
||||
}
|
||||
(<org.nativescript.widgets.ImageView>v._nativeView).setBorderWidth(0);
|
||||
background.ad.onBackgroundOrBorderPropertyChanged(v);
|
||||
}
|
||||
|
||||
public static registerHandlers() {
|
||||
// Use the same handler for all background/border properties
|
||||
// Note: There is no default value getter - the default value is handled in background.ad.onBackgroundOrBorderPropertyChanged
|
||||
|
||||
style.registerHandler(style.borderRadiusProperty, new style.StylePropertyChangedHandler(
|
||||
ImageStyler.setBorderRadiusProperty,
|
||||
ImageStyler.resetBorderRadiusProperty), "Image");
|
||||
|
||||
style.registerHandler(style.borderWidthProperty, new style.StylePropertyChangedHandler(
|
||||
ImageStyler.setBorderWidthProperty,
|
||||
ImageStyler.resetBorderWidthProperty), "Image");
|
||||
}
|
||||
}
|
||||
|
||||
ImageStyler.registerHandlers();
|
||||
|
||||
Reference in New Issue
Block a user