/* eslint-disable global-require */ import { Ionicons } from '@expo/vector-icons' import useModel from 'flooks' import * as Font from 'expo-font' import * as SplashScreen from 'expo-splash-screen' import * as React from 'react' import Toast from '../flooks/Toast' export default function useCachedResources() { const [isLoadingComplete, setLoadingComplete] = React.useState(false) // Load any resources or data that we need prior to rendering the app React.useEffect(() => { async function loadResourcesAndDataAsync() { try { SplashScreen.preventAutoHideAsync() // 初始化 Toast useModel(Toast, []) // Load fonts await Font.loadAsync( 'antoutline', // eslint-disable-next-line require('@ant-design/icons-react-native/fonts/antoutline.ttf') ) await Font.loadAsync( 'antfill', // eslint-disable-next-line require('@ant-design/icons-react-native/fonts/antfill.ttf') ) await Font.loadAsync({ ...Ionicons.font, 'space-mono': require('../assets/fonts/SpaceMono-Regular.ttf'), }) } catch (e) { // We might want to provide this error information to an error reporting service // eslint-disable-next-line no-console console.warn(e) } finally { setLoadingComplete(true) SplashScreen.hideAsync() } } loadResourcesAndDataAsync() }, []) return isLoadingComplete }