mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
setStyle implementation + test
This commit is contained in:
@ -613,6 +613,20 @@ export var testIsVisible = function () {
|
||||
});
|
||||
}
|
||||
|
||||
export var testSetStyle = function () {
|
||||
var lbl = new label.Label();
|
||||
|
||||
var expectedColor = "#ff0000";
|
||||
var expectedBackgroundColor = "#ff0000";
|
||||
|
||||
lbl.setStyle(`color: ${expectedColor};background-color: ${expectedBackgroundColor};`);
|
||||
|
||||
helper.buildUIAndRunTest(lbl, function (views: Array<viewModule.View>) {
|
||||
TKUnit.assert(lbl.color.hex === expectedColor, "Actual: " + lbl.color.hex + "; Expected: " + expectedColor);
|
||||
TKUnit.assert(lbl.backgroundColor.hex === expectedBackgroundColor, "Actual: " + lbl.backgroundColor.hex + "; Expected: " + expectedBackgroundColor);
|
||||
});
|
||||
}
|
||||
|
||||
export var testBorderWidth = function () {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
|
||||
var lbl = <label.Label>views[0];
|
||||
|
@ -923,6 +923,12 @@ export class View extends proxy.ProxyObject implements definition.View {
|
||||
return false;
|
||||
}
|
||||
|
||||
public setStyle(style: string): void {
|
||||
if (types.isString(style)) {
|
||||
this._applyInlineStyle(style);
|
||||
}
|
||||
}
|
||||
|
||||
public _updateLayout() {
|
||||
// needed for iOS.
|
||||
}
|
||||
|
6
ui/core/view.d.ts
vendored
6
ui/core/view.d.ts
vendored
@ -356,6 +356,12 @@ declare module "ui/core/view" {
|
||||
*/
|
||||
public focus(): boolean;
|
||||
|
||||
/**
|
||||
* Sets in-line CSS string as style.
|
||||
* @param style - In-line CSS string.
|
||||
*/
|
||||
public setStyle(style: string) : void;
|
||||
|
||||
public getGestureObservers(type: gestures.GestureTypes): Array<gestures.GesturesObserver>;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user