File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,9 @@ export abstract class LabelBase extends TNLabel implements LabelViewDefinition {
31
31
@cssProperty linkColor : Color ;
32
32
@cssProperty linkUnderline : boolean ;
33
33
@cssProperty selectable : boolean ;
34
- html : string ;
35
- //@ts -ignore
34
+
35
+ html : string | NSAttributedString ;
36
+
36
37
formattedText : FormattedString ;
37
38
38
39
@cssProperty autoFontSize : boolean ;
Original file line number Diff line number Diff line change @@ -427,13 +427,15 @@ export class Label extends LabelBase {
427
427
return ;
428
428
}
429
429
let transformedText : any = null ;
430
+ const constructorName = ( this . html || this . text ) ?. constructor ?. name ;
431
+ const nativeData = constructorName === 'java.lang.CharSequence' || constructorName === 'android.text.Spanned' || constructorName === 'android.text.SpannableStringBuilder' ;
430
432
if ( this . html ) {
431
- transformedText = this . createHTMLString ( ) ;
433
+ transformedText = nativeData ? this . html : this . createHTMLString ( ) ;
432
434
textProperty . nativeValueChange ( this , this . html === null || this . html === undefined ? '' : this . html ) ;
433
435
} else if ( this . formattedText ) {
434
436
transformedText = this . createFormattedTextNative ( this . formattedText ) ;
435
437
textProperty . nativeValueChange ( this , this . formattedText === null || this . formattedText === undefined ? '' : this . formattedText . toString ( ) ) ;
436
- } else if ( this . text instanceof java . lang . CharSequence || this . text instanceof android . text . Spanned ) {
438
+ } else if ( nativeData ) {
437
439
transformedText = this . text ;
438
440
} else {
439
441
const text = this . text ;
Original file line number Diff line number Diff line change @@ -21,9 +21,14 @@ export declare class Label extends TNLabel {
21
21
ios : any /* UITextView */ ;
22
22
23
23
/**
24
- * Gets or sets html string for the HtmlView .
24
+ * Gets or sets html string for the Label .
25
25
*/
26
- html : string ;
26
+ html : any ; // can be string but also native NSAttributedString or android spannable
27
+
28
+ /**
29
+ * Gets or sets string for the Label.
30
+ */
31
+ text : any ; // can be string but also native NSAttributedString or android spannable
27
32
28
33
verticalTextAlignment : VerticalTextAlignment ;
29
34
lineBreak : LineBreak ;
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ export class Label extends LabelBase {
160
160
private mObserver : LabelObserverClass ;
161
161
nativeViewProtected : NSLabel | NSTextView ;
162
162
nativeTextViewProtected : NSLabel | NSTextView ;
163
- attributedString : NSMutableAttributedString ;
163
+ attributedString : NSAttributedString ;
164
164
private mDelegate : LabelNSTextViewDelegateImpl ;
165
165
private mFixedSize : FixedSize ;
166
166
static DTCORETEXT_INIT = false ;
@@ -502,6 +502,8 @@ export class Label extends LabelBase {
502
502
( nativeView as NSTextView ) . selectable = this . selectable === true ;
503
503
}
504
504
this . attributedString = null ;
505
+ } else if ( this . html instanceof NSAttributedString ) {
506
+ this . attributedString = this . html ;
505
507
} else {
506
508
const font = nativeView . font ;
507
509
const style = this . style ;
You can’t perform that action at this time.
0 commit comments