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';
|
2024-05-27 01:24:42 +02:00
|
|
|
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' };
|
2020-05-28 10:44:15 +02:00
|
|
|
|
2024-05-27 01:24:42 +02:00
|
|
|
const DetailViewStack = createNativeStackNavigator<DetailViewStackParamList>();
|
2020-10-06 12:28:06 +02:00
|
|
|
|
2024-05-12 22:37:30 +02:00
|
|
|
const UnlockRoot = () => {
|
2020-09-08 18:06:41 +02:00
|
|
|
return (
|
2024-05-27 01:24:42 +02:00
|
|
|
<DetailViewStack.Navigator screenOptions={{ headerShown: false, animationTypeForReplace: 'push' }}>
|
|
|
|
<DetailViewStack.Screen name="UnlockWithScreen" component={UnlockWith} />
|
|
|
|
</DetailViewStack.Navigator>
|
2020-09-08 18:06:41 +02:00
|
|
|
);
|
2023-07-25 15:50:04 +02:00
|
|
|
};
|
2024-05-27 01:24:42 +02:00
|
|
|
|
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
|
|
|
|
2024-05-03 01:05:22 +02:00
|
|
|
export default MainRoot;
|
2024-05-27 01:24:42 +02:00
|
|
|
export { DetailViewStack }; // Exporting the navigator to use it in DetailViewScreensStack
|