import { useNavigation } from "@react-navigation/native"; import { INatApiError, INatApiTooManyRequestsError } from "api/error"; import { getUserAgent } from "api/userAgent"; import classnames from "classnames"; import { Button, Heading1, Heading2, ScrollViewWrapper } from "components/SharedComponents"; import { fontMonoClass, View } from "components/styledComponents"; import { t } from "i18next"; import type { Node } from "react"; import React, { useCallback } from "react"; import { I18nManager, Platform, Text } from "react-native"; import Config from "react-native-config"; import RNFS from "react-native-fs"; import RNRestart from "react-native-restart"; import useLogs from "sharedHooks/useLogs"; import useAppSize, { formatAppSizeString, formatSizeUnits, getTotalDirectorySize } from "./hooks/useAppSize"; const H1 = ( { children } ) => {children}; const H2 = ( { children } ) => {children}; const P = ( { children } ) => {children}; const CODE = ( { children, optionalClassName } ) => ( {children} ); const modelFileName: string = Platform.select( { ios: Config.IOS_MODEL_FILE_NAME, android: Config.ANDROID_MODEL_FILE_NAME } ); const taxonomyFileName = Platform.select( { ios: Config.IOS_TAXONOMY_FILE_NAME, android: Config.ANDROID_TAXONOMY_FILE_NAME } ); /* eslint-disable i18next/no-literal-string */ const Developer = (): Node => { const fileSizes = useAppSize( ); const boldClassname = ( line, isDirectory = false ) => classnames( { "text-red font-bold": line.includes( "MB" ), "text-blue": isDirectory } ); const displayFileSizes = useCallback( ( ) => Object.keys( fileSizes ).map( directory => { const contents = fileSizes[directory]; if ( !directory || !contents ) { return null; } const totalDirectorySize = formatSizeUnits( getTotalDirectorySize( contents ) ); return ( File Sizes: {" "} {directory} {`Total Directory Size: ${totalDirectorySize}`} {contents.map( ( { name, size } ) => { const line = formatAppSizeString( name, size ); return ( {line} ); } )} ); } ), [fileSizes] ); const toggleRTLandLTR = async ( ) => { const { isRTL, forceRTL } = I18nManager; await forceRTL( !isRTL ); RNRestart.restart( ); }; const navigation = useNavigation( ); const { shareLogFile, emailLogFile } = useLogs(); return ( navigation.navigate( "log" )} text="LOG" className="mb-5" /> { // eslint-disable-next-line no-undef __DEV__ && ( <> navigation.navigate( "UILibrary" )} text="UI LIBRARY" className="mb-5" /> navigation.navigate( "network" )} text="NETWORK" className="mb-5" /> { throw new Error( "Test error" ); }} text="TEST ERROR" className="mb-5" /> { throw new INatApiError( { error: "Test error", status: 422 } ); }} text="TEST INATAPIERROR" className="mb-5" /> { throw new INatApiTooManyRequestsError( ); }} text="TEST API TOO MANY REQUESTS ERROR" className="mb-5" /> { throw new Error( "Test error in promise" ); }} text="TEST UNHANDLED PROMISE REJECTION" className="mb-5" /> > ) } Computer Vision Model: {modelFileName} Taxonomy: {taxonomyFileName} Paths Documents {RNFS.DocumentDirectoryPath} Caches {RNFS.CachesDirectoryPath} Config.API_URL {Config.API_URL} Config.API_URL {Config.API_URL} getUserAgent() {getUserAgent()} {displayFileSizes( )} Log file contents ); }; export default Developer;
{`Total Directory Size: ${totalDirectorySize}`}
{line}
{RNFS.DocumentDirectoryPath}
{RNFS.CachesDirectoryPath}
{Config.API_URL}
{getUserAgent()}