UNPKG

ionic-native

Version:

Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support

76 lines 2.92 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { Plugin } from './plugin'; /** * @name Screenshot * @description Captures a screen shot * @usage * ```typescript * import {Screenshot} from 'ionic-native'; * * // Take a screenshot and save to file * Screenshot.save('jpg', 80, 'myscreenshot.jpg').then(onSuccess, onError); * * // Take a screenshot and get temporary file URI * Screenshot.URI(80).then(onSuccess, onError); * ``` */ export var Screenshot = (function () { function Screenshot() { } /** * Takes screenshot and saves the image * * @param {string} format. Format can take the value of either 'jpg' or 'png' * On ios, only 'jpg' format is supported * @param {number} quality. Determines the quality of the screenshot. * Default quality is set to 100. * @param {string} filename. Name of the file as stored on the storage * @returns {Promise<any>} */ Screenshot.save = function (format, quality, filename) { return new Promise(function (resolve, reject) { navigator.screenshot.save(function (error, result) { if (error) { reject(error); } else { resolve(result); } }, format, quality, filename); }); }; /** * Takes screenshot and returns the image as an URI * * @param {number} quality. Determines the quality of the screenshot. * Default quality is set to 100. * @returns {Promise<any>} */ Screenshot.URI = function (quality) { return new Promise(function (resolve, reject) { navigator.screenshot.URI(function (error, result) { if (error) { reject(error); } else { resolve(result); } }, quality); }); }; Screenshot = __decorate([ Plugin({ pluginName: 'Screenshot', plugin: 'https://github.com/gitawego/cordova-screenshot.git', pluginRef: 'navigator.screenshot', repo: 'https://github.com/gitawego/cordova-screenshot.git' }) ], Screenshot); return Screenshot; }()); //# sourceMappingURL=screenshot.js.map