1
1
import {
2
2
CSSType ,
3
+ ChangedData ,
3
4
Color ,
4
5
CssProperty ,
5
6
FormattedString ,
6
7
InheritedCssProperty ,
7
8
Observable ,
9
+ ObservableArray ,
8
10
Property ,
11
+ PropertyChangeData ,
9
12
Span ,
10
13
Style ,
11
14
Label as TNLabel ,
12
15
booleanConverter ,
13
16
makeParser ,
14
17
makeValidator ,
15
18
} from '@nativescript/core' ;
16
- import { dip } from '@nativescript/core/ui/core/view' ;
17
- import { TextAlignment } from '@nativescript/core/ui/text-base' ;
19
+ import { View , dip } from '@nativescript/core/ui/core/view' ;
20
+ import { TextAlignment , TextDecoration } from '@nativescript/core/ui/text-base' ;
18
21
import { layout } from '@nativescript/core/utils/utils' ;
19
22
import { Label as LabelViewDefinition , LineBreak , TextShadow } from './label' ;
20
- import { VerticalTextAlignment , cssProperty } from '@nativescript-community/text' ;
23
+ import { LightFormattedString , VerticalTextAlignment , cssProperty } from '@nativescript-community/text' ;
24
+ import { FontStyle , FontWeight } from '@nativescript/core/ui/styling/font' ;
21
25
22
26
declare module '@nativescript/core/ui/text-base/formatted-string' {
23
27
interface FormattedString {
24
28
addPropertyChangeHandler ( span : Span ) ;
25
29
removePropertyChangeHandler ( span : Span ) ;
26
30
}
27
31
}
28
- // FormattedString.prototype.onPropertyChange = function(data: PropertyChangeData) {
29
- // this.notifyPropertyChange(data.propertyName, this);
30
- // }
31
- FormattedString . prototype . addPropertyChangeHandler = function ( span : Span ) {
32
- span . on ( Observable . propertyChangeEvent , this . onPropertyChange , this ) ;
33
- // const style = span.style;
34
- // style.on('fontFamilyChange', this.onPropertyChange, this);
35
- // style.on('fontSizeChange', this.onPropertyChange, this);
36
- // style.on('fontStyleChange', this.onPropertyChange, this);
37
- // style.on('fontWeightChange', this.onPropertyChange, this);
38
- // style.on('textDecorationChange', this.onPropertyChange, this);
39
- // style.on('colorChange', this.onPropertyChange, this);
40
- } ;
41
- FormattedString . prototype . removePropertyChangeHandler = function ( span : Span ) {
42
- span . off ( Observable . propertyChangeEvent , this . onPropertyChange , this ) ;
43
- // const style = span.style;
44
- // style.off('fontFamilyChange', this.onPropertyChange, this);
45
- // style.off('fontSizeChange', this.onPropertyChange, this);
46
- // style.off('fontStyleChange', this.onPropertyChange, this);
47
- // style.off('fontWeightChange', this.onPropertyChange, this);
48
- // style.off('textDecorationChange', this.onPropertyChange, this);
49
- // style.off('colorChange', this.onPropertyChange, this);
50
- } ;
51
- // FormattedString.prototype.eachChild = function(callback: (child: ViewBase) => boolean): void {
52
- // this.spans.forEach((v, i, arr) => callback(v));
32
+
33
+ const CHILD_SPAN = 'Span' ;
34
+ const CHILD_FORMATTED_TEXT = 'formattedText' ;
35
+ const CHILD_FORMATTED_STRING = 'FormattedString' ;
36
+ // FormattedString.prototype.addPropertyChangeHandler = function (span: Span) {
37
+ // span.on(Observable.propertyChangeEvent, this.onPropertyChange, this);
53
38
// };
39
+ // FormattedString.prototype.removePropertyChangeHandler = function (span: Span) {
40
+ // span.off(Observable.propertyChangeEvent, this.onPropertyChange, this);
41
+ // };
42
+
43
+
54
44
55
45
export const needFormattedStringComputation = function (
56
46
target : any ,
@@ -74,6 +64,8 @@ export abstract class LabelBase extends TNLabel implements LabelViewDefinition {
74
64
@cssProperty verticalTextAlignment : VerticalTextAlignment ;
75
65
@cssProperty lineBreak : LineBreak ;
76
66
html : string ;
67
+ //@ts -ignore
68
+ formattedText : FormattedString ;
77
69
78
70
_canChangeText = true ;
79
71
_needFormattedStringComputation = false ;
0 commit comments