BlueWallet/navigation/DrawerRoot.tsx

46 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-05-12 22:37:30 +02:00
// DrawerRoot.tsx
import { createDrawerNavigator, DrawerNavigationOptions } from '@react-navigation/drawer';
import React, { useLayoutEffect, useMemo } from 'react';
import { I18nManager, LayoutAnimation } from 'react-native';
2024-05-20 11:54:13 +02:00
2024-05-12 22:37:30 +02:00
import { useIsLargeScreen } from '../hooks/useIsLargeScreen';
import DrawerList from '../screen/wallets/DrawerList';
2024-05-20 11:54:13 +02:00
import DetailViewStackScreensStack from './DetailViewScreensStack';
import { useSettings } from '../hooks/context/useSettings';
2024-05-12 22:37:30 +02:00
const Drawer = createDrawerNavigator();
const DrawerListContent = (props: any) => {
return <DrawerList {...props} />;
};
const DrawerRoot = () => {
2024-08-25 16:47:44 +02:00
const { isLargeScreen } = useIsLargeScreen();
const { isDrawerShouldHide } = useSettings();
2024-05-12 22:37:30 +02:00
const drawerStyle: DrawerNavigationOptions = useMemo(
() => ({
drawerPosition: I18nManager.isRTL ? 'right' : 'left',
drawerStyle: { width: isLargeScreen && !isDrawerShouldHide ? 320 : '0%' },
2024-05-12 22:37:30 +02:00
drawerType: isLargeScreen ? 'permanent' : 'back',
}),
[isDrawerShouldHide, isLargeScreen],
2024-05-12 22:37:30 +02:00
);
useLayoutEffect(() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
}, [isDrawerShouldHide]);
2024-05-12 22:37:30 +02:00
return (
<Drawer.Navigator screenOptions={drawerStyle} drawerContent={DrawerListContent}>
<Drawer.Screen
name="DetailViewStackScreensStack"
component={DetailViewStackScreensStack}
options={{ headerShown: false, gestureHandlerProps: { enableTrackpadTwoFingerGesture: false } }}
/>
</Drawer.Navigator>
);
};
export default DrawerRoot;