Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poc/split adjust to native stack #149

Merged
merged 5 commits into from
Dec 10, 2024
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
45 changes: 26 additions & 19 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {findFocusedRoute} from '@react-navigation/native';
import type {RouteProp} from '@react-navigation/native';
import React, {memo, useEffect, useRef, useState} from 'react';
import {NativeModules, View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
Expand All @@ -12,9 +13,7 @@ import {useSearchRouterContext} from '@components/Search/SearchRouter/SearchRout
import SearchRouterModal from '@components/Search/SearchRouter/SearchRouterModal';
import TestToolsModal from '@components/TestToolsModal';
import * as TooltipManager from '@components/Tooltip/EducationalTooltip/TooltipManager';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useOnboardingFlowRouter from '@hooks/useOnboardingFlow';
import usePermissions from '@hooks/usePermissions';
import {ReportIDsContextProvider} from '@hooks/useReportIDs';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
Expand All @@ -25,16 +24,16 @@ import KeyboardShortcut from '@libs/KeyboardShortcut';
import Log from '@libs/Log';
import NavBarManager from '@libs/NavBarManager';
import getCurrentUrl from '@libs/Navigation/currentUrl';
import SIDEBAR_TO_SPLIT from '@libs/Navigation/linkingConfig/RELATIONS/SIDEBAR_TO_SPLIT';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation';
import Presentation from '@libs/Navigation/PlatformStackNavigation/navigationOptions/presentation';
import shouldOpenOnAdminRoom from '@libs/Navigation/shouldOpenOnAdminRoom';
import type {AuthScreensParamList} from '@libs/Navigation/types';
import {isOnboardingFlowName} from '@libs/NavigationUtils';
import NetworkConnection from '@libs/NetworkConnection';
import onyxSubscribe from '@libs/onyxSubscribe';
import * as Pusher from '@libs/Pusher/pusher';
import PusherConnectionManager from '@libs/PusherConnectionManager';
import * as ReportUtils from '@libs/ReportUtils';
import * as SearchQueryUtils from '@libs/SearchQueryUtils';
import * as SessionUtils from '@libs/SessionUtils';
import ConnectionCompletePage from '@pages/ConnectionCompletePage';
Expand Down Expand Up @@ -211,23 +210,11 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
const styles = useThemeStyles();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const rootNavigatorOptions = useRootNavigatorOptions();
const {canUseDefaultRooms} = usePermissions();
const {activeWorkspaceID} = useActiveWorkspace();
const {toggleSearchRouter} = useSearchRouterContext();

const modal = useRef<OnyxTypes.Modal>({});
const [didPusherInit, setDidPusherInit] = useState(false);
const {isOnboardingCompleted} = useOnboardingFlowRouter();
const [initialReportID] = useState(() => {
const currentURL = getCurrentUrl();
const reportIdFromPath = currentURL && new URL(currentURL).pathname.match(CONST.REGEX.REPORT_ID_FROM_PATH)?.at(1);
if (reportIdFromPath) {
return reportIdFromPath;
}

const initialReport = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID);
return initialReport?.reportID ?? '';
});

useEffect(() => {
NavBarManager.setButtonStyle(theme.navigationBarButtonsStyle);
Expand Down Expand Up @@ -381,19 +368,39 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

// Animation is disabled when navigating to the sidebar screen
const getSplitNavigatorOptions = (route: RouteProp<AuthScreensParamList>) => {
if (!shouldUseNarrowLayout || !route?.params) {
return rootNavigatorOptions.fullScreen;
}

const screenName = 'screen' in route.params ? route.params.screen : undefined;

if (!screenName) {
return rootNavigatorOptions.fullScreen;
}

const animationEnabled = !Object.keys(SIDEBAR_TO_SPLIT).includes(screenName);

return {
...rootNavigatorOptions.fullScreen,
animation: animationEnabled ? Animations.SLIDE_FROM_RIGHT : Animations.NONE,
};
};
Comment on lines 370 to +389

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably extract this one

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll handle it in other PR where I put all nav functions into NavigationUtils


return (
<ComposeProviders components={[OptionsListContextProvider, ActiveWorkspaceContextProvider, ReportIDsContextProvider, SearchContextProvider]}>
<View style={styles.rootNavigatorContainerStyles(shouldUseNarrowLayout)}>
<RootStack.Navigator screenOptions={rootNavigatorOptions.centralPaneNavigator}>
{/* This have to be the first navigator in auth screens. */}
<RootStack.Screen
name={NAVIGATORS.REPORTS_SPLIT_NAVIGATOR}
options={rootNavigatorOptions.fullScreen}
options={({route}) => getSplitNavigatorOptions(route)}
getComponent={loadReportSplitNavigator}
/>
<RootStack.Screen
name={NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR}
options={rootNavigatorOptions.fullScreen}
options={({route}) => getSplitNavigatorOptions(route)}
getComponent={loadSettingsSplitNavigator}
/>
<RootStack.Screen
Expand All @@ -404,7 +411,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
/>
<RootStack.Screen
name={NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR}
options={rootNavigatorOptions.fullScreen}
options={({route}) => getSplitNavigatorOptions(route)}
getComponent={loadWorkspaceSplitNavigator}
/>
<RootStack.Screen
Expand Down
33 changes: 0 additions & 33 deletions src/libs/Navigation/AppNavigator/Navigators/BottomTabNavigator.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {useRoute} from '@react-navigation/native';
import React from 'react';
import FocusTrapForScreens from '@components/FocusTrap/FocusTrapForScreen';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import createSplitStackNavigator from '@libs/Navigation/AppNavigator/createSplitStackNavigator';
import useRootNavigatorOptions from '@libs/Navigation/AppNavigator/useRootNavigatorOptions';
import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation';
import type {PlatformStackNavigationOptions} from '@libs/Navigation/PlatformStackNavigation/types';
import type {SettingsSplitNavigatorParamList} from '@libs/Navigation/types';
import SCREENS from '@src/SCREENS';
import type ReactComponentModule from '@src/types/utils/ReactComponentModule';
Expand All @@ -29,7 +28,6 @@ const CENTRAL_PANE_SETTINGS_SCREENS = {
const Stack = createSplitStackNavigator<SettingsSplitNavigatorParamList>();

function SettingsSplitNavigator() {
const screenOptions = useRootNavigatorOptions();
const route = useRoute();
const rootNavigatorOptions = useRootNavigatorOptions();

Expand All @@ -47,10 +45,10 @@ function SettingsSplitNavigator() {
options={rootNavigatorOptions.homeScreen}
/>
{Object.entries(CENTRAL_PANE_SETTINGS_SCREENS).map(([screenName, componentGetter]) => {
const options = {...screenOptions.fullScreen};
const options: PlatformStackNavigationOptions = {animation: undefined};

if (screenName === SCREENS.SETTINGS.WORKSPACES) {
options.animation = 'none';
options.animation = Animations.NONE;
}

return (
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading