diff --git a/package.json b/package.json index b2f5695..5f6dc00 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "expo-dev-client": "~4.0.27", "expo-font": "^12.0.10", "expo-status-bar": "~1.12.1", - "expo-updates": "~0.25.25", + "expo-updates": "^0.25.27", "html-entities": "^2.5.2", "react": "18.2.0", "react-native": "0.74.5", diff --git a/src/App.js b/src/App.js index 7339db6..cf47e0a 100644 --- a/src/App.js +++ b/src/App.js @@ -12,12 +12,30 @@ import DashboardScreen from "./screens/DashboardScreen/DashboardScreen"; import AlbumViewerScreen from "./screens/AlbumViewerScreen/AlbumViewerScreen"; import Constants from "./constants/constants"; import FloatingPlayerScreen from "./screens/FloatingPlayerScreen/FloatingPlayerScreen"; +import autoUpdateFetch from "./utils/autoUpdateFetch"; +import loadFonts from "./utils/fontLoader"; const Stack = createStackNavigator(); const constants = new Constants(); export default function App() { const [playerInitialized, setPlayerInitialized] = useState(false); + const [fontsLoaded, setFontsLoaded] = useState(false); + + useEffect(() => { + const loadAppFonts = async () => { + await loadFonts(); + setFontsLoaded(true); + }; + + loadAppFonts(); + }, []); + + useEffect(() => { + if (!__DEV__) { + autoUpdateFetch(); + } + }, []); useEffect(() => { const initializePlayer = async () => { @@ -28,13 +46,14 @@ export default function App() { return async () => await TrackPlayer.destroy(); } } catch (error) { + // setPlayerInitialized(true); console.error("Error setting up player", error); } }; initializePlayer(); }, [playerInitialized]); - return ( + return fontsLoaded && ( diff --git a/src/utils/autoUpdateFetch.js b/src/utils/autoUpdateFetch.js new file mode 100644 index 0000000..ad3c7fc --- /dev/null +++ b/src/utils/autoUpdateFetch.js @@ -0,0 +1,19 @@ +import * as Updates from "expo-updates"; +import { ToastAndroid } from "react-native"; + +const autoUpdateFetch = async () => { + try { + const update = await Updates.checkForUpdateAsync(); + if (update.isAvailable) { + await Updates.fetchUpdateAsync(); + await Updates.reloadAsync(); + } + } catch (error) { + ToastAndroid.show( + `Error fetching latest Expo update: ${error}`, + ToastAndroid.SHORT, + ); + } +}; + +export default autoUpdateFetch; diff --git a/src/utils/fontLoader.js b/src/utils/fontLoader.js new file mode 100644 index 0000000..e1fbb62 --- /dev/null +++ b/src/utils/fontLoader.js @@ -0,0 +1,12 @@ +import * as Font from 'expo-font'; + +const loadFonts = async () => { + await Font.loadAsync({ + 'Poppins-Regular': require('../../assets/fonts/Poppins/Poppins-Regular.ttf'), + 'Poppins-Bold': require('../../assets/fonts/Poppins/Poppins-Bold.ttf'), + 'Poppins-Thin': require("../../assets/fonts/Poppins/Poppins-Thin.ttf") + }); +}; + + +export default loadFonts \ No newline at end of file