@@ -21,51 +21,47 @@ Android | iOS
2121## Installation
2222From your command prompt/termial go to your app's root folder and execute:
2323
24- ` npm install nativescript-drawingpad`
24+ ` tns plugin add nativescript-drawingpad`
2525
2626## Usage
2727#### XML:
2828``` XML
2929<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" />
3131 <ScrollView >
3232 <StackLayout >
3333
3434 <DrawingPad : DrawingPad
3535 height =" 400"
3636 id =" drawingPad"
37- penColor =" #ff4081 " penWidth =" 3 " />
37+ penColor =" {{ penColor }} " penWidth =" {{ penWidth }} " />
3838
3939 </StackLayout >
4040 </ScrollView >
4141</Page >
4242```
4343
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' ;
4748
4849// 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+
6258
6359// 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 ();
6763}
68- exports . clearUserDrawing = clearUserDrawing;
64+
6965```
7066
7167## Angular:
0 commit comments