react-native-snackbar icon indicating copy to clipboard operation
react-native-snackbar copied to clipboard

🚀 Feature Proposal - Custom Theme Support

Open ImAbhishekTomar opened this issue 4 years ago • 9 comments

If you add custom theme support something like this then this is very helpful for personalized branding.

allow this component theme configuration on app root.

Screenshot 2020-02-25 at 22 28 20

ImAbhishekTomar avatar Feb 25 '20 17:02 ImAbhishekTomar

This is a great idea and simple to add, thanks @ImAbhishekTomar. Do you want to submit a PR for this (either instructions in the README or perhaps something more advanced)?

cooperka avatar Feb 25 '20 20:02 cooperka

I am trying to get pull request for this repo, but I am failing to do. Can you please help?

ImAbhishekTomar avatar Mar 06 '20 10:03 ImAbhishekTomar

Let me know if this guide helps: https://opensource.com/article/19/7/create-pull-request-github

cooperka avatar Mar 06 '20 16:03 cooperka

I will check!! THANKS

ImAbhishekTomar avatar Mar 12 '20 22:03 ImAbhishekTomar

@cooperka -  I have done something, you can check. This is my first open source contribution so give me a suggestion if i do something wrong.

I am from C# background and I have only limited react-native knowledge so give me a suggestion how can i improve this.

https://github.com/ImAbhishekTomar/react-native-snackbar/tree/branchThemeSupport

ImAbhishekTomar avatar Mar 17 '20 09:03 ImAbhishekTomar

Any updates for that? Maybe even to connect with the dark theme of other libraries like this one?

joaodos3v avatar Aug 23 '20 14:08 joaodos3v

@joao-vieira as far as I'm aware, the screenshot of code @ImAbhishekTomar posted in the description would work out of the box. Feel free to do it in your own code and let us know what works well for you.

If you want more advanced theming integration into this library, I invite you to submit a PR!

cooperka avatar Sep 14 '20 02:09 cooperka

Hi @cooperka, thanks for the excellent work with this library! The solution indication of the @ImAbhishekTomar it worked for me too.

In my case, I created a generic method to "create my snackbar" and, so far, used only the themes of success, warning and error:

/**
 * Creates a standard object with properties according to the current theme
 *
 * @param {String} message the value that will be displayed
 * @param {Snackbar.LENGTH_LONG|LENGTH_SHORT|LENGTH_INDEFINITE} duration how long will be visible
 * @param {String} type the visual configuration of the snackbar (possibilities: success, error)
 */
export const createSnackbar = (message, duration, type = 'success') => {
  const snackbar = { text: message, duration };

  if (type.toLowerCase() === 'error') {
    return {
      ...snackbar,
      textColor: '#FFF2F2', // theme['color-danger-100']
      backgroundColor: '#DB2C66', // theme['color-danger-600']
    };
  }

  if (type.toLowerCase() === 'warning') {
    return {
      ...snackbar,
      textColor: '#FFFDF2', // theme['color-warning-100']
      backgroundColor: '#DB8B00', // theme['color-warning-600']
    };
  }

  return {
    ...snackbar,
    textColor: '#EDFFF3', // theme['color-success-100']
    backgroundColor: '#00B383', // theme['color-success-600']
  };
};

To use it, I simply do:

Snackbar.show(createSnackbar('Your message here!', Snackbar.LENGTH_SHORT));

I hope I contributed to someone 😃 Credit: colors are based on the wonderful UI Kitten 5.0

joaodos3v avatar Sep 14 '20 04:09 joaodos3v

PR please review - https://github.com/cooperka/react-native-snackbar/pull/199

ImAbhishekTomar avatar Jan 17 '23 22:01 ImAbhishekTomar