import { Stack } from "expo-router"; import React from "react"; import * as RN from "react-native"; import { useFonts, Inter_400Regular, Inter_500Medium, Inter_600SemiBold, Inter_700Bold, } from "@expo-google-fonts/inter"; import { AppProvider } from "@/providers"; // Helper to resolve font family based on styles const resolveCustomStyle = (style: any) => { if (!style) { return { fontFamily: "Inter-Regular" }; } const flat = RN.StyleSheet.flatten(style); // If fontFamily is already specified (like icons), don't override it! if (flat && flat.fontFamily && flat.fontFamily !== "System" && flat.fontFamily !== "sans-serif") { return style; } // Map font weight to Inter weights const weight = flat?.fontWeight; let fontFamily = "Inter-Regular"; if (weight === "bold" || weight === "700" || weight === "800" || weight === "900") { fontFamily = "Inter-Bold"; } else if (weight === "600") { fontFamily = "Inter-SemiBold"; } else if (weight === "500") { fontFamily = "Inter-Medium"; } // Merge the new fontFamily with the rest of the styles return [ style, { fontFamily } ]; }; const OriginalText = RN.Text; const OriginalTextInput = RN.TextInput; // Custom Text HOC const CustomText = React.forwardRef((props: any, ref: any) => { const { style, allowFontScaling, ...rest } = props; const newStyle = resolveCustomStyle(style); return ( ); }); // Bind static props/methods if any Object.assign(CustomText, OriginalText); try { const rnExports = require("react-native"); const descText = Object.getOwnPropertyDescriptor(rnExports, "Text"); if (descText && descText.configurable) { Object.defineProperty(rnExports, "Text", { get: () => CustomText, configurable: true, }); } } catch (e) { // Silently ignore if module exports are immutable in web bundle environment } // Custom TextInput HOC const CustomTextInput = React.forwardRef((props: any, ref: any) => { const { style, allowFontScaling, ...rest } = props; const newStyle = resolveCustomStyle(style); return ( ); }); Object.assign(CustomTextInput, OriginalTextInput); try { const rnExports = require("react-native"); const descInput = Object.getOwnPropertyDescriptor(rnExports, "TextInput"); if (descInput && descInput.configurable) { Object.defineProperty(rnExports, "TextInput", { get: () => CustomTextInput, configurable: true, }); } } catch (e) { // Silently ignore if module exports are immutable in web bundle environment } import { useEffect } from "react"; import { Alert, Platform } from "react-native"; import { GestureHandlerRootView } from "react-native-gesture-handler"; import * as ScreenCapture from "expo-screen-capture"; export default function RootLayout() { const [fontsLoaded] = useFonts({ "Inter-Regular": Inter_400Regular, "Inter-Medium": Inter_500Medium, "Inter-SemiBold": Inter_600SemiBold, "Inter-Bold": Inter_700Bold, }); useEffect(() => { if (Platform.OS === "web") return; let isMounted = true; void ScreenCapture.preventScreenCaptureAsync(); const subscription = ScreenCapture.addScreenshotListener(() => { if (!isMounted) return; Alert.alert( "Confidential Clinical Content", "Acupedia clinical reference materials and diagrams are proprietary. Capturing screenshots is restricted to protect clinical data." ); }); return () => { isMounted = false; subscription?.remove(); }; }, []); if (!fontsLoaded) { return null; } return ( ); }