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

@@ -69,9 +69,8 @@ export function buildUIAndRunTest(controlToTest, testFunction, pageCss?) {
clearPage(); clearPage();
let newPage = getCurrentPage(); let newPage = getCurrentPage();
newPage.content = controlToTest; newPage.content = controlToTest;
if (pageCss) {
newPage.css = pageCss; newPage.css = pageCss;
}
testFunction([controlToTest, newPage]); testFunction([controlToTest, newPage]);
newPage.content = null; newPage.content = null;

View File

@@ -252,13 +252,13 @@ export class DependencyObservable extends Observable implements definition.Depen
let currentValue = entry.effectiveValue; let currentValue = entry.effectiveValue;
let newValue = this.getEffectiveValueAndUpdateEntry(currentValueSource, entry, property); let newValue = this.getEffectiveValueAndUpdateEntry(currentValueSource, entry, property);
if (!property.equalityComparer(currentValue, newValue)) { if (!property.equalityComparer(currentValue, newValue)) {
// // If we fallback to defalutValue - remove propertyEntry. // If we fallback to defalutValue - remove propertyEntry.
// if (entry.valueSource === ValueSource.Default) { if (entry.valueSource === ValueSource.Default) {
// delete this._propertyEntries[property.id]; delete this._propertyEntries[property.id];
// } }
// else { else {
entry.effectiveValue = newValue; entry.effectiveValue = newValue;
// } }
this._onPropertyChanged(property, currentValue, 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) { if (this._context) {
view._onAttached(this._context); view._onAttached(this._context);
} }
super._addViewCore(view, atIndex); super._addViewCore(view, atIndex);
if (this._context) {
view._syncNativeProperties();
}
} }
public _removeViewCore(view: viewCommon.View) { public _removeViewCore(view: viewCommon.View) {
@@ -189,12 +193,14 @@ export class View extends viewCommon.View {
if (this._childrenCount > 0) { if (this._childrenCount > 0) {
// Notify each child for the _onAttached event // Notify each child for the _onAttached event
var that = this; var that = this;
var eachChild = function (child: View): boolean { var eachChild = (child: View): boolean => {
child._onAttached(context); child._onAttached(context);
if (!child._isAddedToNativeVisualTree) { if (!child._isAddedToNativeVisualTree) {
// since we have lazy loading of the android widgets, we need to add the native instances at this point. // 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._isAddedToNativeVisualTree = that._addViewToNativeVisualTree(child);
} }
child._syncNativeProperties();
return true; return true;
} }
this._eachChildView(eachChild); this._eachChildView(eachChild);
@@ -260,7 +266,7 @@ export class View extends viewCommon.View {
padding = this.style.paddingTop; padding = this.style.paddingTop;
padding = this.style.paddingRight; padding = this.style.paddingRight;
padding = this.style.paddingBottom; padding = this.style.paddingBottom;
this._syncNativeProperties();
trace.notifyEvent(this, "_onContextChanged"); trace.notifyEvent(this, "_onContextChanged");
} }

View File

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