Skip to content

Commit e404d4b

Browse files
committed
fix(ios): fix text not showing …
1 parent eac31bc commit e404d4b

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

src/label.ios.ts

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
import { Color, colorProperty, fontInternalProperty, Length, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty, View, lineHeightProperty } from '@nativescript/core/ui/page/page';
2-
import { Font } from '@nativescript/core/ui/styling/font';
3-
import { borderBottomWidthProperty, borderLeftWidthProperty, borderRightWidthProperty, borderTopWidthProperty, FormattedString, formattedTextProperty, TextTransform, WhiteSpace, whiteSpaceProperty, letterSpacingProperty, textAlignmentProperty } from '@nativescript/core/ui/text-base';
1+
import { Color, colorProperty, fontInternalProperty, Length, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty, View } from '@nativescript/core/ui/page/page';
2+
import { lineHeightProperty } from '@nativescript/core/ui/text-base/text-base';
3+
import {
4+
borderBottomWidthProperty,
5+
borderLeftWidthProperty,
6+
borderRightWidthProperty,
7+
borderTopWidthProperty,
8+
TextTransform,
9+
WhiteSpace,
10+
whiteSpaceProperty,
11+
letterSpacingProperty,
12+
textAlignmentProperty
13+
} from '@nativescript/core/ui/text-base';
414
import { isString } from '@nativescript/core/utils/types';
515
import { layout } from '@nativescript/core/utils/utils';
616
import { TextShadow, VerticalTextAlignment, verticalTextAlignmentProperty } from './label';
@@ -318,13 +328,13 @@ export class Label extends LabelBase {
318328
htmlString = `<style>body{ color: ${this.color};font-family: '${font.familyName}'; font-size:${font.pointSize}px;}</style>${htmlString}`;
319329
const nsString = NSString.stringWithString(htmlString);
320330
const nsData = nsString.dataUsingEncoding(NSUTF16StringEncoding);
321-
const attrText = this.attributedString = NSMutableAttributedString.alloc().initWithDataOptionsDocumentAttributesError(
331+
const attrText = (this.attributedString = NSMutableAttributedString.alloc().initWithDataOptionsDocumentAttributesError(
322332
nsData,
323333
<any>{
324334
[NSDocumentTypeDocumentAttribute]: NSHTMLTextDocumentType
325335
},
326336
null
327-
);
337+
));
328338

329339
// TODO: letterSpacing should be applied per Span.
330340
if (this.letterSpacing !== 0) {
@@ -347,7 +357,6 @@ export class Label extends LabelBase {
347357
attrText.addAttributeValueRange(NSParagraphStyleAttributeName, paragraphStyle, { location: 0, length: attrText.length });
348358
}
349359

350-
351360
this._requestLayoutOnTextChanged();
352361
}
353362
if (this.nativeViewProtected) {
@@ -357,15 +366,16 @@ export class Label extends LabelBase {
357366
[colorProperty.setNative](value: Color | UIColor) {
358367
const color = value instanceof Color ? value.ios : value;
359368
// if (!this.formattedText && !this.html) {
360-
const nativeView = this.nativeTextViewProtected;
361-
nativeView.textColor = color;
369+
const nativeView = this.nativeTextViewProtected;
370+
nativeView.textColor = color;
362371
// }
363372
}
364373
@needFormattedStringComputation
365374
[htmlProperty.setNative](value: string) {
366-
if (!this.style.fontInternal ) {
375+
console.log('htmlProperty', value);
376+
// if (!this.style.fontInternal) {
367377
this.updateHTMLString();
368-
}
378+
// }
369379
}
370380
@needFormattedStringComputation
371381
[letterSpacingProperty.setNative](value: number) {
@@ -380,8 +390,8 @@ export class Label extends LabelBase {
380390
super[lineHeightProperty.setNative](value);
381391
}
382392
_setNativeText() {
383-
if (!this.html) {
384-
this.updateHTMLString();
393+
if (this.html) {
394+
this.updateHTMLString();
385395
} else {
386396
super._setNativeText();
387397
}

0 commit comments

Comments
 (0)