Toast-PhoneGap-Plugin icon indicating copy to clipboard operation
Toast-PhoneGap-Plugin copied to clipboard

Global definition for style

Open hirbod opened this issue 8 years ago • 10 comments

Hi @EddyVerbruggen,

just awesome you've added the possibility to style toasts. But as you may know me, I have always some extra wishes :p

I'm calling my toasts in different ways at many positions in my code. Is it possible to call a function on app.run (example when using angular), or even deviceready, to define default styling instead of passing the values over and over again? I would like to define a default. It should be possible to overwrite though, but would make things much more efficient.

hirbod avatar Feb 03 '16 15:02 hirbod

Haha, keep 'em coming ;)

I imagine you have one place in your app where you actually call showWithOptions, right? Or else you should create one really. You can then pass in an object and merge with your 'defaults' object. I don't really see why that should be part of the plugin.

That being said perhaps I'll make a 'setDefaultOptions' function anyway. Just not today :)

EddyVerbruggen avatar Feb 03 '16 15:02 EddyVerbruggen

Haha, yeah, you're right. Currently, I've mixed a lot. (showLongCenter, showShortTop() etc.) at different positions in my code, depending on my layout.

But a

window.plugins.toast.setDefaultOptions({
    styling: {
      opacity: 0.75, // 0.0 (transparent) to 1.0 (opaque). Default 0.8
      backgroundColor: '#FF0000', // make sure you use #RRGGBB. Default #333333
      cornerRadius: 16, // minimum is 0 (square). iOS default 20, Android default 100
      horizontalPadding: 20, // iOS default 16, Android default 50
      verticalPadding: 16 // iOS default 12, Android default 30
    }
  });

would be awesome. Not needed today :). Actually, setDefaultLayoutOptions() should be enough.

hirbod avatar Feb 03 '16 15:02 hirbod

:+1:

EddyVerbruggen avatar Feb 03 '16 15:02 EddyVerbruggen

Guys "cannot read property 'toast' of undefined" Can anyone help me with this error?

@EddyVerbruggen

abhisheknjain avatar Feb 03 '16 18:02 abhisheknjain

StackOverflow can

EddyVerbruggen avatar Feb 03 '16 18:02 EddyVerbruggen

Hi @EddyVerbruggen

Didn't find any solution on StackOverflow. Maybe I missed it. Can you please share the link. It will be really helpful.

abhisheknjain avatar Feb 03 '16 18:02 abhisheknjain

Would you please stop hijacking my issue?

hirbod avatar Feb 03 '16 18:02 hirbod

huh??

abhisheknjain avatar Feb 03 '16 18:02 abhisheknjain

Guys no intention to hijack anyone's airplane or issue.

Just as this issue https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues/58 was open, and saw the author @EddyVerbruggen active here. Thought would ask for help here.

Kindly help if possible.

Thanks in advance.

abhisheknjain avatar Feb 03 '16 19:02 abhisheknjain

Hey @abhisheknjain no worries, you're probably not aware that I get notified of ALL comments in ANY issue, so you might as well have added it to #58 (I will also add a comment there).

@Hirbod has a good point that his issue is now polluted with irrelevant comments.

Just something to consider next time :+1:

EddyVerbruggen avatar Feb 03 '16 19:02 EddyVerbruggen