-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuseCachedResources.ts
32 lines (29 loc) · 1.07 KB
/
useCachedResources.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { FontAwesome } from '@expo/vector-icons';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import { useEffect, useState } from 'react';
export default function useCachedResources() {
const [isLoadingComplete, setLoadingComplete] = useState(false);
useEffect(() => {
async function loadResourcesAndDataAsync() {
try {
SplashScreen.preventAutoHideAsync();
await Font.loadAsync({
...FontAwesome.font,
'ubuntu-light': require('../assets/fonts/ubuntu/Ubuntu-Light.ttf'),
'ubuntu-medium': require('../assets/fonts/ubuntu/Ubuntu-Medium.ttf'),
'ubuntu-regular': require('../assets/fonts/ubuntu/Ubuntu-Regular.ttf'),
'ubuntu-bold': require('../assets/fonts/ubuntu/Ubuntu-Bold.ttf'),
Icon: require('../assets/fonts/icons/icons.ttf'),
});
} catch (e) {
console.warn(e);
} finally {
setLoadingComplete(true);
SplashScreen.hideAsync();
}
}
loadResourcesAndDataAsync();
}, []);
return isLoadingComplete;
}