BlueWallet/navigation/index.tsx

55 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-05-20 11:54:13 +02:00
import { createNativeStackNavigator, NativeStackNavigationOptions } from '@react-navigation/native-stack';
import React, { lazy, Suspense } from 'react';
import { isHandset } from '../blue_modules/environment';
2024-05-13 18:43:57 +02:00
import UnlockWith from '../screen/UnlockWith';
import { LazyLoadingIndicator } from './LazyLoadingIndicator';
import { DetailViewStackParamList } from './DetailViewStackParamList';
2024-05-31 19:18:01 +02:00
import { useStorage } from '../hooks/context/useStorage';
2024-05-12 22:37:30 +02:00
2024-05-13 18:43:57 +02:00
const DetailViewScreensStack = lazy(() => import('./DetailViewScreensStack'));
const DrawerRoot = lazy(() => import('./DrawerRoot'));
2024-05-12 17:35:49 +02:00
export const NavigationDefaultOptions: NativeStackNavigationOptions = {
headerShown: false,
presentation: 'modal',
headerShadowVisible: false,
};
export const NavigationFormModalOptions: NativeStackNavigationOptions = {
headerShown: false,
presentation: 'formSheet',
};
export const StatusBarLightOptions: NativeStackNavigationOptions = { statusBarStyle: 'light' };
const DetailViewStack = createNativeStackNavigator<DetailViewStackParamList>();
2024-05-12 22:37:30 +02:00
const UnlockRoot = () => {
return (
<DetailViewStack.Navigator screenOptions={{ headerShown: false, animationTypeForReplace: 'push' }}>
<DetailViewStack.Screen name="UnlockWithScreen" component={UnlockWith} />
</DetailViewStack.Navigator>
);
};
2024-05-12 22:37:30 +02:00
const MainRoot = () => {
const { walletsInitialized } = useStorage();
const renderRoot = () => {
if (!walletsInitialized) {
return <UnlockRoot />;
} else {
// Conditional rendering based on the environment
const Component = isHandset ? DetailViewScreensStack : DrawerRoot;
return (
<Suspense fallback={<LazyLoadingIndicator />}>
<Component />
</Suspense>
);
}
2024-05-10 03:08:59 +02:00
};
2024-05-05 02:14:46 +02:00
2024-05-12 22:37:30 +02:00
return renderRoot();
2020-12-25 17:09:53 +01:00
};
2020-05-27 13:12:17 +02:00
export default MainRoot;
export { DetailViewStack }; // Exporting the navigator to use it in DetailViewScreensStack