magicismight / react-native-root-toast

react native toast like component, pure javascript solution
MIT License
2.1k stars 403 forks source link

Please add support for adding a custom icon before the text #123

Open KaranChimple opened 4 years ago

Yandamuri commented 3 years ago

Yes, I am also looking for this feature

kilisoria commented 3 years ago

Hi Guys! I had the same issue but I tried to add an React element in the message and it works.

return Toast.show(
    <>
      <MessageIcon type="FontAwesome" ios={icon} android={icon} />
      <MessageText>{` ${message}`}</MessageText>
    </>,
    {`
Yandamuri commented 3 years ago

@kilisoria this is custom View is rendering inside the actual Toast View As shown in the below image

Screenshot_1613478193

here background black View is Actual Toast View. Is it possible to remove this actual Toast View?

kilisoria commented 3 years ago

I'm not sure but I think you can try to modify the styles for Toast main container, there is a property for that, and set same background color or modify margin/padding sizes.

Yandamuri commented 3 years ago

@kilisoria This is how I achieved my requirement

const toastMainContianer = {
    height: 41,
    paddingLeft: 13.5,
    paddingRight: 18,
    paddingVertical: 11,
    backgroundColor: '#4B5460',
    borderRadius: 10
}

Toast.show(<View style={toastMainContianer}><Text style={{color: '#FFFFFF'}}>{message}</Text></View>, {
    duration: 1000,
    position: -99, 
    shadow: false,
    animation: true,
    hideOnPress: true,
    delay: 0,
    backgroundColor: 'F2F8FF' //This is my app background color. So that Toast main container background color will be mixed with app background color.
});

BTW, I didn't find Toast main container prop. Can you let me know the prop name and where is it mentioned in the documentation?

kilisoria commented 3 years ago

Hi! You have the following props:

.......
 containerStyle: {

},
textStyle: {

},
......

image

Yandamuri commented 3 years ago

Hey This is Awesome!. In fact, containerStyle and textStyleare not mentioned in the documentation. Can you tell me how to find out all the available props?

usually package maintainers are not mentioning all the available props in the documentation. Is there any way to find out through VScodeeditor?

stanislav-sidorov-empeek commented 3 years ago

please update types from msg: string to ReactNode

AndreasA commented 3 years ago

Created PR to adjust type for message: https://github.com/magicismight/react-native-root-toast/pull/150/files

EDIT: I also just found this PR: https://github.com/magicismight/react-native-root-toast/pull/111 which fixes the type and does additional stuff regarding RectNode support. Not sure if that is necessary as apparently it already works, so only the type should be wrong but maybe there are some specific components that make it necessary?

vladhelios commented 5 months ago

Any updates? Support react node type is really much needed

felipejh commented 3 months ago

Waiting for this. It would be very usefull.

augusthjerrild commented 3 weeks ago

Is this feature something that is planned? Or is this library not maintained anymore? :-)