Skip to content

Commit ce9840c

Browse files
author
farfromrefug
committed
fix(canvaslabel): circular import fix
1 parent 4305a8d commit ce9840c

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/ui-canvaslabel/canvaslabel.android.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import { Paint } from '@nativescript-community/ui-canvas';
2-
import { Color, getTransformedText, profile } from '@nativescript/core';
3-
import { FontWeight, FontWeightType } from '@nativescript/core/ui/styling/font';
4-
import { CanvasLabel as CanvasLabelBase, Group as GroupBase, SpanBase, paintFontCache } from './canvaslabel.common';
5-
import { createNativeAttributedString, createSpannable, typefaceCache } from '@nativescript-community/text';
1+
import { createNativeAttributedString, createSpannable } from '@nativescript-community/text';
2+
import { CanvasLabel as CanvasLabelBase, Group as GroupBase, SpanBase } from './canvaslabel.common';
63

74
export class Span extends SpanBase {
85
_ssb: android.text.SpannableStringBuilder;
@@ -53,4 +50,8 @@ export class Group extends GroupBase {
5350
}
5451
}
5552

56-
export class CanvasLabel extends CanvasLabelBase {}
53+
export class CanvasLabel extends CanvasLabelBase {
54+
createSpan() {
55+
return new Span();
56+
}
57+
}

src/ui-canvaslabel/canvaslabel.common.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
profile
2020
} from '@nativescript/core';
2121
import { FontStyleType, FontWeightType } from '@nativescript/core/ui/styling/font';
22-
import { Span } from './canvaslabel';
2322

2423
const toDpi = Utils.layout.toDeviceIndependentPixels;
2524
export const paintCache: { [k: string]: Paint } = {};
@@ -531,7 +530,7 @@ declare module '@nativescript/core/ui/core/view' {
531530
}
532531

533532
@CSSType('CanvasLabel')
534-
export class CanvasLabel extends CanvasView {
533+
export abstract class CanvasLabel extends CanvasView {
535534
// fontSize: number;
536535
mText: string | any;
537536
// fontStyle: FontStyle;
@@ -553,6 +552,8 @@ export class CanvasLabel extends CanvasView {
553552

554553
private mTextSpan: SpanBase;
555554

555+
abstract createSpan(): SpanBase;
556+
556557
handlePropertyChange() {
557558
this.shapes?.forEach((s) => s instanceof SpanBase && s.reset());
558559
this.invalidate();
@@ -647,7 +648,7 @@ export class CanvasLabel extends CanvasView {
647648
set text(value) {
648649
if (value) {
649650
if (!this.mTextSpan) {
650-
this.mTextSpan = new Span();
651+
this.mTextSpan = this.createSpan();
651652
this.addShape(this.mTextSpan);
652653
} else {
653654
this.mTextSpan.visibility = 'visible';

src/ui-canvaslabel/canvaslabel.ios.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ export class Group extends GroupBase {
3838
}
3939
}
4040

41-
export class CanvasLabel extends CanvasLabelBase {}
41+
export class CanvasLabel extends CanvasLabelBase {
42+
createSpan(): Span {
43+
return new Span();
44+
}
45+
}

0 commit comments

Comments
 (0)