|
1 | 1 | import { isIOS } from '@nativescript/core/platform';
|
2 | 2 | import { CssProperty, InheritedCssProperty, makeParser, makeValidator, Property } from '@nativescript/core/ui/core/properties';
|
3 |
| -import { booleanConverter, Color, CSSType, dip } from '@nativescript/core/ui/core/view'; |
| 3 | +import { booleanConverter, Color, CSSType, dip, Observable, ViewBase } from '@nativescript/core/ui/core/view'; |
4 | 4 | import { Label as TNLabel } from '@nativescript/core/ui/label';
|
5 | 5 | import { Style } from '@nativescript/core/ui/styling/style';
|
6 | 6 | import { layout } from '@nativescript/core/utils/utils';
|
7 | 7 | import { Label as LabelViewDefinition, TextShadow } from './label';
|
8 | 8 | import { FormattedString } from '@nativescript/core/ui/text-base/formatted-string';
|
9 | 9 | import { Span } from '@nativescript/core/ui/text-base/span';
|
10 | 10 |
|
11 |
| - |
12 | 11 | declare module '@nativescript/core/ui/text-base/formatted-string' {
|
13 | 12 | interface FormattedString {
|
14 |
| - addPropertyChangeHandler(): void; |
15 |
| - removePropertyChangeHandler(): void; |
| 13 | + addPropertyChangeHandler(span: Span): void; |
| 14 | + removePropertyChangeHandler(span: Span): void; |
16 | 15 | }
|
17 | 16 | }
|
18 |
| -declare module '@nativescript/core/ui/text-base/span' { |
19 |
| - interface Span { |
20 |
| - addPropertyChangeHandler(): void; |
21 |
| - removePropertyChangeHandler(): void; |
22 |
| - } |
| 17 | +FormattedString.prototype.addPropertyChangeHandler = function(span: Span) { |
| 18 | + span.on(Observable.propertyChangeEvent, this.onPropertyChange, this); |
| 19 | +}; |
| 20 | +FormattedString.prototype.removePropertyChangeHandler = function(span: Span) { |
| 21 | + span.off(Observable.propertyChangeEvent, this.onPropertyChange, this); |
| 22 | +}; |
| 23 | +FormattedString.prototype.eachChild = function(callback: (child: ViewBase) => boolean): void { |
| 24 | + this.spans.forEach((v, i, arr) => callback(v)); |
23 | 25 | }
|
24 | 26 |
|
25 |
| -FormattedString.prototype.addPropertyChangeHandler = function() {} |
26 |
| -FormattedString.prototype.removePropertyChangeHandler = function() {} |
27 |
| -Span.prototype.addPropertyChangeHandler = function() {} |
28 |
| -Span.prototype.removePropertyChangeHandler = function() {} |
29 |
| - |
30 |
| - |
31 | 27 | export const cssProperty = (target: Object, key: string | symbol) => {
|
32 | 28 | // property getter
|
33 | 29 | const getter = function() {
|
|
0 commit comments