Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Link, Redirect, SplashScreen, Tabs } from 'expo-router';
import { Link, Redirect, Tabs } from 'expo-router';
import * as React from 'react';
import { useCallback, useEffect } from 'react';

import { Pressable, Text } from '@/components/ui';
import {
Expand All @@ -14,17 +13,6 @@ import { useIsFirstTime } from '@/lib/hooks/use-is-first-time';
export default function TabLayout() {
const status = useAuth.use.status();
const [isFirstTime] = useIsFirstTime();
const hideSplash = useCallback(async () => {
await SplashScreen.hideAsync();
}, []);
useEffect(() => {
if (status !== 'idle') {
const timer = setTimeout(() => {
hideSplash();
}, 1000);
return () => clearTimeout(timer);
}
}, [hideSplash, status]);

if (isFirstTime) {
return <Redirect href="/onboarding" />;
Expand Down
23 changes: 21 additions & 2 deletions src/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ViewProps } from 'react-native';
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';

import { ThemeProvider } from '@react-navigation/native';
Expand Down Expand Up @@ -34,8 +35,19 @@ SplashScreen.setOptions({
});

export default function RootLayout() {
const hasHiddenSplash = React.useRef(false);

const onLayoutRootView = React.useCallback(() => {
if (hasHiddenSplash.current) {
return;
}

hasHiddenSplash.current = true;
SplashScreen.hide();
}, []);

return (
<Providers>
<Providers onLayout={onLayoutRootView}>
<Stack>
<Stack.Screen name="(app)" options={{ headerShown: false }} />
<Stack.Screen name="onboarding" options={{ headerShown: false }} />
Expand All @@ -45,10 +57,17 @@ export default function RootLayout() {
);
}

function Providers({ children }: { children: React.ReactNode }) {
function Providers({
children,
onLayout,
}: {
children: React.ReactNode;
onLayout: ViewProps['onLayout'];
}) {
const theme = useThemeConfig();
return (
<GestureHandlerRootView
onLayout={onLayout}
style={styles.container}
// eslint-disable-next-line better-tailwindcss/no-unknown-classes
className={theme.dark ? `dark` : undefined}
Expand Down
Loading