demo app hanoicomputer home category productdetail cart
This commit is contained in:
33
hooks/useCachedResources.ts
Normal file
33
hooks/useCachedResources.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import * as Font from 'expo-font';
|
||||
import * as SplashScreen from 'expo-splash-screen';
|
||||
import * as React from 'react';
|
||||
|
||||
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();
|
||||
|
||||
// Load fonts
|
||||
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
|
||||
console.warn(e);
|
||||
} finally {
|
||||
setLoadingComplete(true);
|
||||
SplashScreen.hideAsync();
|
||||
}
|
||||
}
|
||||
|
||||
loadResourcesAndDataAsync();
|
||||
}, []);
|
||||
|
||||
return isLoadingComplete;
|
||||
}
|
||||
8
hooks/useColorScheme.ts
Normal file
8
hooks/useColorScheme.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ColorSchemeName, useColorScheme as _useColorScheme } from 'react-native';
|
||||
|
||||
// The useColorScheme value is always either light or dark, but the built-in
|
||||
// type suggests that it can be null. This will not happen in practice, so this
|
||||
// makes it a bit easier to work with.
|
||||
export default function useColorScheme(): NonNullable<ColorSchemeName> {
|
||||
return _useColorScheme() as NonNullable<ColorSchemeName>;
|
||||
}
|
||||
5
hooks/useColorScheme.web.ts
Normal file
5
hooks/useColorScheme.web.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// useColorScheme from react-native does not support web currently. You can replace
|
||||
// this with react-native-appearance if you would like theme support on web.
|
||||
export default function useColorScheme() {
|
||||
return 'light';
|
||||
}
|
||||
Reference in New Issue
Block a user