@nativescript-community/ui-label 1.2.0 → 1.2.1

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 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.1](https://github.com/nativescript-community/ui-label/compare/v1.2.0...v1.2.1) (2022-01-02)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-label
9
+
10
+
11
+
12
+
13
+
6
14
  # [1.2.0](https://github.com/nativescript-community/ui-label/compare/v1.1.25...v1.2.0) (2021-10-20)
7
15
 
8
16
 
package/label.android.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LightFormattedString, createNativeAttributedString, cssProperty, overrideSpanAndFormattedStringEnabled, verticalTextAlignmentProperty } from '@nativescript-community/text';
2
- import { CSSType, FormattedString, Observable, Property, Span, View, booleanConverter, profile } from '@nativescript/core';
2
+ import { CSSType, Device, FormattedString, Observable, Property, Span, View, booleanConverter, profile } from '@nativescript/core';
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';
@@ -7,8 +7,10 @@ import { letterSpacingProperty, textAlignmentProperty, textDecorationProperty, t
7
7
  import { lineHeightProperty } from '@nativescript/core/ui/text-base/text-base-common';
8
8
  import { layout } from '@nativescript/core/utils/utils';
9
9
  import { autoFontSizeProperty, lineBreakProperty, maxLinesProperty, selectableProperty, textShadowProperty } from './label-common';
10
+ import lazy from '@nativescript/core/utils/lazy';
10
11
  export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
11
12
  export * from './label-common';
13
+ const sdkVersion = lazy(() => parseInt(Device.sdkVersion, 10));
12
14
  let TextView;
13
15
  const CHILD_SPAN = 'Span';
14
16
  const CHILD_FORMATTED_TEXT = 'formattedText';
@@ -388,10 +390,21 @@ export class Label extends LabelBase {
388
390
  }
389
391
  }
390
392
  [lineHeightProperty.setNative](value) {
391
- this.nativeTextViewProtected.setLineSpacing(value * layout.getDisplayDensity(), 1);
393
+ if (sdkVersion() >= 28) {
394
+ this.nativeTextViewProtected.setLineHeight(value * layout.getDisplayDensity());
395
+ }
396
+ else {
397
+ const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null);
398
+ this.nativeTextViewProtected.setLineSpacing(value * layout.getDisplayDensity() - fontHeight, 1);
399
+ }
392
400
  }
393
401
  [fontInternalProperty.setNative](value) {
394
- this.nativeTextViewProtected.setTypeface(value instanceof Font ? value.getAndroidTypeface() : value);
402
+ const androidFont = value instanceof Font ? value.getAndroidTypeface() : value;
403
+ this.nativeTextViewProtected.setTypeface(androidFont);
404
+ if (this.lineHeight && sdkVersion() < 28) {
405
+ const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null);
406
+ this.nativeTextViewProtected.setLineSpacing(this.lineHeight * layout.getDisplayDensity() - fontHeight, 1);
407
+ }
395
408
  }
396
409
  [textDecorationProperty.setNative](value) {
397
410
  switch (value) {
package/label.ios.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CoreTypes, FormattedString, Span } from '@nativescript/core';
1
+ import { CoreTypes, FormattedString } from '@nativescript/core';
2
2
  import { LabelBase } from './label-common';
3
3
  export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
4
4
  export * from './label-common';
@@ -6,8 +6,6 @@ declare module '@nativescript/core/ui/text-base' {
6
6
  interface TextBase {
7
7
  _requestLayoutOnTextChanged(): any;
8
8
  _setNativeText(): any;
9
- createMutableStringForSpan?(span: any, text: any): NSMutableAttributedString;
10
- createNSMutableAttributedString?(formattedString: FormattedString): NSMutableAttributedString;
11
9
  }
12
10
  }
13
11
  export declare function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string;
@@ -18,7 +16,6 @@ export declare class Label extends LabelBase {
18
16
  attributedString: NSMutableAttributedString;
19
17
  private _delegate;
20
18
  static DTCORETEXT_INIT: boolean;
21
- constructor();
22
19
  createNativeView(): UITextView;
23
20
  initNativeView(): void;
24
21
  disposeNativeView(): void;
@@ -38,9 +35,8 @@ export declare class Label extends LabelBase {
38
35
  _setSpannablesFontSizeWithRatio(ratio: any): void;
39
36
  _setNativeText(): void;
40
37
  setTextDecorationAndTransform(): void;
41
- currentMaxFontSize: number;
42
- createNSMutableAttributedString(formattedString: FormattedString): NSMutableAttributedString;
43
- createMutableStringForSpan(span: Span, text: string): NSMutableAttributedString;
38
+ createFormattedTextNative(value: FormattedString): any;
39
+ setFormattedTextDecorationAndTransform(): void;
44
40
  fontSizeRatio: number;
45
41
  _lastAutoSizeKey: string;
46
42
  textViewDidChange(textView: UITextView, width?: any, height?: any, force?: boolean): void;
package/label.ios.js CHANGED
@@ -1,9 +1,9 @@
1
1
  var _a, _b, _c, _d;
2
- import { computeBaseLineOffset, createNativeAttributedString, usingIOSDTCoreText, verticalTextAlignmentProperty } from '@nativescript-community/text';
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, textDecorationProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
6
- import { getClosestPropertyValue, lineHeightProperty } from '@nativescript/core/ui/text-base/text-base-common';
5
+ import { formattedTextProperty, letterSpacingProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
6
+ import { lineHeightProperty } 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
9
  import { LabelBase, autoFontSizeProperty, htmlProperty, lineBreakProperty, linkColorProperty, linkUnderlineProperty, maxLinesProperty, needFormattedStringComputation, selectableProperty, textShadowProperty } from './label-common';
@@ -103,14 +103,16 @@ var ObserverClass = /** @class */ (function (_super) {
103
103
  }(NSObject));
104
104
  export class Label extends LabelBase {
105
105
  constructor() {
106
- super();
107
- this.currentMaxFontSize = 0;
106
+ super(...arguments);
108
107
  this.fontSizeRatio = 1;
109
- // if (iOSUseDTCoreText && !Label.DTCORETEXT_INIT) {
110
- // Label.DTCORETEXT_INIT = true;
111
- // DTCoreTextFontDescriptor.asyncPreloadFontLookupTable();
112
- // }
113
108
  }
109
+ // constructor() {
110
+ // super();
111
+ // if (iOSUseDTCoreText && !Label.DTCORETEXT_INIT) {
112
+ // Label.DTCORETEXT_INIT = true;
113
+ // DTCoreTextFontDescriptor.asyncPreloadFontLookupTable();
114
+ // }
115
+ // }
114
116
  createNativeView() {
115
117
  const view = UITextView.new();
116
118
  if (!view.font) {
@@ -123,13 +125,10 @@ export class Label extends LabelBase {
123
125
  view.backgroundColor = UIColor.clearColor;
124
126
  view.userInteractionEnabled = true;
125
127
  view.dataDetectorTypes = -1 /* All */;
126
- view.textContainerInset = {
127
- top: 0,
128
- left: 0,
129
- bottom: 0,
130
- right: 0
131
- };
132
- view.textContainer.lineFragmentPadding = 0; // to remove left padding
128
+ view.textContainerInset = UIEdgeInsetsZero;
129
+ view.textContainer.lineFragmentPadding = 0;
130
+ // ignore font leading just like UILabel does
131
+ view.layoutManager.usesFontLeading = false;
133
132
  // view.textContainer.lineBreakMode = NSLineBreakMode.ByCharWrapping;
134
133
  return view;
135
134
  }
@@ -140,12 +139,6 @@ export class Label extends LabelBase {
140
139
  this._observer['_owner'] = new WeakRef(this);
141
140
  this.nativeViewProtected.addObserverForKeyPathOptionsContext(this._observer, 'contentSize', 1 /* New */, null);
142
141
  this.nativeViewProtected.attributedText = this.attributedString;
143
- // this.htmlText = null;
144
- // this.needsHTMLUpdate = false;
145
- // this.updatingHTML = false;
146
- // if (this.htmlText && this.needsHTMLUpdate) {
147
- // this.updateHTMLString();
148
- // }
149
142
  }
150
143
  disposeNativeView() {
151
144
  this._delegate = null;
@@ -169,20 +162,31 @@ export class Label extends LabelBase {
169
162
  }
170
163
  computeTextHeight(size) {
171
164
  const tv = this.nativeTextViewProtected;
165
+ const oldtextContainerInset = tv.textContainerInset;
166
+ tv.textContainerInset = UIEdgeInsetsZero;
167
+ // if (tv.attributedText) {
168
+ // const result = tv.attributedText.boundingRectWithSizeOptionsContext(
169
+ // size,
170
+ // NSStringDrawingOptions.UsesLineFragmentOrigin | NSStringDrawingOptions.UsesFontLeading,
171
+ // null
172
+ // );
173
+ // return Math.round(CGRectGetHeight(result));
174
+ // }
172
175
  const result = tv.sizeThatFits(size);
176
+ tv.textContainerInset = oldtextContainerInset;
173
177
  return result.height;
174
178
  }
175
179
  updateTextContainerInset(applyVerticalTextAlignment = true) {
176
- // if (!this.text) {
177
- // return;
178
- // }
180
+ var _e, _f;
179
181
  const tv = this.nativeTextViewProtected;
180
182
  const top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
181
183
  const right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth);
182
184
  const bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth);
183
185
  const left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth);
184
- if (!applyVerticalTextAlignment || !this.verticalTextAlignment) {
185
- this.nativeViewProtected.textContainerInset = {
186
+ if (!applyVerticalTextAlignment ||
187
+ !this.verticalTextAlignment ||
188
+ (((_e = tv.text) === null || _e === void 0 ? void 0 : _e.length) === 0 && ((_f = tv.attributedText) === null || _f === void 0 ? void 0 : _f.length) === 0)) {
189
+ tv.textContainerInset = {
186
190
  top,
187
191
  left,
188
192
  bottom,
@@ -193,7 +197,7 @@ export class Label extends LabelBase {
193
197
  switch (this.verticalTextAlignment) {
194
198
  case 'initial': // not supported
195
199
  case 'top':
196
- this.nativeViewProtected.textContainerInset = {
200
+ tv.textContainerInset = {
197
201
  top,
198
202
  left,
199
203
  bottom,
@@ -205,7 +209,7 @@ export class Label extends LabelBase {
205
209
  const height = this.computeTextHeight(CGSizeMake(tv.bounds.size.width, 10000));
206
210
  let topCorrect = (tv.bounds.size.height - top - bottom - height * tv.zoomScale) / 2.0;
207
211
  topCorrect = topCorrect < 0.0 ? 0.0 : topCorrect;
208
- this.nativeViewProtected.textContainerInset = {
212
+ tv.textContainerInset = {
209
213
  top: top + topCorrect,
210
214
  left,
211
215
  bottom,
@@ -215,9 +219,9 @@ export class Label extends LabelBase {
215
219
  }
216
220
  case 'bottom': {
217
221
  const height = this.computeTextHeight(CGSizeMake(tv.bounds.size.width, 10000));
218
- let bottomCorrect = tv.bounds.size.height - bottom - height * tv.zoomScale;
222
+ let bottomCorrect = tv.bounds.size.height - top - bottom - height * tv.zoomScale;
219
223
  bottomCorrect = bottomCorrect < 0.0 ? 0.0 : bottomCorrect;
220
- this.nativeViewProtected.textContainerInset = {
224
+ tv.textContainerInset = {
221
225
  top: top + bottomCorrect,
222
226
  left,
223
227
  bottom,
@@ -231,78 +235,6 @@ export class Label extends LabelBase {
231
235
  get ios() {
232
236
  return this.nativeViewProtected;
233
237
  }
234
- // setTextDecorationAndTransform() {
235
- // const style = this.style;
236
- // const dict = new Map<string, any>();
237
- // switch (style.textDecoration) {
238
- // case 'none':
239
- // break;
240
- // case 'underline':
241
- // // TODO: Replace deprecated `StyleSingle` with `Single` after the next typings update
242
- // dict.set(NSUnderlineStyleAttributeName, NSUnderlineStyle.Single);
243
- // break;
244
- // case 'line-through':
245
- // // TODO: Replace deprecated `StyleSingle` with `Single` after the next typings update
246
- // dict.set(NSStrikethroughStyleAttributeName, NSUnderlineStyle.Single);
247
- // break;
248
- // case 'underline line-through':
249
- // // TODO: Replace deprecated `StyleSingle` with `Single` after the next typings update
250
- // dict.set(NSUnderlineStyleAttributeName, NSUnderlineStyle.Single);
251
- // dict.set(NSStrikethroughStyleAttributeName, NSUnderlineStyle.Single);
252
- // break;
253
- // default:
254
- // throw new Error(`Invalid text decoration value: ${style.textDecoration}. Valid values are: 'none', 'underline', 'line-through', 'underline line-through'.`);
255
- // }
256
- // if (style.letterSpacing !== 0) {
257
- // dict.set(NSKernAttributeName, style.letterSpacing * this.nativeTextViewProtected.font.pointSize);
258
- // }
259
- // if (style.lineHeight || style.whiteSpace === 'nowrap' || (style['lineBreak'] && style['lineBreak'] !== 'none')) {
260
- // const paragraphStyle = NSMutableParagraphStyle.alloc().init();
261
- // paragraphStyle.minimumLineHeight = style.lineHeight;
262
- // // make sure a possible previously set text alignment setting is not lost when line height is specified
263
- // paragraphStyle.alignment = (this.nativeTextViewProtected as UITextField | UITextView | UILabel).textAlignment;
264
- // // make sure a possible previously set line break mode is not lost when line height is specified
265
- // if (style['lineBreak']) {
266
- // paragraphStyle.lineBreakMode = lineBreakToLineBreakMode(style['lineBreak']);
267
- // } else if (style.whiteSpace) {
268
- // paragraphStyle.lineBreakMode = whiteSpaceToLineBreakMode(style.whiteSpace);
269
- // }
270
- // dict.set(NSParagraphStyleAttributeName, paragraphStyle);
271
- // } else if (isTextView && this.style.textAlignment !== 'initial') {
272
- // const paragraphStyle = NSMutableParagraphStyle.alloc().init();
273
- // paragraphStyle.alignment = this.nativeTextViewProtected.textAlignment;
274
- // dict.set(NSParagraphStyleAttributeName, paragraphStyle);
275
- // }
276
- // if (style.color && dict.size > 0) {
277
- // // dict.set(NSForegroundColorAttributeName, style.color.ios);
278
- // }
279
- // const text = this.text;
280
- // const str = text === undefined || text === null ? '' : text.toString();
281
- // const source = getTransformedText(str, this.textTransform);
282
- // if (dict.size > 0) {
283
- // if (isTextView) {
284
- // // UITextView's font seems to change inside.
285
- // dict.set(NSFontAttributeName, this.nativeTextViewProtected.font);
286
- // }
287
- // const result = NSMutableAttributedString.alloc().initWithString(source);
288
- // result.setAttributesRange(dict as any, { location: 0, length: source.length });
289
- // if (this.nativeTextViewProtected instanceof UIButton) {
290
- // this.nativeTextViewProtected.setAttributedTitleForState(result, UIControlState.Normal);
291
- // } else {
292
- // this.nativeTextViewProtected.attributedText = result;
293
- // }
294
- // } else {
295
- // if (this.nativeTextViewProtected instanceof UIButton) {
296
- // // Clear attributedText or title won't be affected.
297
- // this.nativeTextViewProtected.setAttributedTitleForState(null, UIControlState.Normal);
298
- // this.nativeTextViewProtected.setTitleForState(source, UIControlState.Normal);
299
- // } else {
300
- // // Clear attributedText or text won't be affected.
301
- // this.nativeTextViewProtected.attributedText = undefined;
302
- // this.nativeTextViewProtected.text = source;
303
- // }
304
- // }
305
- // }
306
238
  _requestLayoutOnTextChanged() {
307
239
  if (this._fixedSize === FixedSize.BOTH) {
308
240
  return;
@@ -390,14 +322,13 @@ export class Label extends LabelBase {
390
322
  // when in collectionView or pager
391
323
  // if this is done sync (without DTCoreText) while init the cell
392
324
  // it breaks the UICollectionView :s
393
- if (usingIOSDTCoreText()) {
394
- this._updateHTMLString();
395
- }
396
- else {
397
- // setTimeout(() => {
398
- this._updateHTMLString();
399
- // }, 0);
400
- }
325
+ // if (usingIOSDTCoreText()) {
326
+ // this._updateHTMLString();
327
+ // } else {
328
+ // setTimeout(() => {
329
+ this._updateHTMLString();
330
+ // }, 0);
331
+ // }
401
332
  }
402
333
  _setColor(color) {
403
334
  if (this.nativeTextViewProtected instanceof UIButton) {
@@ -514,6 +445,7 @@ export class Label extends LabelBase {
514
445
  else {
515
446
  super._setNativeText();
516
447
  }
448
+ this.updateTextContainerInset();
517
449
  this._requestLayoutOnTextChanged();
518
450
  }
519
451
  setTextDecorationAndTransform() {
@@ -538,25 +470,18 @@ export class Label extends LabelBase {
538
470
  if (style.letterSpacing !== 0 && this.nativeTextViewProtected.font) {
539
471
  const kern = style.letterSpacing * this.nativeTextViewProtected.font.pointSize;
540
472
  dict.set(NSKernAttributeName, kern);
541
- if (this.nativeTextViewProtected instanceof UITextField) {
542
- this.nativeTextViewProtected.defaultTextAttributes.setValueForKey(kern, NSKernAttributeName);
543
- }
544
473
  }
545
474
  const isTextView = false;
546
- if (style.lineHeight) {
475
+ if (style.lineHeight !== undefined) {
476
+ let lineHeight = style.lineHeight;
477
+ if (lineHeight === 0) {
478
+ lineHeight = 0.00001;
479
+ }
547
480
  const paragraphStyle = NSMutableParagraphStyle.alloc().init();
548
- paragraphStyle.lineSpacing = style.lineHeight;
481
+ paragraphStyle.minimumLineHeight = lineHeight;
482
+ paragraphStyle.maximumLineHeight = lineHeight;
549
483
  // make sure a possible previously set text alignment setting is not lost when line height is specified
550
- if (this.nativeTextViewProtected instanceof UIButton) {
551
- paragraphStyle.alignment = this.nativeTextViewProtected.titleLabel.textAlignment;
552
- }
553
- else {
554
- paragraphStyle.alignment = this.nativeTextViewProtected.textAlignment;
555
- }
556
- if (this.nativeTextViewProtected instanceof UILabel) {
557
- // make sure a possible previously set line break mode is not lost when line height is specified
558
- paragraphStyle.lineBreakMode = this.nativeTextViewProtected.lineBreakMode;
559
- }
484
+ paragraphStyle.alignment = this.nativeTextViewProtected.textAlignment;
560
485
  dict.set(NSParagraphStyleAttributeName, paragraphStyle);
561
486
  }
562
487
  else if (isTextView) {
@@ -580,81 +505,27 @@ export class Label extends LabelBase {
580
505
  location: 0,
581
506
  length: source.length
582
507
  });
583
- if (this.nativeTextViewProtected instanceof UIButton) {
584
- this.nativeTextViewProtected.setAttributedTitleForState(result, 0 /* Normal */);
585
- }
586
- else {
587
- this.nativeTextViewProtected.attributedText = result;
588
- }
508
+ this.nativeTextViewProtected.attributedText = result;
589
509
  }
590
510
  else {
591
- if (this.nativeTextViewProtected instanceof UIButton) {
592
- // Clear attributedText or title won't be affected.
593
- this.nativeTextViewProtected.setAttributedTitleForState(null, 0 /* Normal */);
594
- this.nativeTextViewProtected.setTitleForState(source, 0 /* Normal */);
595
- }
596
- else {
597
- // Clear attributedText or text won't be affected.
598
- this.nativeTextViewProtected.attributedText = undefined;
599
- this.nativeTextViewProtected.text = source;
600
- }
511
+ // Clear attributedText or text won't be affected.
512
+ this.nativeTextViewProtected.attributedText = undefined;
513
+ this.nativeTextViewProtected.text = source;
601
514
  }
602
515
  if (!style.color && majorVersion >= 13 && UIColor.labelColor) {
603
516
  this._setColor(UIColor.labelColor);
604
517
  }
605
518
  }
606
- createNSMutableAttributedString(formattedString) {
607
- var _e;
608
- // we need to store the max Font size to pass it to createMutableStringForSpan
609
- const length = formattedString.spans.length;
610
- let maxFontSize = ((_e = formattedString.style) === null || _e === void 0 ? void 0 : _e.fontSize) || (this === null || this === void 0 ? void 0 : this.style.fontSize) || 0;
611
- for (let i = 0; i < length; i++) {
612
- const s = formattedString.spans.getItem(i);
613
- if (s.style.fontSize) {
614
- maxFontSize = Math.max(maxFontSize, s.style.fontSize);
615
- }
616
- }
617
- this.currentMaxFontSize = maxFontSize;
618
- return super.createNSMutableAttributedString(formattedString);
619
- }
620
- createMutableStringForSpan(span, text) {
621
- const viewFont = this.nativeTextViewProtected.font;
622
- const attrDict = {};
623
- const style = span.style;
624
- let align = style.verticalAlignment || span.parent.style.verticalAlignment;
625
- if (!align || align === 'stretch') {
626
- align = this.verticalTextAlignment;
627
- }
628
- const font = new Font(style.fontFamily, style.fontSize, style.fontStyle, style.fontWeight);
629
- const iosFont = font.getUIFont(viewFont);
630
- attrDict[NSFontAttributeName] = iosFont;
631
- if (span.color) {
632
- const color = span.color instanceof Color ? span.color : new Color(span.color);
633
- attrDict[NSForegroundColorAttributeName] = color.ios;
634
- }
635
- // We don't use isSet function here because defaultValue for backgroundColor is null.
636
- const backgroundColor = style.backgroundColor || span.parent.backgroundColor;
637
- if (backgroundColor) {
638
- const color = backgroundColor instanceof Color ? backgroundColor : new Color(backgroundColor);
639
- attrDict[NSBackgroundColorAttributeName] = color.ios;
640
- }
641
- const textDecoration = getClosestPropertyValue(textDecorationProperty, span);
642
- if (textDecoration) {
643
- const underline = textDecoration.indexOf('underline') !== -1;
644
- if (underline) {
645
- attrDict[NSUnderlineStyleAttributeName] = underline;
646
- }
647
- const strikethrough = textDecoration.indexOf('line-through') !== -1;
648
- if (strikethrough) {
649
- attrDict[NSStrikethroughStyleAttributeName] = strikethrough;
650
- }
651
- }
652
- if (align && align !== 'stretch') {
653
- if (iosFont) {
654
- attrDict[NSBaselineOffsetAttributeName] = -computeBaseLineOffset(align, -iosFont.ascender, -iosFont.descender, -iosFont.ascender, -iosFont.descender, iosFont.pointSize, this.currentMaxFontSize);
655
- }
519
+ createFormattedTextNative(value) {
520
+ return createNativeAttributedString(value, this, this.autoFontSize, this.fontSizeRatio);
521
+ }
522
+ setFormattedTextDecorationAndTransform() {
523
+ const attrText = this.createFormattedTextNative(this.formattedText);
524
+ // we override parent class behavior because we apply letterSpacing and lineHeight on a per Span basis
525
+ if (majorVersion >= 13 && UIColor.labelColor) {
526
+ this.nativeTextViewProtected.textColor = UIColor.labelColor;
656
527
  }
657
- return NSMutableAttributedString.alloc().initWithStringAttributes(text, attrDict);
528
+ this.nativeTextViewProtected.attributedText = attrText;
658
529
  }
659
530
  [paddingTopProperty.getDefault]() {
660
531
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-label",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
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.21"
35
+ "@nativescript-community/text": "^1.4.29"
36
36
  },
37
- "gitHead": "548a66a7342e4c8e1e33ce63a0b6dd9a6a57c5fb"
37
+ "gitHead": "9a124d1823a131d3a2cf1753a661b6984b562b7f"
38
38
  }