Skip to content

Commit 4923274

Browse files
author
farfromrefug
committed
fix: typings fix for paint setShader/getShader
1 parent baaa3dc commit 4923274

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/ui-canvas/canvas.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Paint extends ProxyClass {
6060
// public getTextWidths(param0: native.Array<string>, param1: number, param2: number, param3: native.Array<number>): number;
6161
public getStrokeJoin(): Join;
6262
public getColor(): ColorParam;
63-
public getShader(): any;
63+
public getShader(): Shader;
6464
public measureText(text: string, start: number, end: number): number;
6565
public setTypeface(newValue: Font): Font;
6666
public setStrokeWidth(value: number): void;
@@ -84,7 +84,7 @@ export class Paint extends ProxyClass {
8484
public setFontWeight(weight: FontWeightType);
8585
public setFontStyle(style: FontStyleType);
8686
public getFontFamily(): string;
87-
public setShader(value: any): any;
87+
public setShader(value: Shader): Shader;
8888
// public descent(): number;
8989
public setShadowLayer(radius: number, dx: number, dy: number, color: ColorParam): void;
9090
public clearShadowLayer();
@@ -269,6 +269,8 @@ export class LinearGradient extends android.graphics.LinearGradient {
269269
export class BitmapShader extends android.graphics.BitmapShader {
270270
constructor(image: ImageSource, tileX, tileY);
271271
}
272+
export class Shader extends android.graphics.Shader {
273+
}
272274
export class TileMode extends android.graphics.Shader.TileMode {}
273275
export class Path extends ProxyClass {
274276
computeBounds(rect: RectF, exact: boolean);

src/ui-canvas/canvas.ios.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
/* eslint-disable no-redeclare */
22
import { CSSType, Color, Font, ImageSource, Utils, View } from '@nativescript/core';
33
import { FontStyleType, FontWeightType } from '@nativescript/core/ui/styling/font';
4-
import { Canvas as ICanvas, FontMetrics as IFontMetrics, Matrix as IMatrix, Paint as IPaint, Path as IPath, PorterDuffXfermode as IPorterDuffXfermode, Rect as IRect, RectF as IRectF } from './canvas';
4+
import {
5+
Canvas as ICanvas,
6+
FontMetrics as IFontMetrics,
7+
Matrix as IMatrix,
8+
Paint as IPaint,
9+
Path as IPath,
10+
PorterDuffXfermode as IPorterDuffXfermode,
11+
Rect as IRect,
12+
RectF as IRectF,
13+
Shader as IShader
14+
} from './canvas';
515
import type { CanvasView } from './index.ios';
616
export * from './canvas.common';
717

@@ -870,7 +880,7 @@ export class Paint implements IPaint {
870880
dy: number;
871881
color: Color;
872882
};
873-
shader;
883+
shader: Shader;
874884
colorFilter;
875885
pathEffect: PathEffect;
876886
xfermode: IPorterDuffXfermode;
@@ -971,9 +981,6 @@ export class Paint implements IPaint {
971981
public getStrokeJoin(): Join {
972982
return this.strokeJoin;
973983
}
974-
public getShader() {
975-
return this.shader;
976-
}
977984
public getColorFilter() {
978985
return this.colorFilter;
979986
}
@@ -1007,11 +1014,15 @@ export class Paint implements IPaint {
10071014
public getStrokeCap(): Cap {
10081015
return this.strokeCap;
10091016
}
1010-
public setShader(value: any) {
1017+
public setShader(value: IShader) {
10111018
if (this.shader) {
1012-
this.shader.release();
1019+
(this.shader as any as Shader).release();
10131020
}
1014-
this.shader = value;
1021+
this.shader = value as any as Shader;
1022+
return value;
1023+
}
1024+
public getShader() {
1025+
return this.shader as any as IShader;
10151026
}
10161027
public setColorFilter(value: any) {
10171028
if (this.colorFilter) {
@@ -1158,7 +1169,7 @@ export class Paint implements IPaint {
11581169

11591170
clear() {
11601171
if (this.shader) {
1161-
this.shader.clear();
1172+
this.shader.release();
11621173
this.shader = null;
11631174
}
11641175
if (this.colorFilter) {
@@ -2178,6 +2189,7 @@ class Shader {
21782189
this.localMatrix = null;
21792190
}
21802191
}
2192+
release() {}
21812193
}
21822194
export class RadialGradient extends Shader {
21832195
mGradient;

0 commit comments

Comments
 (0)