mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Cleanup splash screen handling
This commit is contained in:
parent
1c7c4d3ab2
commit
3d53693e68
@ -20,7 +20,6 @@
|
||||
|
||||
import { Icon } from "@kyoo/primitives";
|
||||
import { Tabs } from "expo-router";
|
||||
import { useTheme } from "yoshiki/native";
|
||||
import Home from "@material-symbols/svg-400/rounded/home-fill.svg";
|
||||
import Browse from "@material-symbols/svg-400/rounded/browse-fill.svg";
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
*/
|
||||
|
||||
import { ConnectionErrorContext, useAccount } from "@kyoo/models";
|
||||
import { CircularProgress } from "@kyoo/primitives";
|
||||
import { NavbarRight, NavbarTitle } from "@kyoo/ui";
|
||||
import { LoadingIndicator } from "@kyoo/ui/src/player/components/hover";
|
||||
import { Redirect, Stack } from "expo-router";
|
||||
import { useContext, useRef } from "react";
|
||||
import { Redirect, SplashScreen, Stack } from "expo-router";
|
||||
import { useContext, useEffect } from "react";
|
||||
import { useTheme } from "yoshiki/native";
|
||||
|
||||
export default function SignGuard() {
|
||||
@ -30,12 +30,12 @@ export default function SignGuard() {
|
||||
// TODO: support guest accounts on mobile too.
|
||||
const account = useAccount();
|
||||
const { loading, error } = useContext(ConnectionErrorContext);
|
||||
const wasRendered = useRef(false);
|
||||
|
||||
// While loading, keep the splashcreen if possible. if not, display a spinner.
|
||||
if (loading) return wasRendered.current ? <LoadingIndicator /> : null;
|
||||
wasRendered.current = true;
|
||||
useEffect(() => {
|
||||
if (!loading) SplashScreen.hideAsync();
|
||||
}, [loading]);
|
||||
|
||||
if (loading) return <CircularProgress />;
|
||||
if (error) return <Redirect href={"/connection-error"} />;
|
||||
if (!account) return <Redirect href="/login" />;
|
||||
return (
|
||||
|
@ -34,7 +34,7 @@ import {
|
||||
Poppins_400Regular,
|
||||
Poppins_900Black,
|
||||
} from "@expo-google-fonts/poppins";
|
||||
import { ReactNode, useEffect, useState } from "react";
|
||||
import { ReactNode, useState } from "react";
|
||||
import { useColorScheme } from "react-native";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import { ThemeProvider as RNThemeProvider } from "@react-navigation/native";
|
||||
@ -61,8 +61,6 @@ i18next.use(initReactI18next).init({
|
||||
},
|
||||
});
|
||||
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
|
||||
const NavigationThemeProvider = ({ children }: { children: ReactNode }) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
@ -84,15 +82,13 @@ const NavigationThemeProvider = ({ children }: { children: ReactNode }) => {
|
||||
);
|
||||
};
|
||||
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
|
||||
export default function Root() {
|
||||
const [queryClient] = useState(() => createQueryClient());
|
||||
const theme = useColorScheme();
|
||||
const [fontsLoaded] = useFonts({ Poppins_300Light, Poppins_400Regular, Poppins_900Black });
|
||||
|
||||
useEffect(() => {
|
||||
if (fontsLoaded) SplashScreen.hideAsync();
|
||||
}, [fontsLoaded]);
|
||||
|
||||
if (!fontsLoaded) return null;
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user