@@ -2,6 +2,7 @@ import React, {memo, useEffect, useMemo, useRef} from 'react';
2
2
import { View } from 'react-native' ;
3
3
import type { OnyxEntry } from 'react-native-onyx' ;
4
4
import Onyx , { withOnyx } from 'react-native-onyx' ;
5
+ import type { ValueOf } from 'type-fest' ;
5
6
import OptionsListContextProvider from '@components/OptionListContextProvider' ;
6
7
import useOnboardingLayout from '@hooks/useOnboardingLayout' ;
7
8
import useStyleUtils from '@hooks/useStyleUtils' ;
@@ -14,7 +15,7 @@ import Log from '@libs/Log';
14
15
import getCurrentUrl from '@libs/Navigation/currentUrl' ;
15
16
import getOnboardingModalScreenOptions from '@libs/Navigation/getOnboardingModalScreenOptions' ;
16
17
import Navigation from '@libs/Navigation/Navigation' ;
17
- import type { AuthScreensParamList } from '@libs/Navigation/types' ;
18
+ import type { AuthScreensParamList , CentralPaneName , CentralPaneScreensParamList } from '@libs/Navigation/types' ;
18
19
import NetworkConnection from '@libs/NetworkConnection' ;
19
20
import * as Pusher from '@libs/Pusher/pusher' ;
20
21
import PusherConnectionManager from '@libs/PusherConnectionManager' ;
@@ -42,11 +43,11 @@ import SCREENS from '@src/SCREENS';
42
43
import type * as OnyxTypes from '@src/types/onyx' ;
43
44
import type { SelectedTimezone , Timezone } from '@src/types/onyx/PersonalDetails' ;
44
45
import type ReactComponentModule from '@src/types/utils/ReactComponentModule' ;
46
+ import CENTRAL_PANE_SCREENS from './CENTRAL_PANE_SCREENS' ;
45
47
import createCustomStackNavigator from './createCustomStackNavigator' ;
46
48
import defaultScreenOptions from './defaultScreenOptions' ;
47
49
import getRootNavigatorScreenOptions from './getRootNavigatorScreenOptions' ;
48
50
import BottomTabNavigator from './Navigators/BottomTabNavigator' ;
49
- import CentralPaneNavigator from './Navigators/CentralPaneNavigator' ;
50
51
import FeatureTrainingModalNavigator from './Navigators/FeatureTrainingModalNavigator' ;
51
52
import FullScreenNavigator from './Navigators/FullScreenNavigator' ;
52
53
import LeftModalNavigator from './Navigators/LeftModalNavigator' ;
@@ -75,6 +76,21 @@ const loadReportAvatar = () => require<ReactComponentModule>('../../../pages/Rep
75
76
const loadReceiptView = ( ) => require < ReactComponentModule > ( '../../../pages/TransactionReceiptPage' ) . default ;
76
77
const loadWorkspaceJoinUser = ( ) => require < ReactComponentModule > ( '@pages/workspace/WorkspaceJoinUserPage' ) . default ;
77
78
79
+ function getCentralPaneScreenInitialParams ( screenName : CentralPaneName ) : Partial < ValueOf < CentralPaneScreensParamList > > {
80
+ const url = getCurrentUrl ( ) ;
81
+ const openOnAdminRoom = url ? new URL ( url ) . searchParams . get ( 'openOnAdminRoom' ) : undefined ;
82
+
83
+ if ( screenName === SCREENS . SEARCH . CENTRAL_PANE ) {
84
+ return { sortBy : CONST . SEARCH . TABLE_COLUMNS . DATE , sortOrder : CONST . SEARCH . SORT_ORDER . DESC } ;
85
+ }
86
+
87
+ if ( screenName === SCREENS . REPORT && openOnAdminRoom === 'true' ) {
88
+ return { openOnAdminRoom : true } ;
89
+ }
90
+
91
+ return undefined ;
92
+ }
93
+
78
94
let timezone : Timezone | null ;
79
95
let currentAccountID = - 1 ;
80
96
let isLoadingApp = false ;
@@ -298,20 +314,26 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
298
314
// eslint-disable-next-line react-hooks/exhaustive-deps
299
315
} , [ ] ) ;
300
316
317
+ const CentralPaneScreenOptions = {
318
+ headerShown : false ,
319
+ title : 'New Expensify' ,
320
+
321
+ // Prevent unnecessary scrolling
322
+ cardStyle : styles . cardStyleNavigator ,
323
+ } ;
324
+
301
325
return (
302
326
< OptionsListContextProvider >
303
327
< View style = { styles . rootNavigatorContainerStyles ( isSmallScreenWidth ) } >
304
- < RootStack . Navigator isSmallScreenWidth = { isSmallScreenWidth } >
328
+ < RootStack . Navigator
329
+ screenOptions = { screenOptions . centralPaneNavigator }
330
+ isSmallScreenWidth = { isSmallScreenWidth }
331
+ >
305
332
< RootStack . Screen
306
333
name = { NAVIGATORS . BOTTOM_TAB_NAVIGATOR }
307
334
options = { screenOptions . bottomTab }
308
335
component = { BottomTabNavigator }
309
336
/>
310
- < RootStack . Screen
311
- name = { NAVIGATORS . CENTRAL_PANE_NAVIGATOR }
312
- options = { screenOptions . centralPaneNavigator }
313
- component = { CentralPaneNavigator }
314
- />
315
337
< RootStack . Screen
316
338
name = { SCREENS . VALIDATE_LOGIN }
317
339
options = { {
@@ -433,6 +455,18 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
433
455
options = { defaultScreenOptions }
434
456
component = { ConnectionCompletePage }
435
457
/>
458
+ { Object . entries ( CENTRAL_PANE_SCREENS ) . map ( ( [ screenName , componentGetter ] ) => {
459
+ const centralPaneName = screenName as CentralPaneName ;
460
+ return (
461
+ < RootStack . Screen
462
+ key = { centralPaneName }
463
+ name = { centralPaneName }
464
+ initialParams = { getCentralPaneScreenInitialParams ( centralPaneName ) }
465
+ getComponent = { componentGetter }
466
+ options = { CentralPaneScreenOptions }
467
+ />
468
+ ) ;
469
+ } ) }
436
470
</ RootStack . Navigator >
437
471
</ View >
438
472
</ OptionsListContextProvider >
0 commit comments