GridLayout now calls virtual methods when rows/columns are set through XML.

Added test.
Improved code readability.
This commit is contained in:
Hristo Hristov
2016-01-21 13:54:58 +02:00
parent 0eee931948
commit 68cdff85bd
21 changed files with 351 additions and 345 deletions

View File

@@ -1,18 +1,19 @@
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
import common = require("./stack-layout-common");
import enums = require("ui/enums");
import common = require("./stack-layout-common");
import {Orientation} from "ui/enums";
import {PropertyMetadata} from "ui/core/proxy";
import {PropertyChangeData} from "ui/core/dependency-observable";
global.moduleMerge(common, exports);
function setNativeOrientationProperty(data: PropertyChangeData): void {
var stackLayout = <StackLayout>data.object;
var nativeView = stackLayout._nativeView;
nativeView.setOrientation(data.newValue === Orientation.vertical ? org.nativescript.widgets.Orientation.vertical : org.nativescript.widgets.Orientation.horizontal);
}
(<PropertyMetadata>common.StackLayout.orientationProperty.metadata).onSetNativeValue = setNativeOrientationProperty;
export class StackLayout extends common.StackLayout {
static setNativeOrientationProperty(data: dependencyObservable.PropertyChangeData): void {
var stackLayout = <StackLayout>data.object;
var nativeView = stackLayout._nativeView;
nativeView.setOrientation(data.newValue === enums.Orientation.vertical ? org.nativescript.widgets.Orientation.vertical : org.nativescript.widgets.Orientation.horizontal);
}
private _layout: org.nativescript.widgets.StackLayout;
get android(): org.nativescript.widgets.StackLayout {
@@ -26,6 +27,4 @@ export class StackLayout extends common.StackLayout {
public _createUI() {
this._layout = new org.nativescript.widgets.StackLayout(this._context);
}
}
(<proxy.PropertyMetadata>common.StackLayout.orientationProperty.metadata).onSetNativeValue = StackLayout.setNativeOrientationProperty;
}