@nativescript-community/ui-label 1.2.5 → 1.2.8
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 +24 -0
- package/label-common.d.ts +1 -1
- package/label-common.js +3 -3
- package/label.ios.js +24 -13
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,30 @@
|
|
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.8](https://github.com/nativescript-community/ui-label/compare/v1.2.7...v1.2.8) (2022-04-26)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [1.2.7](https://github.com/nativescript-community/ui-label/compare/v1.2.6...v1.2.7) (2022-04-05)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
## [1.2.6](https://github.com/nativescript-community/ui-label/compare/v1.2.5...v1.2.6) (2022-02-09)
|
23
|
+
|
24
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
6
30
|
## [1.2.5](https://github.com/nativescript-community/ui-label/compare/v1.2.4...v1.2.5) (2022-02-09)
|
7
31
|
|
8
32
|
**Note:** Version bump only for package @nativescript-community/ui-label
|
package/label-common.d.ts
CHANGED
@@ -22,7 +22,7 @@ export declare abstract class LabelBase extends TNLabel implements LabelViewDefi
|
|
22
22
|
onResumeNativeUpdates(): void;
|
23
23
|
}
|
24
24
|
export declare const htmlProperty: Property<LabelBase, string>;
|
25
|
-
export declare const maxLinesProperty:
|
25
|
+
export declare const maxLinesProperty: Property<LabelBase, number>;
|
26
26
|
export declare const lineBreakProperty: CssProperty<Style, string>;
|
27
27
|
export declare const linkColorProperty: CssProperty<Style, Color>;
|
28
28
|
export declare const linkUnderlineProperty: CssProperty<Style, boolean>;
|
package/label-common.js
CHANGED
@@ -92,11 +92,11 @@ export const htmlProperty = new Property({
|
|
92
92
|
affectsLayout: global.isAndroid
|
93
93
|
});
|
94
94
|
htmlProperty.register(LabelBase);
|
95
|
-
export const maxLinesProperty = new
|
95
|
+
export const maxLinesProperty = new Property({
|
96
96
|
name: 'maxLines',
|
97
|
-
|
97
|
+
affectsLayout: global.isAndroid
|
98
98
|
});
|
99
|
-
maxLinesProperty.register(
|
99
|
+
maxLinesProperty.register(LabelBase);
|
100
100
|
export const lineBreakProperty = new CssProperty({
|
101
101
|
name: 'lineBreak',
|
102
102
|
cssName: 'line-break'
|
package/label.ios.js
CHANGED
@@ -85,13 +85,13 @@ var LabelUITextViewDelegateImpl = /** @class */ (function (_super) {
|
|
85
85
|
LabelUITextViewDelegateImpl.ObjCProtocols = [UITextViewDelegate];
|
86
86
|
return LabelUITextViewDelegateImpl;
|
87
87
|
}(NSObject));
|
88
|
-
var
|
89
|
-
__extends(
|
90
|
-
function
|
88
|
+
var LabelObserverClass = /** @class */ (function (_super) {
|
89
|
+
__extends(LabelObserverClass, _super);
|
90
|
+
function LabelObserverClass() {
|
91
91
|
return _super !== null && _super.apply(this, arguments) || this;
|
92
92
|
}
|
93
93
|
// NOTE: Refactor this - use Typescript property instead of strings....
|
94
|
-
|
94
|
+
LabelObserverClass.prototype.observeValueForKeyPathOfObjectChangeContext = function (path, tv) {
|
95
95
|
if (path === 'contentSize') {
|
96
96
|
var owner = this._owner && this._owner.get();
|
97
97
|
if (owner) {
|
@@ -99,7 +99,7 @@ var ObserverClass = /** @class */ (function (_super) {
|
|
99
99
|
}
|
100
100
|
}
|
101
101
|
};
|
102
|
-
return
|
102
|
+
return LabelObserverClass;
|
103
103
|
}(NSObject));
|
104
104
|
export class Label extends LabelBase {
|
105
105
|
constructor() {
|
@@ -135,7 +135,7 @@ export class Label extends LabelBase {
|
|
135
135
|
initNativeView() {
|
136
136
|
super.initNativeView();
|
137
137
|
this._delegate = LabelUITextViewDelegateImpl.initWithOwner(new WeakRef(this));
|
138
|
-
this._observer =
|
138
|
+
this._observer = LabelObserverClass.alloc().init();
|
139
139
|
this._observer['_owner'] = new WeakRef(this);
|
140
140
|
this.nativeViewProtected.addObserverForKeyPathOptionsContext(this._observer, 'contentSize', 1 /* New */, null);
|
141
141
|
this.nativeViewProtected.attributedText = this.attributedString;
|
@@ -266,7 +266,7 @@ export class Label extends LabelBase {
|
|
266
266
|
}
|
267
267
|
}
|
268
268
|
const desiredSize = layout.measureNativeView(nativeView, width, widthMode, height, heightMode);
|
269
|
-
if (resetFont) {
|
269
|
+
if (!this.formattedText && !this.html && resetFont) {
|
270
270
|
nativeView.font = resetFont;
|
271
271
|
}
|
272
272
|
const labelWidth = widthMode === layout.AT_MOST ? Math.min(desiredSize.width, width) : desiredSize.width;
|
@@ -307,7 +307,7 @@ export class Label extends LabelBase {
|
|
307
307
|
fontSize,
|
308
308
|
familyName,
|
309
309
|
fontWeight,
|
310
|
-
color: this.color,
|
310
|
+
// color: this.color,
|
311
311
|
letterSpacing: this.letterSpacing,
|
312
312
|
lineHeight: this.lineHeight,
|
313
313
|
textAlignment: this.nativeTextViewProtected.textAlignment
|
@@ -346,7 +346,12 @@ export class Label extends LabelBase {
|
|
346
346
|
}
|
347
347
|
else {
|
348
348
|
if (this.formattedText || this.html) {
|
349
|
-
this.
|
349
|
+
if (this.html) {
|
350
|
+
this.updateHTMLString();
|
351
|
+
}
|
352
|
+
else {
|
353
|
+
super._setNativeText();
|
354
|
+
}
|
350
355
|
}
|
351
356
|
else {
|
352
357
|
this.nativeTextViewProtected.textColor = color;
|
@@ -454,6 +459,10 @@ export class Label extends LabelBase {
|
|
454
459
|
else {
|
455
460
|
super._setNativeText();
|
456
461
|
}
|
462
|
+
if (this.color) {
|
463
|
+
const color = this.color instanceof Color ? this.color.ios : this.color;
|
464
|
+
this._setColor(color);
|
465
|
+
}
|
457
466
|
this.updateTextContainerInset();
|
458
467
|
this._requestLayoutOnTextChanged();
|
459
468
|
}
|
@@ -657,7 +666,11 @@ export class Label extends LabelBase {
|
|
657
666
|
return currentFont;
|
658
667
|
}
|
659
668
|
const autoSizeKey = fixedWidth + '_' + fixedHeight;
|
660
|
-
|
669
|
+
const fontSize = this.style.fontSize || 17;
|
670
|
+
let expectFont = (this.style.fontInternal || Font.default).getUIFont(UIFont.systemFontOfSize(fontSize));
|
671
|
+
//if we are not on the "default" font size we need to measure again or we could break
|
672
|
+
//the layout behavior like for flexbox where there are multiple measure passes
|
673
|
+
if (!force && autoSizeKey === this._lastAutoSizeKey && expectFont.pointSize === textView.font.pointSize) {
|
661
674
|
return null;
|
662
675
|
}
|
663
676
|
currentFont = textView.font;
|
@@ -665,9 +678,6 @@ export class Label extends LabelBase {
|
|
665
678
|
const nbLines = textView.textContainer.maximumNumberOfLines;
|
666
679
|
// we need to reset verticalTextAlignment or computation will be wrong
|
667
680
|
this.updateTextContainerInset(false);
|
668
|
-
const fontSize = this.style.fontSize || 17;
|
669
|
-
let expectFont = (this.style.fontInternal || Font.default).getUIFont(UIFont.systemFontOfSize(fontSize));
|
670
|
-
//first reset the font size
|
671
681
|
let expectSize;
|
672
682
|
const stepSize = this.autoFontSizeStep || 1;
|
673
683
|
const updateFontSize = (font) => {
|
@@ -678,6 +688,7 @@ export class Label extends LabelBase {
|
|
678
688
|
textView.font = font;
|
679
689
|
}
|
680
690
|
};
|
691
|
+
//first reset the font size
|
681
692
|
updateFontSize(expectFont);
|
682
693
|
const size = () => {
|
683
694
|
if (nbLines === 1) {
|
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.8",
|
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,
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"license": "Apache-2.0",
|
33
33
|
"readmeFilename": "README.md",
|
34
34
|
"dependencies": {
|
35
|
-
"@nativescript-community/text": "^1.4.
|
35
|
+
"@nativescript-community/text": "^1.4.36"
|
36
36
|
},
|
37
|
-
"gitHead": "
|
37
|
+
"gitHead": "3ca6ba169723fcb4190268c2a9f8f47ba74f26aa"
|
38
38
|
}
|