@nativescript-community/drawingpad
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -1,2 +0,2 @@ | ||
import { View, Property, Color } from '@nativescript/core'; | ||
import { Color, Property, View } from '@nativescript/core'; | ||
export declare abstract class DrawingPadBase extends View { | ||
@@ -8,2 +8,3 @@ penColor: Color; | ||
abstract getDrawing(): Promise<any>; | ||
abstract getDrawingAsBase64(): Promise<string>; | ||
getTransparentDrawing(): Promise<any>; | ||
@@ -10,0 +11,0 @@ abstract getDrawingSvg(): Promise<string>; |
@@ -1,6 +0,6 @@ | ||
import { View, Property, Color } from '@nativescript/core'; | ||
import { Color, Property, View } from '@nativescript/core'; | ||
export class DrawingPadBase extends View { | ||
getTransparentDrawing() { | ||
return new Promise((resolve, reject) => { | ||
resolve(); | ||
resolve(null); | ||
}); | ||
@@ -7,0 +7,0 @@ } |
import { DrawingPadBase } from './drawingpad-common'; | ||
export declare class DrawingPad extends DrawingPadBase { | ||
get android(): any; | ||
createNativeView(): any; | ||
getDrawing(): Promise<any>; | ||
getDrawingAsBase64(format?: 'png' | 'jpg' | 'jpeg'): Promise<string>; | ||
getTransparentDrawing(): Promise<any>; | ||
@@ -7,0 +7,0 @@ getDrawingSvg(): Promise<string>; |
@@ -1,7 +0,4 @@ | ||
import { Color } from '@nativescript/core'; | ||
import { Color, ImageSource } from '@nativescript/core'; | ||
import { DrawingPadBase, penColorProperty, penWidthProperty } from './drawingpad-common'; | ||
export class DrawingPad extends DrawingPadBase { | ||
get android() { | ||
return this.nativeView; | ||
} | ||
createNativeView() { | ||
@@ -46,2 +43,20 @@ const signaturePad = new com.github.gcacace.signaturepad.views.SignaturePad(this._context, null); | ||
} | ||
getDrawingAsBase64(format = 'png') { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
if (!this.nativeView.isEmpty()) { | ||
const bitmap = this.nativeView.getSignatureBitmap(); | ||
const img = new ImageSource(bitmap); | ||
const base64Img = img.toBase64String(format); | ||
resolve(base64Img); | ||
} | ||
else { | ||
reject('DrawingPad is empty.'); | ||
} | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
getTransparentDrawing() { | ||
@@ -48,0 +63,0 @@ return new Promise((resolve, reject) => { |
@@ -32,2 +32,8 @@ import { Color, View } from '@nativescript/core'; | ||
/** | ||
* Returns the image as base64 string. | ||
* @param format - The format of the image when converting to ImageSource. "png" | "jpg" | "jpeg". Default is "png". | ||
*/ | ||
getDrawingAsBase64(format: 'png' | 'jpg' | 'jpeg'): Promise<string>; | ||
/** | ||
* *** ANDROID ONLY *** | ||
@@ -34,0 +40,0 @@ * Returns a bitmap with a transparent background. |
@@ -6,7 +6,7 @@ import { DrawingPadBase } from './drawingpad-common'; | ||
constructor(); | ||
get ios(): SignatureView; | ||
onLoaded(): void; | ||
getDrawing(): Promise<any>; | ||
getDrawingAsBase64(format?: 'png' | 'jpg' | 'jpeg'): Promise<string>; | ||
getDrawingSvg(): Promise<string>; | ||
clearDrawing(): void; | ||
} |
@@ -1,3 +0,3 @@ | ||
import { Color, PercentLength } from '@nativescript/core'; | ||
import { DrawingPadBase, penColorProperty, penWidthProperty, clearOnLongPressProperty } from './drawingpad-common'; | ||
import { Color, ImageSource, PercentLength } from '@nativescript/core'; | ||
import { clearOnLongPressProperty, DrawingPadBase, penColorProperty, penWidthProperty } from './drawingpad-common'; | ||
export class DrawingPad extends DrawingPadBase { | ||
@@ -10,5 +10,2 @@ constructor() { | ||
} | ||
get ios() { | ||
return this.nativeView; | ||
} | ||
[penWidthProperty.getDefault]() { | ||
@@ -66,2 +63,21 @@ return this.nativeView.foregroundLineWidth; | ||
} | ||
getDrawingAsBase64(format = 'png') { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
const isSigned = this.nativeView.isSigned(); | ||
if (isSigned === true) { | ||
const data = this.nativeView.signatureImage(); | ||
const img = new ImageSource(data); | ||
const base64Img = img.toBase64String(format); | ||
resolve(base64Img); | ||
} | ||
else { | ||
reject('DrawingPad is empty.'); | ||
} | ||
} | ||
catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
getDrawingSvg() { | ||
@@ -68,0 +84,0 @@ return new Promise((resolve, reject) => { |
@@ -5,7 +5,7 @@ { | ||
"typings": "index.d.ts", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"nativescript": { | ||
"platforms": { | ||
"android": "3.0.0", | ||
"ios": "3.0.0" | ||
"android": "7.0.0", | ||
"ios": "7.0.0" | ||
}, | ||
@@ -25,3 +25,3 @@ "plugin": { | ||
"bugs": { | ||
"url": "https://github.com/bradmartin/nativescript-drawingpad/issues" | ||
"url": "https://github.com/nativescript-community/nativescript-drawingpad/issues" | ||
}, | ||
@@ -47,12 +47,12 @@ "contributors": [ | ||
"devDependencies": { | ||
"husky": "^4.2.5", | ||
"lint-staged": "^10.2.11", | ||
"prettier": "^2.0.5", | ||
"@nativescript/core": "rc", | ||
"@nativescript/types": "rc", | ||
"husky": "^4.3.0", | ||
"lint-staged": "^10.4.0", | ||
"prettier": "^2.1.2", | ||
"@nativescript/core": "~7.0.5", | ||
"@nativescript/types": "~7.0.4", | ||
"rimraf": "^3.0.2", | ||
"tslint": "~6.1.3", | ||
"typescript": "~3.9.0" | ||
"typescript": "~3.9.7" | ||
}, | ||
"homepage": "https://github.com/bradmartin/nativescript-drawingpad", | ||
"homepage": "https://github.com/nativescript-community/nativescript-drawingpad", | ||
"keywords": [ | ||
@@ -65,3 +65,2 @@ "NativeScript", | ||
"drawing pad", | ||
"bradmartin", | ||
"nStudio" | ||
@@ -75,10 +74,8 @@ ], | ||
"build.native": "node scripts/build-native.js", | ||
"test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch", | ||
"test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch", | ||
"test.android": "npm run build && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch", | ||
"test.ios": "npm run build && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch", | ||
"tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"*demo*/platforms/**\"", | ||
"plugin.link": "npm link && cd ../demo && npm link nativescript-geolocation && cd ../src", | ||
"plugin.tscwatch": "npm run tsc -- -w", | ||
"demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles", | ||
"demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles", | ||
"ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**'", | ||
"demo.ios": "npm run build && cd ../demo && tns run ios", | ||
"demo.android": "npm run build && cd ../demo && tns run android", | ||
"ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/typings/**'", | ||
"precommit": "lint-staged", | ||
@@ -93,3 +90,3 @@ "generate.typings.ios": "cd ../demo && TNS_DEBUG_METADATA_PATH=\"$(pwd)/metadata\" tns build ios && TNS_TYPESCRIPT_DECLARATIONS_PATH=\"$(pwd)/typings\" tns build ios && echo 'Now look for your library typings in demo/typings!'" | ||
"lint-staged": { | ||
"**/*": [ | ||
"**/*.ts": [ | ||
"prettier --write", | ||
@@ -101,4 +98,4 @@ "git add" | ||
"type": "git", | ||
"url": "git+https://github.com/bradmartin/nativescript-drawingpad.git" | ||
"url": "git+https://github.com/nativescript-community/nativescript-drawingpad.git" | ||
} | ||
} |
/// <reference path="./node_modules/@nativescript/core/global-types.d.ts" /> | ||
/// <reference path="./node_modules/@nativescript/types/ios.d.ts" /> | ||
/// <reference path="./node_modules/@nativescript/types/android.d.ts" /> | ||
/// <reference path="./node_modules/@nativescript/types/index.d.ts" /> | ||
/// <reference path="./typings/SignatureView.d.ts" /> |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
31732
13
322
1
192
1