Skip to content

Commit

Permalink
Merge pull request #294 from fosopenscouting/fix/splashscreen
Browse files Browse the repository at this point in the history
fix splashscreen
  • Loading branch information
TijlS authored Nov 19, 2024
2 parents e21fec2 + ec1bda7 commit 8cdf31d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
21 changes: 14 additions & 7 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"expo": {
"newArchEnabled": true,
"newArchEnabled": true,
"name": "Saamdagen",
"slug": "saamdagen",
"version": "#{APP_VERSION}#",
Expand All @@ -9,11 +9,6 @@
"icon": "./assets/images/icon.png",
"scheme": "saamdagen",
"userInterfaceStyle": "automatic",
"splash": {
"image": "./assets/images/splash_new.png",
"resizeMode": "cover",
"backgroundColor": "#00549F"
},
"updates": {
"fallbackToCacheTimeout": 0
},
Expand All @@ -39,6 +34,18 @@
"favicon": "./assets/images/favicon.png"
},
"description": "",
"plugins": ["expo-asset", "expo-font", "expo-router"]
"plugins": [
[
"expo-splash-screen",
{
"backgroundColor": "#00549F",
"image": "./assets/images/logo.png",
"imageWidth": 200
}
],
"expo-asset",
"expo-font",
"expo-router"
]
}
}
9 changes: 5 additions & 4 deletions hooks/useCachedResources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import * as React from 'react';

SplashScreen.preventAutoHideAsync();

const useCachedResources: () => boolean = () => {
const [isLoadingComplete, setLoadingComplete] = React.useState(false);

// Load any resources or data that we need prior to rendering the app
React.useEffect(() => {
loadResourcesAndDataAsync();

async function loadResourcesAndDataAsync() {
try {
SplashScreen.preventAutoHideAsync();
// Load fonts
await Font.loadAsync({
...Ionicons.font,
Expand All @@ -22,9 +21,11 @@ const useCachedResources: () => boolean = () => {
console.warn(e);
} finally {
setLoadingComplete(true);
await SplashScreen.hideAsync();
SplashScreen.hide();
}
}

loadResourcesAndDataAsync();
}, []);

return isLoadingComplete;
Expand Down

0 comments on commit 8cdf31d

Please sign in to comment.