Fixed with another approach.

This commit is contained in:
Nedyalko Nikolov
2016-08-16 17:02:57 +03:00
parent 97a1ad6a7a
commit dc5b7d5bac
2 changed files with 10 additions and 12 deletions

View File

@@ -551,8 +551,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
}
}
public test_SettingTextWhenInFixedSizeGridShouldRequestLayout() {
this.requestLayoutFixture(true, "", () => {
public test_SettingTextWhenInFixedSizeGridShouldNotRequestLayout() {
this.requestLayoutFixture(false, "", () => {
let host = new GridLayout();
host.width = 100;
host.height = 100;
@@ -569,8 +569,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
});
}
public test_SettingTextWhenFixedWidthAndHeightDoesRequestLayout() {
this.requestLayoutFixture(true, "", label => {
public test_SettingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
this.requestLayoutFixture(false, "", label => {
let host = new StackLayout();
label.width = 100;
label.height = 100;

View File

@@ -45,15 +45,13 @@ export class Label extends common.Label {
}
_requestLayoutOnTextChanged(): void {
console.log("requestLayout called --------------------------------------->");
if (this._fixedSize === FixedSize.BOTH) {
return;
}
if (this._fixedSize === FixedSize.WIDTH && !this.textWrap) {
if (this._fixedSize === FixedSize.WIDTH && !this.textWrap && this.getMeasuredHeight() > 0) {
// Single line label with fixed width will skip request layout on text change.
return;
}
console.log("actual requestLayout called --------------------------------------->");
super._requestLayoutOnTextChanged();
}
@@ -74,13 +72,13 @@ export class Label extends common.Label {
height = Number.POSITIVE_INFINITY;
}
if (this.text !== "") {
//if (this.text !== "") {
this._fixedSize = (widthMode === utils.layout.EXACTLY ? FixedSize.WIDTH : FixedSize.NONE)
| (heightMode === utils.layout.EXACTLY ? FixedSize.HEIGHT : FixedSize.NONE);
}
else {
this._fixedSize = FixedSize.NONE;
}
//}
//else {
// this._fixedSize = FixedSize.NONE;
//}
var nativeSize = nativeView.sizeThatFits(CGSizeMake(width, height));
var labelWidth = nativeSize.width;