Skip to content

Commit caaf2e3

Browse files
Bradley MartinBradley Martin
authored andcommitted
add more android methods (bump)
1 parent 07dda37 commit caaf2e3

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ Attribute to specify the pen (stroke) color to use.
7777

7878
Attribute to specify the pen (stroke) width to use.
7979

80-
## Methods
80+
## Methods
81+
8182
**getDrawing()** - Promise *(returns image if successful)*
8283

83-
**clearDrawing()** - clears the drawing from the DrawingPad view.
84+
**clearDrawing()** - clears the drawing from the DrawingPad view.
85+
86+
#### *Android Only*
87+
88+
- **getTransparentDrawing** - Promise (returns a bitmap with a transparent background)
89+
- **getDrawingSvg()** - Promise (returns a Scalable Vector Graphics document)
90+

drawingpad.android.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,23 @@ export class DrawingPad extends common.DrawingPad {
3030

3131
}
3232

33-
public getDrawing():Promise<any> {
33+
34+
public getDrawing(): Promise<any> {
35+
return new Promise((resolve, reject) => {
36+
try {
37+
if (!this._android.isEmpty()) {
38+
let data = this._android.getSignatureBitmap();
39+
resolve(data);
40+
} else {
41+
reject("DrawingPad is empty.");
42+
}
43+
} catch (err) {
44+
reject(err);
45+
}
46+
})
47+
}
48+
49+
public getTransparentDrawing(): Promise<any> {
3450
return new Promise((resolve, reject) => {
3551
try {
3652
if (!this._android.isEmpty()) {
@@ -45,6 +61,21 @@ export class DrawingPad extends common.DrawingPad {
4561
})
4662
}
4763

64+
public getDrawingSvg(): Promise<any> {
65+
return new Promise((resolve, reject) => {
66+
try {
67+
if (!this._android.isEmpty()) {
68+
let data = this._android.getSignatureSvg();
69+
resolve(data);
70+
} else {
71+
reject("DrawingPad is empty.");
72+
}
73+
} catch (err) {
74+
reject(err);
75+
}
76+
})
77+
}
78+
4879
public clearDrawing(): any {
4980
try {
5081
this._android.clear();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-drawingpad",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"main": "drawingpad.js",
55
"description": "A NativeScript plugin to provide a way to capture any drawing (signatures are a common use case) from the device screen.",
66
"nativescript": {

0 commit comments

Comments
 (0)