Files
super-app/App/common/utilities/SizeUtils.ts
2024-03-27 15:06:03 +00:00

16 lines
449 B
TypeScript

import { PixelRatio } from "react-native";
import { logToSentry } from "../hooks/useSentryLogging";
export const getSizeInPx = (size: number) => {
return PixelRatio.getPixelSizeForLayoutSize(size);
};
export const getIndexFromOffset = (offset: number, SIZE: number) => {
if (SIZE === 0) {
logToSentry(
`Division by zero, offset: ${offset} | MethodName: getIndexFromOffset`
);
}
return Math.abs(Math.round(offset / SIZE));
};