import { BlockingModal } from '@Components/BlockingModal'; import { HeaderTitleView } from '@Components/HeaderTitleView'; import { IoniconsHeaderButton } from '@Components/IoniconsHeaderButton'; import { RouteProp } from '@react-navigation/native'; import { createStackNavigator, StackNavigationProp, } from '@react-navigation/stack'; import { Authenticate } from '@Screens/Authenticate/Authenticate'; import { AuthenticatePrivileges } from '@Screens/Authenticate/AuthenticatePrivileges'; import { PasscodeInputModal } from '@Screens/InputModal/PasscodeInputModal'; import { TagInputModal } from '@Screens/InputModal/TagInputModal'; import { MODAL_BLOCKING_ALERT, SCREEN_AUTHENTICATE, SCREEN_AUTHENTICATE_PRIVILEGES, SCREEN_INPUT_MODAL_PASSCODE, SCREEN_INPUT_MODAL_TAG, SCREEN_MANAGE_PRIVILEGES, SCREEN_SETTINGS, } from '@Screens/screens'; import { ManagePrivileges } from '@Screens/Settings/ManagePrivileges'; import { Settings } from '@Screens/Settings/Settings'; import { ICON_CHECKMARK, ICON_CLOSE } from '@Style/icons'; import { ThemeService } from '@Style/theme_service'; import React, { useContext } from 'react'; import { Platform } from 'react-native'; import { HeaderButtons, Item } from 'react-navigation-header-buttons'; import { Challenge, DeinitSource, PrivilegeCredential, ProtectedAction, } from 'snjs'; import { ThemeContext } from 'styled-components'; import { HeaderTitleParams } from './App'; import { ApplicationContext } from './ApplicationContext'; import { AppStackComponent } from './AppStack'; import { HistoryStack } from './HistoryStack'; type ModalStackNavigatorParamList = { AppStack: undefined; HistoryStack: undefined; [SCREEN_SETTINGS]: undefined; [SCREEN_MANAGE_PRIVILEGES]: undefined; [SCREEN_INPUT_MODAL_TAG]: HeaderTitleParams & { tagUuid?: string; noteUuid?: string; }; [SCREEN_INPUT_MODAL_PASSCODE]: undefined; [SCREEN_AUTHENTICATE]: { challenge: Challenge; title?: string; }; [SCREEN_AUTHENTICATE_PRIVILEGES]: { action: ProtectedAction; privilegeCredentials: PrivilegeCredential[]; previousScreen: string; unlockedItemId?: string; }; [MODAL_BLOCKING_ALERT]: { title?: string; text: string; }; }; export type ModalStackNavigationProp< T extends keyof ModalStackNavigatorParamList > = { navigation: StackNavigationProp; route: RouteProp; }; const MainStack = createStackNavigator(); export const MainStackComponent = ({ env }: { env: 'prod' | 'dev' }) => { const application = useContext(ApplicationContext); const theme = useContext(ThemeContext); 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(DeinitSource.SignOut); }} /> ), })} component={Settings} /> ({ title: 'Privileges', headerTitle: ({ children }) => { return ; }, headerLeft: ({ disabled, onPress }) => ( ), })} component={ManagePrivileges} /> { return ; }, headerLeft: ({ disabled, onPress }) => ( ), }} component={PasscodeInputModal} /> ({ title: 'Tag', gestureEnabled: false, headerTitle: ({ children }) => { return ( ); }, headerLeft: ({ disabled, onPress }) => ( ), })} component={TagInputModal} /> ({ title: 'Authenticate', headerLeft: () => undefined, headerTitle: ({ children }) => ( ), })} component={Authenticate} /> ({ title: 'Authenticate', headerLeft: ({ disabled, onPress }) => ( ), headerTitle: ({ children }) => { return ; }, })} component={AuthenticatePrivileges} /> ({ 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} /> ); };