GithubHelp home page GithubHelp logo

Comments (8)

lucasferreira avatar lucasferreira commented on August 30, 2024 4

You use something like that:

import FlashMessage from "react-native-flash-message";

class App extends React.Component {
  componentDidMount() {
    FlashMessage.setColorTheme({
      success: "#25c879",
      info: "#75a4f6",
      warning: "#ff9398",
      danger: "#d990fb",
    });
  }
  render() {
   return <View />; // YOUR LAYOUT APP HERE
 }
}

setColorTheme it's a static method from FlashMessage component, you can call then in your top app structure like I did in the sample above.

So next time ahead in your code when you call showMessage({ type: "success", message: title, description:message} your message will be shown with color "#25c879".

Please try over there and feedback me if it works ;)

from react-native-flash-message.

lucasferreira avatar lucasferreira commented on August 30, 2024 1

Hi @alexakasanjeev,

Your PR will be very welcome ;)

from react-native-flash-message.

lucasferreira avatar lucasferreira commented on August 30, 2024

Hi @mozibrand

Colors are defined here:
https://github.com/lucasferreira/react-native-flash-message/blob/master/src/FlashMessage.js#L344

As a static variable in Component they are defined globally. You could customize globally using setColorTheme or when you call showMessage you could pass a custom background color or font color.

It's that your question?

from react-native-flash-message.

eugle avatar eugle commented on August 30, 2024

Thank you for your answer, but I'm not quite sure how to do it, like, should I write it like this:
showMessage({
type: state,
message: title,
description:message,
setColorTheme: {
success: "#25c879",
info: "#75a4f6",
warning: "#ff9398",
danger: "#d990fb",
}
});

It didn't work

from react-native-flash-message.

eugle avatar eugle commented on August 30, 2024

Please tell me how it is implemented,thank you ver much

from react-native-flash-message.

eugle avatar eugle commented on August 30, 2024

Thank you very much for your contribution,Is very perfect

from react-native-flash-message.

lucasferreira avatar lucasferreira commented on August 30, 2024

You're welcome ;)

from react-native-flash-message.

sanjeevyadavIT avatar sanjeevyadavIT commented on August 30, 2024

@lucasferreira Can I update Readme file, mentioning this static method, and how to change color, I mean, we don't have to look at source code or search issue, for this

I want to make two edits in README, can I contribute this?

  1. Mention how to change color
  2. Rename Props title to FlashMessage component Props(this will just remove ambiguity)

from react-native-flash-message.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.