| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ export function loadExamples() { | |||
| 21 | 21 | examples.set("pgrid", "layouts-percent/grid"); | |
| 22 | 22 | examples.set("pstack", "layouts-percent/stack"); | |
| 23 | 23 | examples.set("pwrap", "layouts-percent/wrap"); | |
| 24 | + examples.set("stacklayout-6059", "layouts/stacklayout-6059"); | ||
| 24 | 25 | ||
| 25 | 26 | return examples; | |
| 26 | 27 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,40 @@ | |||
| 1 | + <Page class="page" xmlns="http://schemas.nativescript.org/tns.xsd"> | ||
| 2 | + | ||
| 3 | + <StackLayout> | ||
| 4 | + <StackLayout orientation="horizontal"> | ||
| 5 | + <StackLayout backgroundColor="GoldenRod"> | ||
| 6 | + <Label text="overflowing text, overflow"></Label> | ||
| 7 | + </StackLayout> | ||
| 8 | + <StackLayout backgroundColor="LemonChiffon"> | ||
| 9 | + <Label text="overflowing text, overflowing text"></Label> | ||
| 10 | + </StackLayout> | ||
| 11 | + <StackLayout backgroundColor="LightBlue"> | ||
| 12 | + <Label text="overflowing text, overflowing text"></Label> | ||
| 13 | + </StackLayout> | ||
| 14 | + <StackLayout backgroundColor="HotPink"> | ||
| 15 | + <Label text="overflowing text, overflowing text"></Label> | ||
| 16 | + </StackLayout> | ||
| 17 | + </StackLayout> | ||
| 18 | + | ||
| 19 | + <StackLayout orientation="horizontal"> | ||
| 20 | + <Label text="overflowing text, overflow" backgroundColor="LightBlue"></Label> | ||
| 21 | + <Label text="overflowing text, overflowing text" backgroundColor="LightGray"></Label> | ||
| 22 | + <Label text="overflowing text, overflowing text" backgroundColor="HotPink"></Label> | ||
| 23 | + <Label text="overflowing text, overflowing text" backgroundColor="Yellow"></Label> | ||
| 24 | + </StackLayout> | ||
| 25 | + | ||
| 26 | + <StackLayout orientation="horizontal"> | ||
| 27 | + <Label text="overflowing text, overflowing text" backgroundColor="GoldenRod" textWrap="true"></Label> | ||
| 28 | + <Label text="overflowing text, overflowing text" backgroundColor="LemonChiffon" textWrap="true"></Label> | ||
| 29 | + <Label text="overflowing text, overflowing text" backgroundColor="LightBlue" textWrap="true"></Label> | ||
| 30 | + </StackLayout> | ||
| 31 | + | ||
| 32 | + <StackLayout orientation="horizontal"> | ||
| 33 | + <Label text="1 2 3 4 5 6 7 8 9 0" backgroundColor="LightBlue" textWrap="true"></Label> | ||
| 34 | + <Label text="1 2 3 4 5 6 7 8 9 0" backgroundColor="LightGray" textWrap="true"></Label> | ||
| 35 | + <Label text="1 2 3 4 5 6 7 8 9 0" backgroundColor="HotPink" textWrap="true"></Label> | ||
| 36 | + <Label text="1 2 3 4 5 6 7 8 9 0" backgroundColor="Yellow" textWrap="true"></Label> | ||
| 37 | + </StackLayout> | ||
| 38 | + </StackLayout> | ||
| 39 | + | ||
| 40 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,11 +68,25 @@ export class Label extends TextBase implements LabelDefinition { | |||
| 68 | 68 | this._fixedSize = (widthMode === layout.EXACTLY ? FixedSize.WIDTH : FixedSize.NONE) | |
| 69 | 69 | | (heightMode === layout.EXACTLY ? FixedSize.HEIGHT : FixedSize.NONE); | |
| 70 | 70 | ||
| 71 | - // NOTE: utils.measureNativeView(...) relies on UIView.sizeThatFits(...) that | ||
| 72 | - // seems to have various issues when laying out UILabel instances. | ||
| 73 | - // We use custom measure logic here that relies on overriden | ||
| 74 | - // UILabel.textRectForBounds:limitedToNumberOfLines: in TNSLabel widget. | ||
| 75 | - const nativeSize = this._measureNativeView(width, widthMode, height, heightMode); | ||
| 71 | + let nativeSize; | ||
| 72 | + if (this.textWrap) { | ||
| 73 | + // https://github.com/NativeScript/NativeScript/issues/4834 | ||
| 74 | + // NOTE: utils.measureNativeView(...) relies on UIView.sizeThatFits(...) that | ||
| 75 | + // seems to have various issues when laying out UILabel instances. | ||
| 76 | + // We use custom measure logic here that relies on overriden | ||
| 77 | + // UILabel.textRectForBounds:limitedToNumberOfLines: in TNSLabel widget. | ||
| 78 | + nativeSize = this._measureNativeView(width, widthMode, height, heightMode); | ||
| 79 | + } else { | ||
| 80 | + // https://github.com/NativeScript/NativeScript/issues/6059 | ||
| 81 | + // NOTE: _measureNativeView override breaks a scenario with StackLayout that arranges | ||
| 82 | + // labels horizontally (with textWrap=false) e.g. we are measuring label #2 within 356px, | ||
| 83 | + // label #2 needs more, and decides to show ellipsis(...) but because of this its native size | ||
| 84 | + // returned from UILabel.textRectForBounds:limitedToNumberOfLines: logic becomes 344px, so | ||
| 85 | + // StackLayout tries to measure label #3 within the remaining 12px which is wrong; | ||
| 86 | + // label #2 with ellipsis should take the whole 356px and label #3 should not be visible at all. | ||
| 87 | + nativeSize = layout.measureNativeView(nativeView, width, widthMode, height, heightMode); | ||
| 88 | + } | ||
| 89 | + | ||
| 76 | 90 | let labelWidth = nativeSize.width; | |
| 77 | 91 | ||
| 78 | 92 | if (this.textWrap && widthMode === layout.AT_MOST) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments