26 lines
706 B
TypeScript
26 lines
706 B
TypeScript
import { PixelRatio } from "react-native";
|
|
import {
|
|
AnalyticsEventNameConstants,
|
|
BASE_SCREEN,
|
|
EVENT_NAMES,
|
|
} from "../constants";
|
|
import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent";
|
|
|
|
export const getSizeInPx = (size: number) => {
|
|
return PixelRatio.getPixelSizeForLayoutSize(size);
|
|
};
|
|
|
|
export const getIndexFromOffset = (offset: number, SIZE: number) => {
|
|
if (SIZE === 0) {
|
|
sendAsAnalyticsEvent({
|
|
name: AnalyticsEventNameConstants.HI_RN_INVALID_ARITHMETIC_ERROR,
|
|
properties: {
|
|
errorType: EVENT_NAMES.ARITHMETIC_ERROR,
|
|
error: `${offset}`,
|
|
methodName: "getIndexFromOffset",
|
|
},
|
|
});
|
|
}
|
|
return Math.abs(Math.round(offset / SIZE));
|
|
};
|