2015-11-29 06:17:04 +08:00
|
|
|
import {Page, NavParams} from 'ionic/ionic';
|
|
|
|
|
2015-11-29 06:52:05 +08:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2015-11-29 06:17:04 +08:00
|
|
|
@Page({
|
|
|
|
templateUrl: 'app/plugin/plugin.html',
|
|
|
|
})
|
|
|
|
export class Plugin {
|
|
|
|
constructor(params: NavParams) {
|
|
|
|
|
|
|
|
this.plugin = params.get('plugin');
|
|
|
|
console.log('Plugin', this.plugin);
|
|
|
|
|
|
|
|
this.methods = Object.keys(this.plugin).filter((k) => {
|
|
|
|
if(typeof this.plugin[k] === 'function') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
doMethod(method) {
|
2015-11-29 06:24:38 +08:00
|
|
|
|
2015-11-29 06:52:05 +08:00
|
|
|
let pluginMethodArgEntry = demoArgs[this.plugin];
|
|
|
|
|
|
|
|
let args = [];
|
|
|
|
if(pluginMethodArgEntry) {
|
|
|
|
args = pluginMethodArgEntry[method] || [];
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('Doing method', method, 'on Plugin', this.plugin, 'args:', args);
|
2015-11-29 06:24:38 +08:00
|
|
|
// TODO: Pass args
|
2015-11-29 06:52:05 +08:00
|
|
|
this.plugin[method].apply(this.plugin, args);
|
2015-11-29 06:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|