Git Product home page Git Product logo

Comments (1)

a7medev avatar a7medev commented on September 22, 2024 2

Hello @PEvgeniya! Thanks for reporting this issue.

This issue is that the values passed to BugReporting.setFloatingButtonEdge aren't normalized from React Native values to appropriate values to pass to the native side so the way the number passed is treated differs both Android and iOS.

On Android, it expects the value to be in pixel size (px), not in layout size (dp), and React Native uses layout size by default, so the value returned from Dimensions needs to get scaled to be in pixel size which you can achieve using the PixelRatio API as below:

const height = Dimensions.get('window').height;

BugReporting.setFloatingButtonEdge(
  FloatingButtonPosition.right,
  PixelRatio.getPixelSizeForLayoutSize(height * 0.8),
);

On iOS, it expects the value in layout size which is the default in React Native so you can pass the value from Dimensions as is.

The complete code should look something like this (I'm using Platform to conditionally normalize the value on Android):

const height = Dimensions.get('window').height;
const offset = 0.8 * height;

BugReporting.setFloatingButtonEdge(
  FloatingButtonPosition.right,
  Platform.OS === 'android' ? PixelRatio.getPixelSizeForLayoutSize(offset) : offset,
);

We already have it on our radar to make such APIs behave the same on both iOS and Android without the need for manual normalization from the developer's end, but this is how you can achieve it for now. 🙏🏼

I'll close the issue for now but feel free to reopen it if you're still facing any issues with it.

from instabug-react-native.

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.