import { RouteProp } from '@react-navigation/native' import { createStackNavigator, StackNavigationProp } from '@react-navigation/stack' import { BlockingModal } from '@Root/Components/BlockingModal' import { HeaderTitleView } from '@Root/Components/HeaderTitleView' import { IoniconsHeaderButton } from '@Root/Components/IoniconsHeaderButton' import { Authenticate } from '@Root/Screens/Authenticate/Authenticate' import { FileInputModal } from '@Root/Screens/InputModal/FileInputModal' import { PasscodeInputModal } from '@Root/Screens/InputModal/PasscodeInputModal' import { TagInputModal } from '@Root/Screens/InputModal/TagInputModal' import { ManageSessions } from '@Root/Screens/ManageSessions/ManageSessions' import { MODAL_BLOCKING_ALERT, SCREEN_AUTHENTICATE, SCREEN_INPUT_MODAL_FILE_NAME, SCREEN_INPUT_MODAL_PASSCODE, SCREEN_INPUT_MODAL_TAG, SCREEN_INPUT_MODAL_WORKSPACE_NAME, SCREEN_MANAGE_SESSIONS, SCREEN_SETTINGS, SCREEN_UPLOADED_FILES_LIST, SCREEN_WEB_APP, } from '@Root/Screens/screens' import { Settings } from '@Root/Screens/Settings/Settings' import { UploadedFilesList } from '@Root/Screens/UploadedFilesList/UploadedFilesList' import { WorkspaceInputModal } from '@Screens/InputModal/WorkspaceInputModal' import { ApplicationDescriptor, Challenge, DeinitMode, DeinitSource, FileItem, SNNote } from '@standardnotes/snjs' import { ICON_CHECKMARK, ICON_CLOSE } from '@Style/Icons' import { ThemeService } from '@Style/ThemeService' import React, { memo, useContext } from 'react' import { Platform } from 'react-native' import { HeaderButtons, Item } from 'react-navigation-header-buttons' import { ThemeContext } from 'styled-components' import { ApplicationContext } from './ApplicationContext' import { AppStackComponent } from './AppStack' import { HistoryStack } from './HistoryStack' import { MobileWebAppContainer } from './MobileWebAppContainer' import { HeaderTitleParams, TEnvironment } from './NativeApp' export type ModalStackNavigatorParamList = { AppStack: undefined HistoryStack: undefined [SCREEN_SETTINGS]: undefined [SCREEN_MANAGE_SESSIONS]: undefined [SCREEN_INPUT_MODAL_TAG]: HeaderTitleParams & { tagUuid?: string noteUuid?: string } [SCREEN_INPUT_MODAL_FILE_NAME]: HeaderTitleParams & { file: FileItem renameFile: (file: FileItem, fileName: string) => Promise } [SCREEN_UPLOADED_FILES_LIST]: HeaderTitleParams & { note: SNNote } [SCREEN_INPUT_MODAL_WORKSPACE_NAME]: HeaderTitleParams & { descriptor: ApplicationDescriptor renameWorkspace: (descriptor: ApplicationDescriptor, workspaceName: string) => Promise } [SCREEN_INPUT_MODAL_PASSCODE]: undefined [SCREEN_AUTHENTICATE]: { challenge: Challenge title?: string } [MODAL_BLOCKING_ALERT]: { title?: string text: string } [SCREEN_WEB_APP]: undefined } export type ModalStackNavigationProp = { navigation: StackNavigationProp route: RouteProp } const MainStack = createStackNavigator() export const MobileWebMainStackComponent = () => { const MemoizedAppStackComponent = memo((props: ModalStackNavigationProp<'AppStack'>) => ( )) return ( ) } export const NativeMainStackComponent = ({ env }: { env: TEnvironment }) => { const application = useContext(ApplicationContext) const theme = useContext(ThemeContext) const MemoizedAppStackComponent = memo((props: ModalStackNavigationProp<'AppStack'>) => ( )) return ( ({ title: 'Settings', headerTitle: ({ children }) => { return }, headerLeft: ({ disabled, onPress }) => ( ), headerRight: () => (env === 'dev' || __DEV__) && ( { await application?.deviceInterface?.removeAllRawStorageValues() await application?.deviceInterface?.removeAllRawDatabasePayloads(application?.identifier) application?.deinit(DeinitMode.Soft, DeinitSource.SignOut) }} /> ), })} component={Settings} /> ({ title: 'Active Sessions', headerTitle: ({ children }) => { return }, headerLeft: ({ disabled, onPress }) => ( ), })} component={ManageSessions} /> { return }, headerLeft: ({ disabled, onPress }) => ( ), }} component={PasscodeInputModal} /> ({ title: 'Tag', gestureEnabled: false, headerTitle: ({ children }) => { return }, headerLeft: ({ disabled, onPress }) => ( ), })} component={TagInputModal} /> ({ title: 'File', gestureEnabled: false, headerTitle: ({ children }) => { return }, headerLeft: ({ disabled, onPress }) => ( ), })} component={FileInputModal} /> ({ title: 'Authenticate', headerLeft: () => undefined, headerTitle: ({ children }) => , })} component={Authenticate} /> ({ title: 'Files', headerLeft: ({ disabled, onPress }) => ( ), headerTitle: ({ children }) => { return }, })} component={UploadedFilesList} /> ({ headerShown: false, cardStyle: { backgroundColor: 'rgba(0, 0, 0, 0.15)' }, cardOverlayEnabled: true, cardStyleInterpolator: ({ current: { progress } }) => ({ cardStyle: { opacity: progress.interpolate({ inputRange: [0, 0.5, 0.9, 1], outputRange: [0, 0.25, 0.7, 1], }), }, overlayStyle: { opacity: progress.interpolate({ inputRange: [0, 1], outputRange: [0, 0.5], extrapolate: 'clamp', }), }, }), })} component={BlockingModal} /> ({ title: 'Workspace', gestureEnabled: false, headerTitle: ({ children }) => { return }, headerLeft: ({ disabled, onPress }) => ( ), })} component={WorkspaceInputModal} /> ({ title: 'App' })} component={MobileWebAppContainer} /> ) }