robcalcroft / react-native-in-app-notification

:bell: Customisable in-app notification component for React Native
MIT License
270 stars 78 forks source link

Passing type prop ('success', 'error', 'info' etc) to showNotification #37

Open albertkai opened 5 years ago

albertkai commented 5 years ago

Got any ideas on how i can pass additional props to showNotification function, in order to be able to customise the appearance, depending on the notification type. For example, i want to show green background for success notifications, and red for error etc.

VitaliiK91 commented 5 years ago

Hey @albertkai , I created a pull request showing how to achieve what you are looking for. You can take a look here. Hope it helps 🤓

DrySoldier commented 4 years ago

Hi @VitaliiK91 , I think the documentation might be wrong, as passing additionalProps={{ type: 'error' }} will result in an error. That being said, the PR you created with instructions on how to use it does not match the documentation in the readme anyways, and trying to use it that way yields no results. Any help would be appreciated, thanks!

VitaliiK91 commented 4 years ago

@DrySoldier what type of error are you getting? Could you share the code snippet? As you can see in PR comments, the merged code is slightly different and README has the proper instructions, basically passProps has been renamed to additionalProps

stonebinox commented 4 years ago

@VitaliiK91 your readme has this

{
              title: 'You pressed it!',
              message: 'The notification has been triggered',
              onPress: () => Alert.alert('Alert', 'You clicked the notification!')
              additionalProps={{ type: 'error' }}
            }

and if you look at the additionalProps line, you'll see that it's incorrect JSON structure with the = sign. But looking at your code with the PR you mentioned above, I tried

{
              title: 'You pressed it!',
              message: 'The notification has been triggered',
              onPress: () => Alert.alert('Alert', 'You clicked the notification!')
              additionalProps: { type: 'error' }
            }

and the notification doesn't change in color or style whatsoever. There is no error either. It would be great if you could update the Readme with the right structure and (maybe?) one other example with all the options passed in so we understand how extensible it is.

VitaliiK91 commented 4 years ago

@stonebinox Hi, yes you absolutely correct, I will open a new PR for README fix. As for color or style change I am not sure what you mean? This prop will just pass additional props to the notificationBodyComponent where you can access them and style notification body. Could you share your NotificationBody component? Thank you!

stonebinox commented 4 years ago

@VitaliiK91 actually i figured out the NotificationBody bit so no worries. Maybe, updating the Readme with what I pointed out should be enough.

VitaliiK91 commented 4 years ago

@stonebinox Glad it worked for you. Yeah I opened a PR with a README fix, hopefully that would help! Cheers!