@applicaster/zapp-react-native-ui-components
Version:
Applicaster Zapp React Native ui components for the Quick Brick App
22 lines (17 loc) • 655 B
text/typescript
import { PixelRatio } from "react-native";
import { isNil, identity } from "ramda";
import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
// HACK - to prevent text flickering
export const withAdjustedLineHeight = (styles) => {
const fontScale = PixelRatio.getFontScale();
const lineHeight = toNumber(styles.lineHeight);
if (isNil(lineHeight)) {
return styles;
}
return { ...styles, lineHeight: lineHeight * fontScale };
};
export const withScaledLineHeight = platformSelect({
ios: withAdjustedLineHeight,
default: identity,
});