Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6c60eab

Browse filesBrowse files
fix(core): ellipsis at the end for Labels with maxLines (#10005)
1 parent b998d40 commit 6c60eab
Copy full SHA for 6c60eab

File tree

5 files changed

+68
-1
lines changed
Filter options

5 files changed

+68
-1
lines changed

‎apps/toolbox/src/main-page.xml

Copy file name to clipboardExpand all lines: apps/toolbox/src/main-page.xml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
<Button text="a11y" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1010
<Button text="box-shadow" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1111
<Button text="css-playground" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
12-
<Button text="datepicker" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
12+
<Button text="datepicker" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1313
<Button text="image-async" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1414
<Button text="image-handling" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
15+
<Button text="labels" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1516
<Button text="list-page" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1617
<Button text="root-layout" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1718
<Button text="switch" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />

‎apps/toolbox/src/pages/labels.ts

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Page, Observable, EventData } from '@nativescript/core';
2+
3+
let page: Page;
4+
5+
export function navigatingTo(args: EventData) {
6+
page = <Page>args.object;
7+
page.bindingContext = new SampleData();
8+
}
9+
10+
export class SampleData extends Observable {}

‎apps/toolbox/src/pages/labels.xml

Copy file name to clipboard
+54Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
2+
<Page.actionBar>
3+
<ActionBar title="Labels and TextView" class="action-bar">
4+
</ActionBar>
5+
</Page.actionBar>
6+
<ScrollView>
7+
<StackLayout padding="20">
8+
<Label text="maxLines 2" fontWeight="bold" />
9+
<Label
10+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
11+
textWrap="true"
12+
maxLines="2"
13+
marginTop="2"
14+
/>
15+
16+
<Label text="maxLines 3" fontWeight="bold" marginTop="6" />
17+
<Label
18+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
19+
textWrap="true"
20+
maxLines="3"
21+
marginTop="2"
22+
/>
23+
24+
<Label text="maxLines 4" fontWeight="bold" marginTop="6" />
25+
<Label
26+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
27+
textWrap="true"
28+
maxLines="4"
29+
marginTop="2"
30+
/>
31+
32+
<Label text="NO textWrap" fontWeight="bold" marginTop="6" />
33+
<Label
34+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
35+
marginTop="2"
36+
/>
37+
38+
<Label text="NO maxLines" fontWeight="bold" marginTop="6" />
39+
<Label
40+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
41+
textWrap="true"
42+
marginTop="2"
43+
/>
44+
45+
<Label text="TextView with maxLines 4" fontWeight="bold" marginTop="6" />
46+
<TextView
47+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
48+
maxLines="4"
49+
textWrap="true"
50+
marginTop="2"
51+
/>
52+
</StackLayout>
53+
</ScrollView>
54+
</Page>

‎packages/core/ui/text-base/index.android.ts

Copy file name to clipboardExpand all lines: packages/core/ui/text-base/index.android.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ export class TextBase extends TextBaseCommon {
468468
nativeTextViewProtected.setMaxLines(Number.MAX_SAFE_INTEGER);
469469
} else {
470470
nativeTextViewProtected.setMaxLines(typeof value === 'string' ? parseInt(value, 10) : value);
471+
nativeTextViewProtected.setEllipsize(android.text.TextUtils.TruncateAt.END);
471472
}
472473
}
473474

‎packages/core/ui/text-base/index.ios.ts

Copy file name to clipboardExpand all lines: packages/core/ui/text-base/index.ios.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export class TextBase extends TextBaseCommon {
244244
}
245245
} else if (nativeTextViewProtected instanceof UILabel) {
246246
nativeTextViewProtected.numberOfLines = numberOfLines;
247+
nativeTextViewProtected.lineBreakMode = NSLineBreakMode.ByTruncatingTail;
247248
} else if (nativeTextViewProtected instanceof UIButton) {
248249
nativeTextViewProtected.titleLabel.numberOfLines = numberOfLines;
249250
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.