Skip to content

Commit 8883240

Browse files
committed
added get drawing() to return the bitmap from the drawing on android
1 parent d6d4336 commit 8883240

File tree

5 files changed

+40
-16
lines changed

5 files changed

+40
-16
lines changed

signaturepad-common.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ var SignaturePad = (function (_super) {
3333
enumerable: true,
3434
configurable: true
3535
});
36+
Object.defineProperty(SignaturePad.prototype, "drawing", {
37+
get: function () {
38+
return this._getValue(SignaturePad.drawingProperty);
39+
},
40+
enumerable: true,
41+
configurable: true
42+
});
3643
SignaturePad.penColorProperty = penColorProperty;
3744
SignaturePad.penWidthProperty = penWidthProperty;
3845
return SignaturePad;

signaturepad-common.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export class SignaturePad extends view.View implements definition.SignaturePad {
1919

2020
public static penColorProperty = penColorProperty;
2121
public static penWidthProperty = penWidthProperty;
22+
public static drawingProperty: any;
2223

2324
constructor(options?: definition.Options) {
2425
super(options);
@@ -38,4 +39,8 @@ export class SignaturePad extends view.View implements definition.SignaturePad {
3839
this._setValue(SignaturePad.penWidthProperty, value);
3940
}
4041

42+
get drawing(): any {
43+
return this._getValue(SignaturePad.drawingProperty);
44+
}
45+
4146
}

signaturepad.android.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ var __extends = (this && this.__extends) || function (d, b) {
44
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
55
};
66
var common = require("./signaturepad-common");
7+
var color = require("color");
78
global.moduleMerge(common, exports);
89
var SignaturePad = (function (_super) {
910
__extends(SignaturePad, _super);
1011
function SignaturePad() {
11-
_super.call(this);
12+
_super.apply(this, arguments);
1213
}
1314
Object.defineProperty(SignaturePad.prototype, "android", {
1415
get: function () {
@@ -26,15 +27,21 @@ var SignaturePad = (function (_super) {
2627
});
2728
SignaturePad.prototype._createUI = function () {
2829
this._android = new com.github.gcacace.signaturepad.views.SignaturePad(this._context, null);
29-
if (!this._androidViewId) {
30-
this._androidViewId = android.view.View.generateViewId();
31-
}
32-
this._android.setId(this._androidViewId);
3330
if (this.penColor)
34-
this._android.setPenColor(this.penColor.android);
31+
this._android.setPenColor(new color.Color(this.penColor).android);
3532
if (this.penWidth)
3633
this._android.setMinWidth(this.penWidth);
3734
};
35+
Object.defineProperty(SignaturePad.prototype, "drawing", {
36+
get: function () {
37+
// check if empty first
38+
if (!this._android.isEmpty())
39+
console.log('has drawing');
40+
return this._android.getTransparentSignatureBitmap();
41+
},
42+
enumerable: true,
43+
configurable: true
44+
});
3845
return SignaturePad;
3946
})(common.SignaturePad);
4047
exports.SignaturePad = SignaturePad;

signaturepad.android.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import common = require("./signaturepad-common");
2+
import color = require("color");
23

34
global.moduleMerge(common, exports);
45

56
export class SignaturePad extends common.SignaturePad {
67
private _android: com.github.gcacace.signaturepad.views.SignaturePad;
78

8-
constructor() {
9-
super();
10-
}
11-
129
get android(): com.github.gcacace.signaturepad.views.SignaturePad {
1310
return this._android;
1411
}
@@ -21,16 +18,19 @@ export class SignaturePad extends common.SignaturePad {
2118

2219
this._android = new com.github.gcacace.signaturepad.views.SignaturePad(this._context, null);
2320

24-
if (!this._androidViewId) {
25-
this._androidViewId = android.view.View.generateViewId();
26-
}
27-
this._android.setId(this._androidViewId);
28-
2921
if (this.penColor)
30-
this._android.setPenColor(this.penColor.android);
22+
this._android.setPenColor(new color.Color(this.penColor).android);
3123

3224
if (this.penWidth)
3325
this._android.setMinWidth(this.penWidth);
3426

3527
}
28+
29+
get drawing(): any {
30+
// check if empty first
31+
if (!this._android.isEmpty())
32+
console.log('has drawing');
33+
return this._android.getTransparentSignatureBitmap();
34+
}
35+
3636
}

signaturepad.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ declare module "signaturepad" {
2323
*/
2424
ios: any /* SignatureView */;
2525

26+
/*
27+
* Gets the drawing from the signature pad view.
28+
*/
29+
drawing: any; /* BitMap (Android) -- .png (iOS) */
30+
2631
/**
2732
* Gets or set the stroke color attribute
2833
*/

0 commit comments

Comments
 (0)