mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix(core): ellipsis at the end for Labels with maxLines (#10005)
This commit is contained in:
@ -9,9 +9,10 @@
|
||||
<Button text="a11y" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="box-shadow" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="css-playground" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="datepicker" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="datepicker" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="image-async" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="image-handling" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="labels" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="list-page" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="root-layout" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
<Button text="switch" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
|
||||
|
10
apps/toolbox/src/pages/labels.ts
Normal file
10
apps/toolbox/src/pages/labels.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { Page, Observable, EventData } from '@nativescript/core';
|
||||
|
||||
let page: Page;
|
||||
|
||||
export function navigatingTo(args: EventData) {
|
||||
page = <Page>args.object;
|
||||
page.bindingContext = new SampleData();
|
||||
}
|
||||
|
||||
export class SampleData extends Observable {}
|
54
apps/toolbox/src/pages/labels.xml
Normal file
54
apps/toolbox/src/pages/labels.xml
Normal file
@ -0,0 +1,54 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="Labels and TextView" class="action-bar">
|
||||
</ActionBar>
|
||||
</Page.actionBar>
|
||||
<ScrollView>
|
||||
<StackLayout padding="20">
|
||||
<Label text="maxLines 2" fontWeight="bold" />
|
||||
<Label
|
||||
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."
|
||||
textWrap="true"
|
||||
maxLines="2"
|
||||
marginTop="2"
|
||||
/>
|
||||
|
||||
<Label text="maxLines 3" fontWeight="bold" marginTop="6" />
|
||||
<Label
|
||||
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."
|
||||
textWrap="true"
|
||||
maxLines="3"
|
||||
marginTop="2"
|
||||
/>
|
||||
|
||||
<Label text="maxLines 4" fontWeight="bold" marginTop="6" />
|
||||
<Label
|
||||
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."
|
||||
textWrap="true"
|
||||
maxLines="4"
|
||||
marginTop="2"
|
||||
/>
|
||||
|
||||
<Label text="NO textWrap" fontWeight="bold" marginTop="6" />
|
||||
<Label
|
||||
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."
|
||||
marginTop="2"
|
||||
/>
|
||||
|
||||
<Label text="NO maxLines" fontWeight="bold" marginTop="6" />
|
||||
<Label
|
||||
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."
|
||||
textWrap="true"
|
||||
marginTop="2"
|
||||
/>
|
||||
|
||||
<Label text="TextView with maxLines 4" fontWeight="bold" marginTop="6" />
|
||||
<TextView
|
||||
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."
|
||||
maxLines="4"
|
||||
textWrap="true"
|
||||
marginTop="2"
|
||||
/>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</Page>
|
@ -468,6 +468,7 @@ export class TextBase extends TextBaseCommon {
|
||||
nativeTextViewProtected.setMaxLines(Number.MAX_SAFE_INTEGER);
|
||||
} else {
|
||||
nativeTextViewProtected.setMaxLines(typeof value === 'string' ? parseInt(value, 10) : value);
|
||||
nativeTextViewProtected.setEllipsize(android.text.TextUtils.TruncateAt.END);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,6 +244,7 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
} else if (nativeTextViewProtected instanceof UILabel) {
|
||||
nativeTextViewProtected.numberOfLines = numberOfLines;
|
||||
nativeTextViewProtected.lineBreakMode = NSLineBreakMode.ByTruncatingTail;
|
||||
} else if (nativeTextViewProtected instanceof UIButton) {
|
||||
nativeTextViewProtected.titleLabel.numberOfLines = numberOfLines;
|
||||
}
|
||||
|
Reference in New Issue
Block a user