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 {
3131 @cssProperty linkColor : Color ;
3232 @cssProperty linkUnderline : boolean ;
3333 @cssProperty selectable : boolean ;
34- html : string ;
35- //@ts -ignore
34+
35+ html : string | NSAttributedString ;
36+
3637 formattedText : FormattedString ;
3738
3839 @cssProperty autoFontSize : boolean ;
Original file line number Diff line number Diff line change @@ -427,13 +427,15 @@ export class Label extends LabelBase {
427427 return ;
428428 }
429429 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' ;
430432 if ( this . html ) {
431- transformedText = this . createHTMLString ( ) ;
433+ transformedText = nativeData ? this . html : this . createHTMLString ( ) ;
432434 textProperty . nativeValueChange ( this , this . html === null || this . html === undefined ? '' : this . html ) ;
433435 } else if ( this . formattedText ) {
434436 transformedText = this . createFormattedTextNative ( this . formattedText ) ;
435437 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 ) {
437439 transformedText = this . text ;
438440 } else {
439441 const text = this . text ;
Original file line number Diff line number Diff line change @@ -21,9 +21,14 @@ export declare class Label extends TNLabel {
2121 ios : any /* UITextView */ ;
2222
2323 /**
24- * Gets or sets html string for the HtmlView .
24+ * Gets or sets html string for the Label .
2525 */
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
2732
2833 verticalTextAlignment : VerticalTextAlignment ;
2934 lineBreak : LineBreak ;
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ export class Label extends LabelBase {
160160 private mObserver : LabelObserverClass ;
161161 nativeViewProtected : NSLabel | NSTextView ;
162162 nativeTextViewProtected : NSLabel | NSTextView ;
163- attributedString : NSMutableAttributedString ;
163+ attributedString : NSAttributedString ;
164164 private mDelegate : LabelNSTextViewDelegateImpl ;
165165 private mFixedSize : FixedSize ;
166166 static DTCORETEXT_INIT = false ;
@@ -502,6 +502,8 @@ export class Label extends LabelBase {
502502 ( nativeView as NSTextView ) . selectable = this . selectable === true ;
503503 }
504504 this . attributedString = null ;
505+ } else if ( this . html instanceof NSAttributedString ) {
506+ this . attributedString = this . html ;
505507 } else {
506508 const font = nativeView . font ;
507509 const style = this . style ;
You can’t perform that action at this time.
0 commit comments