mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
GridLayout now calls virtual methods when rows/columns are set through XML.
Added test. Improved code readability.
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
import layouts = require("ui/layouts/layout-base");
|
||||
import definition = require("ui/layouts/stack-layout");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import enums = require("ui/enums");
|
||||
import proxy = require("ui/core/proxy");
|
||||
import definition = require("ui/layouts/stack-layout");
|
||||
import platform = require("platform");
|
||||
import {LayoutBase} from "ui/layouts/layout-base";
|
||||
import {View} from "ui/core/view";
|
||||
import {Orientation} from "ui/enums";
|
||||
import {PropertyMetadata} from "ui/core/proxy";
|
||||
import {Property, PropertyMetadataSettings} from "ui/core/dependency-observable";
|
||||
|
||||
// on Android we explicitly set propertySettings to None because android will invalidate its layout (skip unnecessary native call).
|
||||
var AffectsLayout = platform.device.os === platform.platformNames.android ? dependencyObservable.PropertyMetadataSettings.None : dependencyObservable.PropertyMetadataSettings.AffectsLayout;
|
||||
var AffectsLayout = platform.device.os === platform.platformNames.android ? PropertyMetadataSettings.None : PropertyMetadataSettings.AffectsLayout;
|
||||
|
||||
function validateOrientation(value: any): boolean {
|
||||
return value === enums.Orientation.vertical || value === enums.Orientation.horizontal;
|
||||
return value === Orientation.vertical || value === Orientation.horizontal;
|
||||
}
|
||||
|
||||
export class StackLayout extends layouts.LayoutBase implements definition.StackLayout {
|
||||
|
||||
public static orientationProperty = new dependencyObservable.Property("orientation","StackLayout",
|
||||
new proxy.PropertyMetadata(enums.Orientation.vertical, AffectsLayout, undefined, validateOrientation));
|
||||
export class StackLayout extends LayoutBase implements definition.StackLayout {
|
||||
public static orientationProperty = new Property("orientation", "StackLayout", new PropertyMetadata(Orientation.vertical, AffectsLayout, undefined, validateOrientation));
|
||||
|
||||
get orientation(): string {
|
||||
return this._getValue(StackLayout.orientationProperty);
|
||||
|
||||
Reference in New Issue
Block a user