From 044a824f294fa6e6b843b3d2f8ce3ab9534e9e06 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Sat, 28 Nov 2015 16:52:05 -0600 Subject: [PATCH] yea toast --- demo/package.json | 8 +++++++- demo/www/app/plugin/plugin.js | 26 ++++++++++++++++++++++++-- dist/plugins/toast.d.ts | 6 ++++++ dist/plugins/toast.js | 10 ++++++++++ dist/src/plugins/toast.d.ts | 6 ++++++ dist/src/plugins/toast.js | 8 ++++++++ src/plugins/toast.ts | 13 +++++++++++++ 7 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 dist/plugins/toast.d.ts create mode 100644 dist/plugins/toast.js create mode 100644 dist/src/plugins/toast.d.ts create mode 100644 dist/src/plugins/toast.js create mode 100644 src/plugins/toast.ts diff --git a/demo/package.json b/demo/package.json index 1f22260a4..e166e758d 100644 --- a/demo/package.json +++ b/demo/package.json @@ -17,5 +17,11 @@ "ionic-native": "^1.0.7" }, "name": "demo", - "description": "demo: An Ionic project" + "description": "demo: An Ionic project", + "cordovaPlugins": [ + "cordova-plugin-x-toast" + ], + "cordovaPlatforms": [ + "ios" + ] } diff --git a/demo/www/app/plugin/plugin.js b/demo/www/app/plugin/plugin.js index 7b807493e..ef7d59caa 100644 --- a/demo/www/app/plugin/plugin.js +++ b/demo/www/app/plugin/plugin.js @@ -1,5 +1,20 @@ import {Page, NavParams} from 'ionic/ionic'; +import {Camera, StatusBar, Toast} from 'ionic-native'; + +// To specify arguments for any plugin calls +var demoArgs = {}; +demoArgs[Toast] = { + showWithOptions: [ + { + message: "hey there", + duration: "short", + position: "bottom", + addPixelsY: -40 // added a negative value to move it up a bit (default 0) + } + ] +} + @Page({ templateUrl: 'app/plugin/plugin.html', }) @@ -18,10 +33,17 @@ export class Plugin { } doMethod(method) { - console.log('Doing method', method, 'on Plugin', this.plugin); + let pluginMethodArgEntry = demoArgs[this.plugin]; + + let args = []; + if(pluginMethodArgEntry) { + args = pluginMethodArgEntry[method] || []; + } + + console.log('Doing method', method, 'on Plugin', this.plugin, 'args:', args); // TODO: Pass args - this.plugin[method].apply(this.plugin); + this.plugin[method].apply(this.plugin, args); } } diff --git a/dist/plugins/toast.d.ts b/dist/plugins/toast.d.ts new file mode 100644 index 000000000..4341e8549 --- /dev/null +++ b/dist/plugins/toast.d.ts @@ -0,0 +1,6 @@ +export declare var Toast: { + name: string; + plugin: string; + showWithOptions: (...args: any[]) => any; + hide: (...args: any[]) => any; +}; diff --git a/dist/plugins/toast.js b/dist/plugins/toast.js new file mode 100644 index 000000000..cc13d9fd3 --- /dev/null +++ b/dist/plugins/toast.js @@ -0,0 +1,10 @@ +var util_1 = require('../util'); +var PLUGIN_REF = 'plugins.toast'; +exports.Toast = { + // Metadata + name: 'Toast', + plugin: 'cordova-plugin-x-toast', + // Methods + showWithOptions: util_1.wrap(PLUGIN_REF, 'showWithOptions', 1, 2), + hide: util_1.promisify(PLUGIN_REF, 'hide', 0, 1), +}; diff --git a/dist/src/plugins/toast.d.ts b/dist/src/plugins/toast.d.ts new file mode 100644 index 000000000..45f90d6b9 --- /dev/null +++ b/dist/src/plugins/toast.d.ts @@ -0,0 +1,6 @@ +export declare var Toast: { + name: string; + plugin: string; + showWithOptions: (...args: any[]) => any; + hide: (...args: any[]) => any; +}; diff --git a/dist/src/plugins/toast.js b/dist/src/plugins/toast.js new file mode 100644 index 000000000..2b9ef8b32 --- /dev/null +++ b/dist/src/plugins/toast.js @@ -0,0 +1,8 @@ +var util_1 = require('../util'); +var PLUGIN_REF = 'plugins.toast'; +exports.Toast = { + name: 'Toast', + plugin: 'cordova-plugin-x-toast', + showWithOptions: util_1.wrap(PLUGIN_REF, 'showWithOptions', 1, 2), + hide: util_1.promisify(PLUGIN_REF, 'hide', 0, 1), +}; diff --git a/src/plugins/toast.ts b/src/plugins/toast.ts new file mode 100644 index 000000000..def9ec824 --- /dev/null +++ b/src/plugins/toast.ts @@ -0,0 +1,13 @@ +import {wrap, promisify} from '../util'; + +let PLUGIN_REF = 'plugins.toast' + +export var Toast = { + // Metadata + name: 'Toast', + plugin: 'cordova-plugin-x-toast', + + // Methods + showWithOptions: wrap(PLUGIN_REF, 'showWithOptions', 1, 2), + hide: promisify(PLUGIN_REF, 'hide', 0, 1), +}