mukaschultze / nativescript-windowed-modal

Consistent modals for Android and iOS
https://www.npmjs.com/package/nativescript-windowed-modal
Apache License 2.0
47 stars 18 forks source link

[feature][nativescript-vue] Allow overriding default options when installing the plugin #37

Open cypherix93 opened 4 years ago

cypherix93 commented 4 years ago

When calling Vue.use(VueWindowedModal), please allow passing in the default options as a 2nd parameter, for example:

Vue.use(VueWindowedModal, {
  fullscreen: true,
  dimAmount: 0.25
})

I'm thinking the only change that would be required to do this is accept a 2nd parameter in the install function in the plugin, along with augmenting the base default options with the provided options if any. For example:

install(Vue, pluginOptions) {

  // -- omitted --

  Vue.prototype.$showModal = function(component, options) {
    const defaultOptions = {
        fullscreen: false,
        animated: true,
        stretched: false,
        dimAmount: 0.5,
        ios: {},
        ...pluginOptions
    };
    // build options object with defaults
    options = { ...defaultOptions, ...options };

    // -- omitted --
  }
}

I would submit a PR, but I have no way of testing this on iOS. It should work as described above, let me know what you think.

Thanks.