// accurate up to 0.5

import {PixelRatio} from 'react-native';

const fontScale = PixelRatio.getFontScale();
export const computeElegantNumber = (lineHeight: number) => {
  const values = [
    Math.floor(lineHeight),
    Math.floor(lineHeight) + 0.5,
    Math.ceil(lineHeight),
  ];
  const closestValue = values.reduce((prev, curr) => {
    return Math.abs(curr - lineHeight) < Math.abs(prev - lineHeight)
      ? curr
      : prev;
  });
  return closestValue;
};

export const LINE_HEIGHT_XS_DIFFERENCE =
  computeElegantNumber(19.6 * fontScale) - computeElegantNumber(19.6);
export const LINE_HEIGHT_S_DIFFERENCE =
  computeElegantNumber(22.5 * fontScale) - computeElegantNumber(22.5);
