Skip to content

Commit 0f12771

Browse files
Bradley MartinBradley Martin
authored andcommitted
getting ready to pub 1.0 (ios support)
1 parent 1489c19 commit 0f12771

File tree

10 files changed

+38
-34
lines changed

10 files changed

+38
-34
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
.vs
22
.vs/
3+
.vscode/
34
*.js
45
*.map
56
demo/platforms
67
demo/node_modules
78
demo/hooks
89
demo/tsconfig.json
10+
hooks/
11+
node_modules/
912
.DS_Store
1013
*.gitattributes

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
NativeScript plugin to provide a way to capture any drawing (signatures are a common use case) from the device.
66
You can use this component to capture really anything you want that can be drawn on the screen. Go crazy with it!!!
77

8-
## WARNING - iOS is in development and should be available soon. ANDROID ONLY for now.
8+
## Samples
9+
10+
Android | iOS
11+
-------- | ---------
12+
![Sample1](screens/androidDrawing.gif) | ![Sample2](screens/iosDrawing.gif)
913

1014
#### Native Libraries:
1115
Android | iOS
@@ -74,10 +78,4 @@ Attribute to specify the pen (stroke) width to use.
7478
## Methods
7579
**getDrawing()** - Promise *(returns image if successful)*
7680

77-
**clearDrawing()** - clears the drawing from the DrawingPad view.
78-
79-
## Sample Screenshots
80-
81-
Sample 1 | Sample 2
82-
-------- | ---------
83-
![Sample1](screens/sample1.png) | ![Sample2](screens/sample2.png)
81+
**clearDrawing()** - clears the drawing from the DrawingPad view.

demo/app/main-page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function pageLoaded(args) {
1515
window.setStatusBarColor(new color.Color("#0288D1").android);
1616
}
1717
}
18-
exports.pageLoaded = pageLoaded;
18+
exports.pageLoaded = pageLoaded;
1919

2020

2121

demo/app/main-page.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
<ScrollView>
44
<StackLayout>
55

6-
<DrawingPad:DrawingPad
7-
backgroundColor="black"
6+
<DrawingPad:DrawingPad
7+
backgroundColor="#222"
88
margin="10" height="400"
99
id="drawingPad"
1010
penColor="#ff4081" penWidth="3" />
1111

1212
<StackLayout orientation="horizontal">
1313
<Button text="Get Drawing" tap="getMyDrawing" />
14-
<button text="Clear Drawing" tap="clearMyDrawing" />
14+
<Button text="Clear Drawing" tap="clearMyDrawing" />
1515
</StackLayout>
16+
1617
</StackLayout>
1718
</ScrollView>
1819
</Page>

drawingpad.android.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import common = require("./drawingpad-common");
2-
import definition = require("nativescript-drawingpad");
32
import { Color } from "color";
43

54
global.moduleMerge(common, exports);
@@ -9,11 +8,11 @@ declare var com: any;
98
export class DrawingPad extends common.DrawingPad {
109
private _android: com.github.gcacace.signaturepad.views.SignaturePad;
1110

12-
get android(): com.github.gcacace.signaturepad.views.SignaturePad {
11+
get android() {
1312
return this._android;
1413
}
1514

16-
get _nativeView(): com.github.gcacace.signaturepad.views.SignaturePad {
15+
get _nativeView() {
1716
return this._android;
1817
}
1918

drawingpad.ios.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ global.moduleMerge(common, exports);
77
declare var SignatureView: any, CGRectMake: any;
88

99
export class DrawingPad extends common.DrawingPad {
10-
private _ios: SignatureView;
10+
private _ios: any = SignatureView;
1111

12-
get ios(): SignatureView {
12+
get ios(): any {
1313
return this._ios;
1414
}
1515

16-
get _nativeView(): SignatureView {
16+
get _nativeView(): any {
1717
return this._ios;
1818
}
1919

@@ -27,33 +27,32 @@ export class DrawingPad extends common.DrawingPad {
2727
super.onLoaded();
2828

2929
try {
30-
this._ios = SignatureView.alloc().initWithFrame(CGRectMake(0, 0, 100, 100));
31-
3230
if (this.penColor) {
33-
this._ios.foregroundLineColor = new Color(this.penColor).ios;
34-
this._ios.backgroundLineColor = new Color(this.penColor).ios;
31+
let value = this.penColor;
32+
this._ios.setLineColor(new Color(value).ios);
3533
}
3634

3735
if (this.penWidth) {
38-
this._ios.foregroundLineWidth = this.penWidth;
39-
this._ios.backgroundLineWidth = this.penWidth;
36+
let value = this.penWidth;
37+
this._ios.setLineWidth(value);
4038
}
4139

4240
} catch (ex) {
4341
console.log(ex);
44-
}
45-
46-
// if (isNaN(this.width) || isNaN(this.height)) {
47-
// this.requestLayout();
48-
// }
42+
}
4943

5044
}
5145

52-
public getDrawing():Promise<any> {
46+
public getDrawing(): Promise<any> {
5347
return new Promise((resolve, reject) => {
5448
try {
55-
let data = this._ios.signatureData();
56-
resolve(data);
49+
let isSigned = this._ios.isSigned();
50+
if (isSigned === true) {
51+
let data = this._ios.signatureImage();
52+
resolve(data);
53+
} else {
54+
reject("DrawingPad is empty.");
55+
}
5756
} catch (err) {
5857
reject(err);
5958
}
@@ -62,7 +61,7 @@ export class DrawingPad extends common.DrawingPad {
6261

6362
public clearDrawing(): any {
6463
try {
65-
this._ios.UILongPressGestureRecognizer();
64+
this._ios.clear();
6665
} catch (err) {
6766
console.log("Error clearing the DrawingPad: " + err);
6867
}

screens/iosDrawing.gif

88.1 KB
Loading

screens/sample1.png

-213 KB
Binary file not shown.

screens/sample2.png

-183 KB
Binary file not shown.

tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@
1212
"drawingpad.ios.ts",
1313
"drawingpad-common.ts"
1414
],
15-
"compileOnSave": false
15+
"compileOnSave": false,
16+
"exclude": [
17+
"node_modules",
18+
"platforms"
19+
]
1620
}

0 commit comments

Comments
 (0)