1
- import { QLabel , NodeWidget , QLabelSignals } from " @nodegui/nodegui" ;
2
- import { ViewProps , setViewProps } from " ../View/RNView" ;
3
- import { RNWidget } from " ../config" ;
4
- import { throwUnsupported } from " ../../utils/helpers" ;
1
+ import { QLabel , NodeWidget , QLabelSignals } from ' @nodegui/nodegui' ;
2
+ import { ViewProps , setViewProps } from ' ../View/RNView' ;
3
+ import { RNWidget } from ' ../config' ;
4
+ import { throwUnsupported } from ' ../../utils/helpers' ;
5
5
6
6
export interface TextProps extends ViewProps < QLabelSignals > {
7
- children ?: string | number ;
7
+ children ?: string | number | Array < string | number > ;
8
8
wordWrap ?: boolean ;
9
9
scaledContents ?: boolean ;
10
10
openExternalLinks ?: boolean ;
@@ -19,18 +19,20 @@ export const setTextProps = (
19
19
oldProps : TextProps
20
20
) => {
21
21
const setter : TextProps = {
22
- set children ( text : string | number ) {
22
+ set children ( text : string | number | Array < string | number > ) {
23
+ text = Array . isArray ( text ) ? text . join ( '' ) : text ;
24
+
23
25
widget . setText ( text ) ;
24
26
} ,
25
27
set wordWrap ( shouldWrap : boolean ) {
26
28
widget . setWordWrap ( shouldWrap ) ;
27
29
} ,
28
30
set scaledContents ( scaled : boolean ) {
29
- widget . setProperty ( " scaledContents" , scaled ) ;
31
+ widget . setProperty ( ' scaledContents' , scaled ) ;
30
32
} ,
31
33
set openExternalLinks ( shouldOpenExternalLinks : boolean ) {
32
- widget . setProperty ( " openExternalLinks" , shouldOpenExternalLinks ) ;
33
- }
34
+ widget . setProperty ( ' openExternalLinks' , shouldOpenExternalLinks ) ;
35
+ } ,
34
36
} ;
35
37
Object . assign ( setter , newProps ) ;
36
38
setViewProps ( widget , newProps , oldProps ) ;
@@ -55,5 +57,5 @@ export class RNText extends QLabel implements RNWidget {
55
57
removeChild ( child : NodeWidget < any > ) : void {
56
58
throwUnsupported ( this ) ;
57
59
}
58
- static tagName = " text" ;
60
+ static tagName = ' text' ;
59
61
}
0 commit comments