@@ -21,51 +21,47 @@ Android | iOS
21
21
## Installation
22
22
From your command prompt/termial go to your app's root folder and execute:
23
23
24
- ` npm install nativescript-drawingpad`
24
+ ` tns plugin add nativescript-drawingpad`
25
25
26
26
## Usage
27
27
#### XML:
28
28
``` XML
29
29
<Page xmlns =" http://schemas.nativescript.org/tns.xsd" xmlns : DrawingPad =" nativescript-drawingpad" loaded =" pageLoaded" >
30
- <ActionBar title =" NativeScript-DrawingPad" color = " #fff " backgroundColor = " #03A9F4 " />
30
+ <ActionBar title =" NativeScript-DrawingPad" />
31
31
<ScrollView >
32
32
<StackLayout >
33
33
34
34
<DrawingPad : DrawingPad
35
35
height =" 400"
36
36
id =" drawingPad"
37
- penColor =" #ff4081 " penWidth =" 3 " />
37
+ penColor =" {{ penColor }} " penWidth =" {{ penWidth }} " />
38
38
39
39
</StackLayout >
40
40
</ScrollView >
41
41
</Page >
42
42
```
43
43
44
- #### JS:
45
- ``` JS
46
- var frame = require (" ui/frame" );
44
+ ### TS:
45
+ ``` TS
46
+ import { topmost } from ' ui/frame' ;
47
+ import { DrawingPad } from ' nativescript-drawingpad' ;
47
48
48
49
// To get the drawing...
49
- function getDrawingAsPic (args ) {
50
- // get reference to the drawing pad
51
- var pad = frame .topmost ().currentPage .getViewById (" drawingPad" );
52
- // then get the drawing (Bitmap on Android) of the drawingpad
53
- var drawingImage;
54
- pad .getDrawing ().then (function (data ) {
55
- console .log (data);
56
- drawingImage = data;
57
- }, function (err ) {
58
- console .log (err);
59
- })
60
- }
61
- exports .getDrawingAsPic = getDrawingAsPic;
50
+
51
+ public getMyDrawing () {
52
+ let drawingPad = topmost ().getViewById (' myDrawingPad' );
53
+ drawingPad .getDrawing ().then ((res ) => {
54
+ console .log (res );
55
+ });
56
+ }
57
+
62
58
63
59
// If you want to clear the signature/drawing...
64
- function clearUserDrawing ( args ) {
65
- var pad = frame . topmost ().currentPage . getViewById (" drawingPad " );
66
- pad .clearDrawing ();
60
+ public clearMyDrawing ( ) {
61
+ let drawingPad = topmost ().getViewById (' myDrawingPad ' );
62
+ drawingPad .clearDrawing ();
67
63
}
68
- exports . clearUserDrawing = clearUserDrawing;
64
+
69
65
```
70
66
71
67
## Angular:
0 commit comments