mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-04-15 20:57:07 +08:00
Thug
This commit is contained in:
parent
d27dd35dd6
commit
b9bc5fd8e7
34
src/index.js
34
src/index.js
@ -2,34 +2,24 @@ import {Plugins} from './plugins';
|
||||
import {PluginConfig} from './plugin-config'
|
||||
import {promisifyCordova} from './cordova';
|
||||
|
||||
class IonicNative {
|
||||
constructor() {
|
||||
let pluginData, promised;
|
||||
for(let plugin in PluginConfig) {
|
||||
let Wrapped = {
|
||||
}
|
||||
|
||||
pluginData = PluginConfig[plugin];
|
||||
console.log('Plugin', plugin, pluginData);
|
||||
let promised;
|
||||
for(let plugin of PluginConfig) {
|
||||
console.log('Plugin', plugin.name, plugin);
|
||||
|
||||
promised = pluginData.promise;
|
||||
Wrapped[plugin.className] = {};
|
||||
|
||||
for(let method of promised) {
|
||||
promised = plugin.promise;
|
||||
|
||||
|
||||
let p = promisifyCordova(plugin, method)
|
||||
p().then((resp) => {
|
||||
console.log('Thing');
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
for(let method of promised) {
|
||||
let p = promisifyCordova(plugin.id, method)
|
||||
Wrapped[plugin.className][method] = p;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export {Wrapped};
|
||||
|
||||
let Native = new IonicNative;
|
||||
|
||||
export default Native;
|
||||
|
||||
// Because require isn't exporting properly, who the fuck knows
|
||||
window.IonicNative = Native
|
||||
window.Native = Wrapped;
|
||||
|
@ -1,7 +1,8 @@
|
||||
export var PluginConfig = {
|
||||
"camera": {
|
||||
'name': 'Camera',
|
||||
export var PluginConfig = [
|
||||
{
|
||||
'id': 'camera',
|
||||
'className': 'Camera',
|
||||
'plugin': 'cordova-plugin-camera',
|
||||
"promise": ["takePicture"],
|
||||
'promise': ['takePicture'],
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -1 +1,7 @@
|
||||
console.log(window.require);
|
||||
console.log(window.Native);
|
||||
|
||||
Native.Camera.takePicture().then(function(resp) {
|
||||
console.log('Got picture');
|
||||
}, function(err) {
|
||||
console.log('ERROR');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user