import { StyleSheet, Dimensions, Platform, StyleProp, TextStyle, } from "react-native"; import { Color } from "../themes"; const { width, height } = Dimensions.get("window"); const realWidth = height > width ? width : height; const flattenStyle = StyleSheet.flatten; export function getTextStyle(style: StyleProp) { const fontSize = flattenStyle(style).fontSize || 1; let scalingFactor = realWidth < 550 ? 350 : 450; if (Platform.OS === "ios") { scalingFactor *= 0.95; } const lineHeight = fontSize * 1.5; const scaledFontSize = (fontSize * realWidth) / scalingFactor; const scaledLineHeight = (lineHeight * realWidth) / scalingFactor; return { scaledFontSize, scaledLineHeight }; } const fontFamilies = { bold: "ProximaNova-Bold", medium: "ProximaNova-Medium", }; export enum DECORATION_TEXT_INPUT { "bold" = "bold", "medium" = "medium", } export function getTextInputStyle( style: StyleProp, decoration: keyof typeof DECORATION_TEXT_INPUT, placeholderTextColorProps: string ) { const fontSize = flattenStyle(style).fontSize ?? 13; let scalingFactor = 375; if (Platform.OS === "ios") { scalingFactor *= 0.9; } const lineHeight = fontSize * 1.2; const scaledFontSize = (fontSize * realWidth) / scalingFactor; const scaledLineHeight = (lineHeight * realWidth) / scalingFactor; const fontFamily = fontFamilies[decoration] || "ProximaNova-Medium"; const placeholderTextColor = placeholderTextColorProps || Color.greyPlaceholder; return { scaledFontSize, scaledLineHeight, fontFamily, placeholderTextColor }; }