Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offset is not provided as prop in toast.show(str, {offset: 30}) #108

Open
maXXCZ1 opened this issue Oct 29, 2021 · 7 comments
Open

offset is not provided as prop in toast.show(str, {offset: 30}) #108

maXXCZ1 opened this issue Oct 29, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@maXXCZ1
Copy link

maXXCZ1 commented Oct 29, 2021

Current behaviour

I can't access offset prop in toast.show method.

Expected behaviour

We should be able to access offset (ideally also bottomOffset and topOffset, but that is not mentioned in documentation, so let's focus just on offset).

Documentation example states this:

toast.show("Task finished successfully", {
  type: "normal | success | warning | danger | custom",
  placement: "top | bottom",
  duration: 4000,
  offset: 30  <========== I can't access this.
  animationType: "slide-in | zoom-in",
});

Code sample

Snack example:
https://snack.expo.dev/iidWBs8MB

Screenshots (if applicable)

//

What have you tried

When i set offset (also top and bottom) in provider, it works. But that is global setting i would like to override.

Your Environment

software version
ios or android android
react-native 0.64.2
react-native-toast-notifications 3.2.2
node
npm or yarn yarn
@maXXCZ1 maXXCZ1 added the bug Something isn't working label Oct 29, 2021
@Lokprakash-babu
Copy link

Raised a PR to fix this issue.

@lminar
Copy link

lminar commented Jan 18, 2022

Hi, when the fix will be released?

@arnnis
Copy link
Owner

arnnis commented Jan 18, 2022

You can modify offset globally in ToastProvider, It's by intention not modifiable on show() because it can break the stacking feature (Toasts going over each other).

Do you have a use case where overriding ToastProvider isn't be enough?

@lminar
Copy link

lminar commented Jan 18, 2022

I use bottom position of toast and on some screens I have my bottom bar with actions . So for these screens I want to set specify (larger offset) to prevent the bottom bar from being covered by the toast.

@lminar
Copy link

lminar commented Jan 18, 2022

@arnnis but I understand the reason why it is only globally.. thanks for your time..
I found workaround: I have custom renderType and the element has margin-bottom value .. so the notification is rendered as I want.. I am ok with the stacking feature isssue that you describe

renderType={{
            custom: (toast: any) => <ToastContent {...toast} />,
            ....

const ToastContent = (props) => {
   render (
       <View marginBottom={'50px'} .....>
             <Text>{props.message}</Text>
             ......
      </View>
     );    
}

@arnnis
Copy link
Owner

arnnis commented Jan 18, 2022

We also have a style prop you can use margins there

toast.show("Toast", {
   style: {
       marginBottom: 50
   }
])

@wata-tiendubai
Copy link

With workaround solution from @lminar, i can't interact to area below the Toast :(
And solution from @arnnis only work for the non-custom toast, not work for custom toast :(
So the best option is using PR from @Lokprakash-babu. 👍
Thanks everyone! Great Toast Lib!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants