UNPKG

1.57 kBJavaScriptView Raw
1import { TextBase, whiteSpaceProperty } from '../text-base';
2import { profile } from '../../profiling';
3import { CSSType } from '../core/view';
4import { booleanConverter } from '../core/view-base';
5export * from '../text-base';
6let Label = class Label extends TextBase {
7 get textWrap() {
8 return this.style.whiteSpace === 'normal';
9 }
10 set textWrap(value) {
11 if (typeof value === 'string') {
12 value = booleanConverter(value);
13 }
14 this.style.whiteSpace = value ? 'normal' : 'nowrap';
15 }
16 createNativeView() {
17 return new org.nativescript.widgets.StyleableTextView(this._context);
18 }
19 initNativeView() {
20 super.initNativeView();
21 const textView = this.nativeTextViewProtected;
22 textView.setSingleLine(true);
23 textView.setEllipsize(android.text.TextUtils.TruncateAt.END);
24 textView.setGravity(android.view.Gravity.CENTER_VERTICAL);
25 }
26 [whiteSpaceProperty.setNative](value) {
27 // Label initial value is no-wrap. set in initNativeView
28 const newValue = value === 'initial' ? 'nowrap' : value;
29 super[whiteSpaceProperty.setNative](newValue);
30 }
31};
32__decorate([
33 profile,
34 __metadata("design:type", Function),
35 __metadata("design:paramtypes", []),
36 __metadata("design:returntype", void 0)
37], Label.prototype, "createNativeView", null);
38Label = __decorate([
39 CSSType('Label')
40], Label);
41export { Label };
42Label.prototype._isSingleLine = true;
43Label.prototype.recycleNativeView = 'auto';
44//# sourceMappingURL=index.android.js.map
\No newline at end of file