2024-05-20 10:54:13 +01:00
|
|
|
import { createNativeStackNavigator, NativeStackNavigationOptions } from '@react-navigation/native-stack';
|
|
|
|
import React, { lazy, Suspense } from 'react';
|
|
|
|
import { isHandset } from '../blue_modules/environment';
|
2024-05-13 12:43:57 -04:00
|
|
|
import UnlockWith from '../screen/UnlockWith';
|
|
|
|
import { LazyLoadingIndicator } from './LazyLoadingIndicator';
|
2024-05-26 19:24:42 -04:00
|
|
|
import { DetailViewStackParamList } from './DetailViewStackParamList';
|
2024-05-31 13:18:01 -04:00
|
|
|
import { useStorage } from '../hooks/context/useStorage';
|
2024-05-12 16:37:30 -04:00
|
|
|
|
2024-05-13 12:43:57 -04:00
|
|
|
const DetailViewScreensStack = lazy(() => import('./DetailViewScreensStack'));
|
|
|
|
const DrawerRoot = lazy(() => import('./DrawerRoot'));
|
2024-05-12 11:35:49 -04: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 11:44:15 +03:00
|
|
|
|
2024-05-26 19:24:42 -04:00
|
|
|
const DetailViewStack = createNativeStackNavigator<DetailViewStackParamList>();
|
2020-10-06 06:28:06 -04:00
|
|
|
|
2024-05-12 16:37:30 -04:00
|
|
|
const UnlockRoot = () => {
|
2020-09-08 12:06:41 -04:00
|
|
|
return (
|
2024-05-26 19:24:42 -04:00
|
|
|
<DetailViewStack.Navigator screenOptions={{ headerShown: false, animationTypeForReplace: 'push' }}>
|
|
|
|
<DetailViewStack.Screen name="UnlockWithScreen" component={UnlockWith} />
|
|
|
|
</DetailViewStack.Navigator>
|
2020-09-08 12:06:41 -04:00
|
|
|
);
|
2023-07-25 14:50:04 +01:00
|
|
|
};
|
2024-05-26 19:24:42 -04:00
|
|
|
|
2024-05-12 16:37:30 -04: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-09 21:08:59 -04:00
|
|
|
};
|
2024-05-04 20:14:46 -04:00
|
|
|
|
2024-05-12 16:37:30 -04:00
|
|
|
return renderRoot();
|
2020-12-25 19:09:53 +03:00
|
|
|
};
|
2020-05-27 14:12:17 +03:00
|
|
|
|
2024-05-02 19:05:22 -04:00
|
|
|
export default MainRoot;
|
2024-05-26 19:24:42 -04:00
|
|
|
export { DetailViewStack }; // Exporting the navigator to use it in DetailViewScreensStack
|