Fix the LayoutParams

This commit is contained in:
Panayot Cankov
2016-09-30 17:36:17 +03:00
parent 943e67a4c8
commit b5ab387ebd
4 changed files with 28 additions and 15 deletions

View File

@@ -252,13 +252,13 @@ export class DependencyObservable extends Observable implements definition.Depen
let currentValue = entry.effectiveValue;
let newValue = this.getEffectiveValueAndUpdateEntry(currentValueSource, entry, property);
if (!property.equalityComparer(currentValue, newValue)) {
// // If we fallback to defalutValue - remove propertyEntry.
// if (entry.valueSource === ValueSource.Default) {
// delete this._propertyEntries[property.id];
// }
// else {
entry.effectiveValue = newValue;
// }
// If we fallback to defalutValue - remove propertyEntry.
if (entry.valueSource === ValueSource.Default) {
delete this._propertyEntries[property.id];
}
else {
entry.effectiveValue = newValue;
}
this._onPropertyChanged(property, currentValue, newValue);
}

View File

@@ -150,12 +150,16 @@ export class View extends viewCommon.View {
}
}
public _addViewCore(view: viewCommon.View, atIndex?: number) {
public _addViewCore(view: View, atIndex?: number) {
if (this._context) {
view._onAttached(this._context);
}
super._addViewCore(view, atIndex);
if (this._context) {
view._syncNativeProperties();
}
}
public _removeViewCore(view: viewCommon.View) {
@@ -189,12 +193,14 @@ export class View extends viewCommon.View {
if (this._childrenCount > 0) {
// Notify each child for the _onAttached event
var that = this;
var eachChild = function (child: View): boolean {
var eachChild = (child: View): boolean => {
child._onAttached(context);
if (!child._isAddedToNativeVisualTree) {
// since we have lazy loading of the android widgets, we need to add the native instances at this point.
child._isAddedToNativeVisualTree = that._addViewToNativeVisualTree(child);
}
child._syncNativeProperties();
return true;
}
this._eachChildView(eachChild);
@@ -260,7 +266,7 @@ export class View extends viewCommon.View {
padding = this.style.paddingTop;
padding = this.style.paddingRight;
padding = this.style.paddingBottom;
this._syncNativeProperties();
trace.notifyEvent(this, "_onContextChanged");
}

View File

@@ -51,6 +51,15 @@ const alignContentMap = {
[AlignContent.STRETCH]: FlexboxLayoutWidget.ALIGN_CONTENT_STRETCH
}
const alignSelfMap = {
[AlignSelf.AUTO]: FlexboxLayoutWidget.LayoutParams.ALIGN_SELF_AUTO,
[AlignSelf.FLEX_START]: FlexboxLayoutWidget.LayoutParams.ALIGN_SELF_FLEX_START,
[AlignSelf.FLEX_END]: FlexboxLayoutWidget.LayoutParams.ALIGN_SELF_FLEX_END,
[AlignSelf.CENTER]: FlexboxLayoutWidget.LayoutParams.ALIGN_SELF_CENTER,
[AlignSelf.BASELINE]: FlexboxLayoutWidget.LayoutParams.ALIGN_SELF_BASELINE,
[AlignSelf.STRETCH]: FlexboxLayoutWidget.LayoutParams.ALIGN_SELF_STRETCH
}
export class FlexboxLayout extends FlexboxLayoutBase {
private _layout: FlexboxLayoutWidget;
@@ -109,8 +118,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
protected onAlignSelfPropertyChanged(view: View, oldValue: AlignSelf, newValue: AlignSelf): void {
console.log("align-self changed: " + newValue + " " + view);
// TODO: Map the align self enum:
// this.setLayoutParamsProperty(view, lp => lp.alignSelf = newValue);
this.setLayoutParamsProperty(view, lp => lp.alignSelf = alignSelfMap[newValue]);
}
private setLayoutParamsProperty(view: View, setter: (lp: org.nativescript.widgets.FlexboxLayout.LayoutParams) => void) {