mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Expose special property logic in builder.
Called by the Angular renderer.
This commit is contained in:
3
ui/builder/component-builder.d.ts
vendored
3
ui/builder/component-builder.d.ts
vendored
@ -5,6 +5,9 @@ declare module "ui/builder/component-builder" {
|
||||
export function getComponentModule(elementName: string, namespace: string, attributes: Object, exports: Object): ComponentModule;
|
||||
export function setPropertyValue(instance: view.View, instanceModuleExports: Object, pageExports: Object, propertyName: string, propertyValue: string) : void;
|
||||
|
||||
export var specialProperties: Array<string>;
|
||||
export function setSpecialPropertyValue(instance: view.View, propertyName: string, propertyValue: string): boolean;
|
||||
|
||||
export interface ComponentModule {
|
||||
component: view.View;
|
||||
exports: any;
|
||||
|
@ -29,6 +29,16 @@ var DOCK = "dock";
|
||||
var LEFT = "left";
|
||||
var TOP = "top";
|
||||
|
||||
export var specialProperties: Array<string> = [
|
||||
ROW,
|
||||
COL,
|
||||
COL_SPAN,
|
||||
ROW_SPAN,
|
||||
DOCK,
|
||||
LEFT,
|
||||
TOP,
|
||||
]
|
||||
|
||||
var eventHandlers = {};
|
||||
|
||||
export function getComponentModule(elementName: string, namespace: string, attributes: Object, exports: Object): definition.ComponentModule {
|
||||
@ -112,6 +122,28 @@ export function getComponentModule(elementName: string, namespace: string, attri
|
||||
return componentModule;
|
||||
}
|
||||
|
||||
export function setSpecialPropertyValue(instance: view.View, propertyName: string, propertyValue: string) {
|
||||
if (propertyName === ROW) {
|
||||
gridLayoutModule.GridLayout.setRow(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === COL) {
|
||||
gridLayoutModule.GridLayout.setColumn(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === COL_SPAN) {
|
||||
gridLayoutModule.GridLayout.setColumnSpan(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === ROW_SPAN) {
|
||||
gridLayoutModule.GridLayout.setRowSpan(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === LEFT) {
|
||||
absoluteLayoutDef.AbsoluteLayout.setLeft(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === TOP) {
|
||||
absoluteLayoutDef.AbsoluteLayout.setTop(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === DOCK) {
|
||||
console.log('set dock: ' + propertyName + ' -> ' + propertyValue);
|
||||
dockLayoutDef.DockLayout.setDock(instance, propertyValue);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function setPropertyValue(instance: view.View, instanceModule: Object, exports: Object, propertyName: string, propertyValue: string) {
|
||||
// Note: instanceModule can be null if we are loading custom compnenet with no code-behind.
|
||||
var isEventOrGesture: boolean = isKnownEventOrGesture(propertyName, instance);
|
||||
@ -136,20 +168,8 @@ export function setPropertyValue(instance: view.View, instanceModule: Object, ex
|
||||
if (types.isFunction(handler)) {
|
||||
instance.on(propertyName, handler);
|
||||
}
|
||||
} else if (propertyName === ROW) {
|
||||
gridLayoutModule.GridLayout.setRow(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === COL) {
|
||||
gridLayoutModule.GridLayout.setColumn(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === COL_SPAN) {
|
||||
gridLayoutModule.GridLayout.setColumnSpan(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === ROW_SPAN) {
|
||||
gridLayoutModule.GridLayout.setRowSpan(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === LEFT) {
|
||||
absoluteLayoutDef.AbsoluteLayout.setLeft(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === TOP) {
|
||||
absoluteLayoutDef.AbsoluteLayout.setTop(instance, !isNaN(+propertyValue) && +propertyValue);
|
||||
} else if (propertyName === DOCK) {
|
||||
dockLayoutDef.DockLayout.setDock(instance, propertyValue);
|
||||
} else if (setSpecialPropertyValue(instance, propertyName, propertyValue)) {
|
||||
// Already set by setSpecialPropertyValue
|
||||
} else {
|
||||
var attrHandled = false;
|
||||
|
||||
@ -211,4 +231,4 @@ function isBinding(value: string): boolean {
|
||||
}
|
||||
|
||||
return isBinding;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user