@nativescript-community/ui-label 1.2.8 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/label-common.d.ts +3 -4
- package/label-common.js +21 -21
- package/label.android.d.ts +5 -23
- package/label.android.js +22 -62
- package/label.ios.d.ts +5 -6
- package/label.ios.js +25 -29
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [1.2.9](https://github.com/nativescript-community/ui-label/compare/v1.2.8...v1.2.9) (2022-07-22)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
6
14
|
## [1.2.8](https://github.com/nativescript-community/ui-label/compare/v1.2.7...v1.2.8) (2022-04-26)
|
7
15
|
|
8
16
|
**Note:** Version bump only for package @nativescript-community/ui-label
|
package/label-common.d.ts
CHANGED
@@ -2,7 +2,6 @@ import { VerticalTextAlignment } from '@nativescript-community/text';
|
|
2
2
|
import { Color, CssProperty, FormattedString, Property, Style, Label as TNLabel } from '@nativescript/core';
|
3
3
|
import { Label as LabelViewDefinition, LineBreak, TextShadow } from './label';
|
4
4
|
export declare const needFormattedStringComputation: (target: any, propertyKey: string | Symbol, descriptor: PropertyDescriptor) => void;
|
5
|
-
export declare const needFontComputation: (target: any, propertyKey: string | Symbol, descriptor: PropertyDescriptor) => void;
|
6
5
|
export declare abstract class LabelBase extends TNLabel implements LabelViewDefinition {
|
7
6
|
maxLines: string | number;
|
8
7
|
verticalTextAlignment: VerticalTextAlignment;
|
@@ -16,9 +15,9 @@ export declare abstract class LabelBase extends TNLabel implements LabelViewDefi
|
|
16
15
|
minFontSize: number;
|
17
16
|
maxFontSize: number;
|
18
17
|
autoFontSizeStep: number;
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
mCanChangeText: boolean;
|
19
|
+
mNeedFormattedStringComputation: boolean;
|
20
|
+
mNeedFontComputation: boolean;
|
22
21
|
onResumeNativeUpdates(): void;
|
23
22
|
}
|
24
23
|
export declare const htmlProperty: Property<LabelBase, string>;
|
package/label-common.js
CHANGED
@@ -12,41 +12,41 @@ init();
|
|
12
12
|
export const needFormattedStringComputation = function (target, propertyKey, descriptor) {
|
13
13
|
const originalMethod = descriptor.value;
|
14
14
|
descriptor.value = function (...args) {
|
15
|
-
if (!this.
|
16
|
-
this.
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
return originalMethod.apply(this, args);
|
20
|
-
};
|
21
|
-
};
|
22
|
-
export const needFontComputation = function (target, propertyKey, descriptor) {
|
23
|
-
const originalMethod = descriptor.value;
|
24
|
-
descriptor.value = function (...args) {
|
25
|
-
if (!this._canChangeText) {
|
26
|
-
this._needFontComputation = true;
|
15
|
+
if (!this.mCanChangeText) {
|
16
|
+
this.mNeedFormattedStringComputation = true;
|
27
17
|
return;
|
28
18
|
}
|
29
19
|
return originalMethod.apply(this, args);
|
30
20
|
};
|
31
21
|
};
|
22
|
+
// export const needFontComputation = function (target: any, propertyKey: string | Symbol, descriptor: PropertyDescriptor) {
|
23
|
+
// const originalMethod = descriptor.value;
|
24
|
+
// descriptor.value = function (...args: any[]) {
|
25
|
+
// if (!this.mCanChangeText) {
|
26
|
+
// this._needFontComputation = true;
|
27
|
+
// return;
|
28
|
+
// }
|
29
|
+
// return originalMethod.apply(this, args);
|
30
|
+
// };
|
31
|
+
// };
|
32
32
|
let LabelBase = class LabelBase extends TNLabel {
|
33
33
|
constructor() {
|
34
34
|
super(...arguments);
|
35
|
-
this.
|
36
|
-
this.
|
37
|
-
this.
|
35
|
+
this.mCanChangeText = true;
|
36
|
+
this.mNeedFormattedStringComputation = false;
|
37
|
+
this.mNeedFontComputation = false;
|
38
38
|
}
|
39
39
|
onResumeNativeUpdates() {
|
40
40
|
// {N} suspends properties update on `_suspendNativeUpdates`. So we only need to do this in onResumeNativeUpdates
|
41
|
-
this.
|
41
|
+
this.mCanChangeText = false;
|
42
42
|
super.onResumeNativeUpdates();
|
43
|
-
this.
|
44
|
-
if (this.
|
45
|
-
this.
|
43
|
+
this.mCanChangeText = true;
|
44
|
+
if (this.mNeedFormattedStringComputation) {
|
45
|
+
this.mNeedFormattedStringComputation = false;
|
46
46
|
this._setNativeText();
|
47
47
|
}
|
48
|
-
if (this.
|
49
|
-
this.
|
48
|
+
if (this.mNeedFontComputation) {
|
49
|
+
this.mNeedFontComputation = false;
|
50
50
|
this[fontInternalProperty.setNative](this.style.fontInternal);
|
51
51
|
}
|
52
52
|
}
|
package/label.android.d.ts
CHANGED
@@ -6,24 +6,6 @@ import { FontStyle, FontWeight } from '@nativescript/core/ui/styling/font';
|
|
6
6
|
import { Label as LabelViewDefinition, LineBreak } from './label';
|
7
7
|
export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
|
8
8
|
export * from './label-common';
|
9
|
-
declare enum SuspendType {
|
10
|
-
Incremental = 0,
|
11
|
-
Loaded = 1048576,
|
12
|
-
NativeView = 2097152,
|
13
|
-
UISetup = 4194304,
|
14
|
-
IncrementalCountMask = -7340033
|
15
|
-
}
|
16
|
-
declare module '@nativescript/core/ui/core/view-base' {
|
17
|
-
interface ViewBase {
|
18
|
-
_resumeNativeUpdates(type: SuspendType): any;
|
19
|
-
_defaultPaddingTop: number;
|
20
|
-
_defaultPaddingRight: number;
|
21
|
-
_defaultPaddingBottom: number;
|
22
|
-
_defaultPaddingLeft: number;
|
23
|
-
_isPaddingRelative: boolean;
|
24
|
-
_androidView: any;
|
25
|
-
}
|
26
|
-
}
|
27
9
|
declare module '@nativescript/core/ui/text-base' {
|
28
10
|
interface TextBase {
|
29
11
|
_setTappableState(tappable: boolean): any;
|
@@ -42,6 +24,7 @@ declare abstract class LabelBase extends View implements LabelViewDefinition {
|
|
42
24
|
linkUnderline: boolean;
|
43
25
|
html: string;
|
44
26
|
selectable: boolean;
|
27
|
+
_isSingleLine: boolean;
|
45
28
|
mIsSingleLine: boolean;
|
46
29
|
text: string;
|
47
30
|
formattedText: FormattedString;
|
@@ -63,8 +46,8 @@ declare abstract class LabelBase extends View implements LabelViewDefinition {
|
|
63
46
|
paddingRight: CoreTypes.LengthType;
|
64
47
|
paddingBottom: CoreTypes.LengthType;
|
65
48
|
paddingLeft: CoreTypes.LengthType;
|
66
|
-
|
67
|
-
|
49
|
+
mCanChangeText: boolean;
|
50
|
+
mNeedFormattedStringComputation: boolean;
|
68
51
|
onResumeNativeUpdates(): void;
|
69
52
|
get textWrap(): boolean;
|
70
53
|
set textWrap(value: boolean);
|
@@ -77,17 +60,16 @@ declare abstract class LabelBase extends View implements LabelViewDefinition {
|
|
77
60
|
export declare class Label extends LabelBase {
|
78
61
|
nativeViewProtected: com.nativescript.label.EllipsizingTextView;
|
79
62
|
mHandleFontSize: boolean;
|
63
|
+
mTappable: boolean;
|
80
64
|
private mAutoFontSize;
|
81
|
-
private
|
65
|
+
private mDefaultMovementMethod;
|
82
66
|
get nativeTextViewProtected(): com.nativescript.label.EllipsizingTextView;
|
83
67
|
createNativeView(): com.nativescript.label.EllipsizingTextView;
|
84
68
|
private enableAutoSize;
|
85
69
|
private disableAutoSize;
|
86
70
|
createFormattedTextNative(value: any): any;
|
87
71
|
createHTMLString(): globalAndroid.text.SpannableStringBuilder;
|
88
|
-
_tappable: boolean;
|
89
72
|
_setTappableState(tappable: boolean): void;
|
90
73
|
_setNativeText(reset?: boolean): void;
|
91
|
-
_setupUI(context: android.content.Context, atIndex?: number, parentIsLoaded?: boolean): void;
|
92
74
|
}
|
93
75
|
export declare function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string;
|
package/label.android.js
CHANGED
@@ -3,25 +3,17 @@ import { CSSType, Device, FormattedString, Observable, Property, Span, View, boo
|
|
3
3
|
import { Color } from '@nativescript/core/color';
|
4
4
|
import { Font } from '@nativescript/core/ui/styling/font';
|
5
5
|
import { Length, colorProperty, fontInternalProperty, fontSizeProperty, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty } from '@nativescript/core/ui/styling/style-properties';
|
6
|
-
import { letterSpacingProperty, textAlignmentProperty, textDecorationProperty, textTransformProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
|
7
|
-
import {
|
8
|
-
import { layout } from '@nativescript/core/utils/utils';
|
9
|
-
import { autoFontSizeProperty, lineBreakProperty, maxLinesProperty, selectableProperty, textShadowProperty } from './label-common';
|
6
|
+
import { letterSpacingProperty, lineHeightProperty, textAlignmentProperty, textDecorationProperty, textTransformProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
|
7
|
+
import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
|
10
8
|
import lazy from '@nativescript/core/utils/lazy';
|
9
|
+
import { layout } from '@nativescript/core/utils/utils';
|
10
|
+
import { autoFontSizeProperty, lineBreakProperty, selectableProperty, textShadowProperty } from './label-common';
|
11
11
|
export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
|
12
12
|
export * from './label-common';
|
13
13
|
const sdkVersion = lazy(() => parseInt(Device.sdkVersion, 10));
|
14
14
|
let TextView;
|
15
15
|
const CHILD_FORMATTED_TEXT = 'formattedText';
|
16
16
|
const resetSymbol = Symbol('textPropertyDefault');
|
17
|
-
var SuspendType;
|
18
|
-
(function (SuspendType) {
|
19
|
-
SuspendType[SuspendType["Incremental"] = 0] = "Incremental";
|
20
|
-
SuspendType[SuspendType["Loaded"] = 1048576] = "Loaded";
|
21
|
-
SuspendType[SuspendType["NativeView"] = 2097152] = "NativeView";
|
22
|
-
SuspendType[SuspendType["UISetup"] = 4194304] = "UISetup";
|
23
|
-
SuspendType[SuspendType["IncrementalCountMask"] = -7340033] = "IncrementalCountMask";
|
24
|
-
})(SuspendType || (SuspendType = {}));
|
25
17
|
const textProperty = new Property({ name: 'text', defaultValue: '', affectsLayout: true });
|
26
18
|
const formattedTextProperty = new Property({
|
27
19
|
name: 'formattedText',
|
@@ -31,13 +23,14 @@ const formattedTextProperty = new Property({
|
|
31
23
|
export const htmlProperty = new Property({ name: 'html', defaultValue: null, affectsLayout: true });
|
32
24
|
function getHorizontalGravity(textAlignment) {
|
33
25
|
switch (textAlignment) {
|
34
|
-
case 'initial':
|
35
|
-
case 'left':
|
36
|
-
return 8388611; //Gravity.START
|
37
26
|
case 'center':
|
38
27
|
return 1; //Gravity.CENTER_HORIZONTAL
|
39
28
|
case 'right':
|
40
29
|
return 8388613; //Gravity.END
|
30
|
+
default:
|
31
|
+
case 'initial':
|
32
|
+
case 'left':
|
33
|
+
return 8388611; //Gravity.START
|
41
34
|
}
|
42
35
|
}
|
43
36
|
function getVerticalGravity(textAlignment) {
|
@@ -121,8 +114,8 @@ let LabelBase = class LabelBase extends View {
|
|
121
114
|
constructor() {
|
122
115
|
super(...arguments);
|
123
116
|
// for now code is duplicated as Android version is a full rewrite
|
124
|
-
this.
|
125
|
-
this.
|
117
|
+
this.mCanChangeText = true;
|
118
|
+
this.mNeedFormattedStringComputation = false;
|
126
119
|
}
|
127
120
|
get nativeTextViewProtected() {
|
128
121
|
return this.nativeViewProtected;
|
@@ -130,11 +123,11 @@ let LabelBase = class LabelBase extends View {
|
|
130
123
|
_setTappableState(value) { }
|
131
124
|
onResumeNativeUpdates() {
|
132
125
|
// {N} suspends properties update on `_suspendNativeUpdates`. So we only need to do this in onResumeNativeUpdates
|
133
|
-
this.
|
126
|
+
this.mCanChangeText = false;
|
134
127
|
super.onResumeNativeUpdates();
|
135
|
-
this.
|
136
|
-
if (this.
|
137
|
-
this.
|
128
|
+
this.mCanChangeText = true;
|
129
|
+
if (this.mNeedFormattedStringComputation) {
|
130
|
+
this.mNeedFormattedStringComputation = false;
|
138
131
|
this._setNativeText();
|
139
132
|
}
|
140
133
|
}
|
@@ -268,8 +261,8 @@ export class Label extends LabelBase {
|
|
268
261
|
constructor() {
|
269
262
|
super(...arguments);
|
270
263
|
this.mHandleFontSize = true;
|
264
|
+
this.mTappable = false;
|
271
265
|
this.mAutoFontSize = false;
|
272
|
-
this._tappable = false;
|
273
266
|
}
|
274
267
|
get nativeTextViewProtected() {
|
275
268
|
return this.nativeViewProtected;
|
@@ -516,20 +509,20 @@ export class Label extends LabelBase {
|
|
516
509
|
return result;
|
517
510
|
}
|
518
511
|
_setTappableState(tappable) {
|
519
|
-
if (this.
|
520
|
-
this.
|
521
|
-
if (this.
|
512
|
+
if (this.mTappable !== tappable) {
|
513
|
+
this.mTappable = tappable;
|
514
|
+
if (this.mTappable) {
|
522
515
|
this.nativeViewProtected.setMovementMethod(android.text.method.LinkMovementMethod.getInstance());
|
523
516
|
this.nativeViewProtected.setHighlightColor(null);
|
524
517
|
}
|
525
518
|
else {
|
526
|
-
this.nativeViewProtected.setMovementMethod(this.
|
519
|
+
this.nativeViewProtected.setMovementMethod(this.mDefaultMovementMethod);
|
527
520
|
}
|
528
521
|
}
|
529
522
|
}
|
530
523
|
_setNativeText(reset = false) {
|
531
|
-
if (!this.
|
532
|
-
this.
|
524
|
+
if (!this.mCanChangeText) {
|
525
|
+
this.mNeedFormattedStringComputation = true;
|
533
526
|
return;
|
534
527
|
}
|
535
528
|
if (reset) {
|
@@ -552,36 +545,6 @@ export class Label extends LabelBase {
|
|
552
545
|
}
|
553
546
|
this.nativeTextViewProtected.setText(transformedText);
|
554
547
|
}
|
555
|
-
_setupUI(context, atIndex, parentIsLoaded) {
|
556
|
-
if (this._context === context) {
|
557
|
-
return;
|
558
|
-
}
|
559
|
-
else if (this._context) {
|
560
|
-
this._tearDownUI(true);
|
561
|
-
}
|
562
|
-
this._context = context;
|
563
|
-
// This will account for nativeView that is created in createNativeView, recycled
|
564
|
-
// or for backward compatability - set before _setupUI in iOS contructor.
|
565
|
-
let nativeView = this.nativeViewProtected;
|
566
|
-
if (!nativeView) {
|
567
|
-
nativeView = this.createNativeView();
|
568
|
-
}
|
569
|
-
this._androidView = nativeView;
|
570
|
-
// if (nativeView) {
|
571
|
-
// if (this._isPaddingRelative === undefined) {
|
572
|
-
// this._isPaddingRelative = false;
|
573
|
-
// }
|
574
|
-
// this._defaultPaddingTop = 0;
|
575
|
-
// this._defaultPaddingRight = 0;
|
576
|
-
// this._defaultPaddingBottom = 0;
|
577
|
-
// this._defaultPaddingLeft = 0;
|
578
|
-
// }
|
579
|
-
this.setNativeView(nativeView);
|
580
|
-
if (this.parent) {
|
581
|
-
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, undefined);
|
582
|
-
}
|
583
|
-
this._resumeNativeUpdates(SuspendType.UISetup);
|
584
|
-
}
|
585
548
|
}
|
586
549
|
__decorate([
|
587
550
|
profile
|
@@ -592,15 +555,12 @@ __decorate([
|
|
592
555
|
__decorate([
|
593
556
|
profile
|
594
557
|
], Label.prototype, "_setNativeText", null);
|
595
|
-
__decorate([
|
596
|
-
profile
|
597
|
-
], Label.prototype, "_setupUI", null);
|
598
558
|
function getCapitalizedString(str) {
|
599
559
|
const words = str.split(' ');
|
600
560
|
const newWords = [];
|
601
561
|
for (let i = 0, length = words.length; i < length; i++) {
|
602
562
|
const word = words[i].toLowerCase();
|
603
|
-
newWords.push(word.
|
563
|
+
newWords.push(word.substring(0, 1).toUpperCase() + word.substring(1));
|
604
564
|
}
|
605
565
|
return newWords.join(' ');
|
606
566
|
}
|
package/label.ios.d.ts
CHANGED
@@ -10,12 +10,15 @@ declare module '@nativescript/core/ui/text-base' {
|
|
10
10
|
}
|
11
11
|
export declare function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string;
|
12
12
|
export declare class Label extends LabelBase {
|
13
|
-
private
|
13
|
+
private mObserver;
|
14
14
|
nativeViewProtected: UITextView;
|
15
15
|
nativeTextViewProtected: UITextView;
|
16
16
|
attributedString: NSMutableAttributedString;
|
17
|
-
private
|
17
|
+
private mDelegate;
|
18
|
+
private mFixedSize;
|
18
19
|
static DTCORETEXT_INIT: boolean;
|
20
|
+
fontSizeRatio: number;
|
21
|
+
mLastAutoSizeKey: string;
|
19
22
|
createNativeView(): UITextView;
|
20
23
|
initNativeView(): void;
|
21
24
|
disposeNativeView(): void;
|
@@ -23,8 +26,6 @@ export declare class Label extends LabelBase {
|
|
23
26
|
onUnloaded(): void;
|
24
27
|
computeTextHeight(size: CGSize): number;
|
25
28
|
updateTextContainerInset(applyVerticalTextAlignment?: boolean): void;
|
26
|
-
get ios(): UITextView;
|
27
|
-
private _fixedSize;
|
28
29
|
_requestLayoutOnTextChanged(): void;
|
29
30
|
onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
|
30
31
|
_onSizeChanged(): void;
|
@@ -37,8 +38,6 @@ export declare class Label extends LabelBase {
|
|
37
38
|
setTextDecorationAndTransform(): void;
|
38
39
|
createFormattedTextNative(value: FormattedString): any;
|
39
40
|
setFormattedTextDecorationAndTransform(): void;
|
40
|
-
fontSizeRatio: number;
|
41
|
-
_lastAutoSizeKey: string;
|
42
41
|
updateAutoFontSize({ textView, width, height, force, onlyMeasure }: {
|
43
42
|
textView: UITextView;
|
44
43
|
width?: any;
|
package/label.ios.js
CHANGED
@@ -2,11 +2,11 @@ var _a, _b, _c, _d;
|
|
2
2
|
import { createNativeAttributedString, verticalTextAlignmentProperty } from '@nativescript-community/text';
|
3
3
|
import { Color, Font, View } from '@nativescript/core';
|
4
4
|
import { borderBottomWidthProperty, borderLeftWidthProperty, borderRightWidthProperty, borderTopWidthProperty, fontInternalProperty, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty } from '@nativescript/core/ui/styling/style-properties';
|
5
|
-
import { formattedTextProperty, letterSpacingProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
|
6
|
-
import {
|
5
|
+
import { formattedTextProperty, letterSpacingProperty, lineHeightProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
|
6
|
+
import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
|
7
7
|
import { isNullOrUndefined, isString } from '@nativescript/core/utils/types';
|
8
8
|
import { iOSNativeHelper, layout } from '@nativescript/core/utils/utils';
|
9
|
-
import { LabelBase, autoFontSizeProperty, htmlProperty, lineBreakProperty, linkColorProperty, linkUnderlineProperty,
|
9
|
+
import { LabelBase, autoFontSizeProperty, htmlProperty, lineBreakProperty, linkColorProperty, linkUnderlineProperty, needFormattedStringComputation, selectableProperty, textShadowProperty } from './label-common';
|
10
10
|
export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
|
11
11
|
export * from './label-common';
|
12
12
|
const majorVersion = iOSNativeHelper.MajorVersion;
|
@@ -39,24 +39,24 @@ export function getTransformedText(text, textTransform) {
|
|
39
39
|
function lineBreakToLineBreakMode(value) {
|
40
40
|
switch (value) {
|
41
41
|
case 'end':
|
42
|
-
return 4 /* ByTruncatingTail */;
|
42
|
+
return 4 /* NSLineBreakMode.ByTruncatingTail */;
|
43
43
|
case 'start':
|
44
|
-
return 3 /* ByTruncatingHead */;
|
44
|
+
return 3 /* NSLineBreakMode.ByTruncatingHead */;
|
45
45
|
case 'middle':
|
46
|
-
return 5 /* ByTruncatingMiddle */;
|
46
|
+
return 5 /* NSLineBreakMode.ByTruncatingMiddle */;
|
47
47
|
default:
|
48
48
|
case 'none':
|
49
|
-
return 0 /* ByWordWrapping */;
|
49
|
+
return 0 /* NSLineBreakMode.ByWordWrapping */;
|
50
50
|
}
|
51
51
|
}
|
52
52
|
function whiteSpaceToLineBreakMode(value) {
|
53
53
|
switch (value) {
|
54
54
|
case 'initial':
|
55
55
|
case 'normal':
|
56
|
-
return 0 /* ByWordWrapping */;
|
56
|
+
return 0 /* NSLineBreakMode.ByWordWrapping */;
|
57
57
|
default:
|
58
58
|
case 'nowrap':
|
59
|
-
return 4 /* ByTruncatingTail */;
|
59
|
+
return 4 /* NSLineBreakMode.ByTruncatingTail */;
|
60
60
|
}
|
61
61
|
}
|
62
62
|
var LabelUITextViewDelegateImpl = /** @class */ (function (_super) {
|
@@ -124,7 +124,7 @@ export class Label extends LabelBase {
|
|
124
124
|
view.selectable = false;
|
125
125
|
view.backgroundColor = UIColor.clearColor;
|
126
126
|
view.userInteractionEnabled = true;
|
127
|
-
view.dataDetectorTypes = -1 /* All */;
|
127
|
+
view.dataDetectorTypes = -1 /* UIDataDetectorTypes.All */;
|
128
128
|
view.textContainerInset = UIEdgeInsetsZero;
|
129
129
|
view.textContainer.lineFragmentPadding = 0;
|
130
130
|
// ignore font leading just like UILabel does
|
@@ -134,27 +134,27 @@ export class Label extends LabelBase {
|
|
134
134
|
}
|
135
135
|
initNativeView() {
|
136
136
|
super.initNativeView();
|
137
|
-
this.
|
138
|
-
this.
|
139
|
-
this.
|
140
|
-
this.nativeViewProtected.addObserverForKeyPathOptionsContext(this.
|
137
|
+
this.mDelegate = LabelUITextViewDelegateImpl.initWithOwner(new WeakRef(this));
|
138
|
+
this.mObserver = LabelObserverClass.alloc().init();
|
139
|
+
this.mObserver['_owner'] = new WeakRef(this);
|
140
|
+
this.nativeViewProtected.addObserverForKeyPathOptionsContext(this.mObserver, 'contentSize', 1 /* NSKeyValueObservingOptions.New */, null);
|
141
141
|
this.nativeViewProtected.attributedText = this.attributedString;
|
142
142
|
}
|
143
143
|
disposeNativeView() {
|
144
|
-
this.
|
144
|
+
this.mDelegate = null;
|
145
145
|
super.disposeNativeView();
|
146
146
|
// if (this._htmlTapGestureRecognizer) {
|
147
147
|
// this.nativeViewProtected.removeGestureRecognizer(this._htmlTapGestureRecognizer);
|
148
148
|
// this._htmlTapGestureRecognizer = null;
|
149
149
|
// }
|
150
|
-
if (this.
|
151
|
-
this.nativeViewProtected.removeObserverForKeyPath(this.
|
152
|
-
this.
|
150
|
+
if (this.mObserver) {
|
151
|
+
this.nativeViewProtected.removeObserverForKeyPath(this.mObserver, 'contentSize');
|
152
|
+
this.mObserver = null;
|
153
153
|
}
|
154
154
|
}
|
155
155
|
onLoaded() {
|
156
156
|
super.onLoaded();
|
157
|
-
this.nativeTextViewProtected.delegate = this.
|
157
|
+
this.nativeTextViewProtected.delegate = this.mDelegate;
|
158
158
|
}
|
159
159
|
onUnloaded() {
|
160
160
|
this.nativeTextViewProtected.delegate = null;
|
@@ -231,15 +231,11 @@ export class Label extends LabelBase {
|
|
231
231
|
}
|
232
232
|
}
|
233
233
|
}
|
234
|
-
// @ts-ignore
|
235
|
-
get ios() {
|
236
|
-
return this.nativeViewProtected;
|
237
|
-
}
|
238
234
|
_requestLayoutOnTextChanged() {
|
239
|
-
if (this.
|
235
|
+
if (this.mFixedSize === FixedSize.BOTH) {
|
240
236
|
return;
|
241
237
|
}
|
242
|
-
if (this.
|
238
|
+
if (this.mFixedSize === FixedSize.WIDTH && !this.textWrap && this.getMeasuredHeight() > 0) {
|
243
239
|
// Single line label with fixed width will skip request layout on text change.
|
244
240
|
return;
|
245
241
|
}
|
@@ -420,8 +416,8 @@ export class Label extends LabelBase {
|
|
420
416
|
nativeView.font = newFont;
|
421
417
|
}
|
422
418
|
else if (newFont) {
|
423
|
-
if (!this.
|
424
|
-
this.
|
419
|
+
if (!this.mCanChangeText) {
|
420
|
+
this.mNeedFormattedStringComputation = true;
|
425
421
|
return;
|
426
422
|
}
|
427
423
|
this._setNativeText();
|
@@ -670,11 +666,11 @@ export class Label extends LabelBase {
|
|
670
666
|
let expectFont = (this.style.fontInternal || Font.default).getUIFont(UIFont.systemFontOfSize(fontSize));
|
671
667
|
//if we are not on the "default" font size we need to measure again or we could break
|
672
668
|
//the layout behavior like for flexbox where there are multiple measure passes
|
673
|
-
if (!force && autoSizeKey === this.
|
669
|
+
if (!force && autoSizeKey === this.mLastAutoSizeKey && expectFont.pointSize === textView.font.pointSize) {
|
674
670
|
return null;
|
675
671
|
}
|
676
672
|
currentFont = textView.font;
|
677
|
-
this.
|
673
|
+
this.mLastAutoSizeKey = autoSizeKey;
|
678
674
|
const nbLines = textView.textContainer.maximumNumberOfLines;
|
679
675
|
// we need to reset verticalTextAlignment or computation will be wrong
|
680
676
|
this.updateTextContainerInset(false);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/ui-label",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.9",
|
4
4
|
"description": "Alternative to the built-in NativeScript Label but with better performance and additional features such as HTML rendering and more.",
|
5
5
|
"main": "./label",
|
6
6
|
"sideEffects": false,
|
@@ -34,5 +34,5 @@
|
|
34
34
|
"dependencies": {
|
35
35
|
"@nativescript-community/text": "^1.4.36"
|
36
36
|
},
|
37
|
-
"gitHead": "
|
37
|
+
"gitHead": "7adb2579ca2d8f292770a8daaa12867f520e0bd7"
|
38
38
|
}
|