From f60a9f633267225b8e37a8d7330782a2a825f6f0 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 22 Mar 2023 13:48:18 -0300 Subject: [PATCH] Create ShareExtensionStack --- app/AppContainer.tsx | 4 +- app/definitions/navigationTypes.ts | 45 ------------------ app/share.tsx | 58 ++---------------------- app/stacks/ShareExtensionStack/index.tsx | 57 +++++++++++++++++++++++ app/stacks/ShareExtensionStack/types.ts | 29 ++++++++++++ app/stacks/types.ts | 16 ++++++- 6 files changed, 106 insertions(+), 103 deletions(-) create mode 100644 app/stacks/ShareExtensionStack/index.tsx create mode 100644 app/stacks/ShareExtensionStack/types.ts diff --git a/app/AppContainer.tsx b/app/AppContainer.tsx index 08092c2dc..70319c80f 100644 --- a/app/AppContainer.tsx +++ b/app/AppContainer.tsx @@ -3,17 +3,15 @@ import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; import { connect } from 'react-redux'; -import { SetUsernameStackParamList, StackParamList } from './definitions/navigationTypes'; import Navigation from './lib/navigation/appNavigation'; import { defaultHeader, getActiveRouteName, navigationTheme } from './lib/methods/helpers/navigation'; import { RootEnum } from './definitions'; -// Stacks import AuthLoadingView from './views/AuthLoadingView'; -// SetUsername Stack import SetUsernameView from './views/SetUsernameView'; import OutsideStack from './stacks/OutsideStack'; import InsideStack from './stacks/InsideStack'; import MasterDetailStack from './stacks/MasterDetailStack'; +import { SetUsernameStackParamList, StackParamList } from './stacks/types'; import { ThemeContext } from './theme'; import { setCurrentScreen } from './lib/methods/helpers/log'; diff --git a/app/definitions/navigationTypes.ts b/app/definitions/navigationTypes.ts index 960b35b5d..2390d67dc 100644 --- a/app/definitions/navigationTypes.ts +++ b/app/definitions/navigationTypes.ts @@ -1,12 +1,5 @@ -import { NavigatorScreenParams } from '@react-navigation/core'; import { StackNavigationOptions } from '@react-navigation/stack'; -import { TSubscriptionModel } from './ISubscription'; -import { TServerModel } from './IServer'; -import { IAttachment } from './IAttachment'; -import { MasterDetailInsideStackParamList } from '../stacks/MasterDetailStack/types'; -import { OutsideParamList, InsideStackParamList } from '../stacks/types'; - interface INavigationProps { route?: any; navigation?: any; @@ -16,41 +9,3 @@ interface INavigationProps { export type TNavigationOptions = { navigationOptions?(props: INavigationProps): StackNavigationOptions; }; - -export type SetUsernameStackParamList = { - SetUsernameView: { - title: string; - }; -}; - -export type StackParamList = { - AuthLoading: undefined; - OutsideStack: NavigatorScreenParams; - InsideStack: NavigatorScreenParams; - MasterDetailStack: NavigatorScreenParams; - SetUsernameStack: NavigatorScreenParams; -}; - -export type ShareInsideStackParamList = { - ShareListView: undefined; - ShareView: { - attachments: IAttachment[]; - isShareView?: boolean; - isShareExtension: boolean; - serverInfo: TServerModel; - text: string; - room: TSubscriptionModel; - thread?: any; // TODO: Change - }; - SelectServerView: undefined; -}; - -export type ShareOutsideStackParamList = { - WithoutServersView: undefined; -}; - -export type ShareAppStackParamList = { - AuthLoading?: undefined; - OutsideStack?: NavigatorScreenParams; - InsideStack?: NavigatorScreenParams; -}; diff --git a/app/share.tsx b/app/share.tsx index 255becb90..99ba04833 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -1,7 +1,6 @@ -import React, { useContext, useEffect, useLayoutEffect, useState } from 'react'; +import React, { useEffect, useLayoutEffect, useState } from 'react'; import { Dimensions } from 'react-native'; import { NavigationContainer } from '@react-navigation/native'; -import { createStackNavigator } from '@react-navigation/stack'; import { Provider } from 'react-redux'; import { getTheme, setNativeTheme, initialTheme as initialThemeFunction, unsubscribeTheme } from './lib/methods/helpers/theme'; @@ -10,67 +9,18 @@ import Navigation from './lib/navigation/shareNavigation'; import store from './lib/store'; import { initStore } from './lib/store/auxStore'; import { closeShareExtension, shareExtensionInit } from './lib/methods/shareExtension'; -import { defaultHeader, getActiveRouteName, navigationTheme, themedHeader } from './lib/methods/helpers/navigation'; +import { getActiveRouteName, navigationTheme } from './lib/methods/helpers/navigation'; import { ThemeContext } from './theme'; import { localAuthenticate } from './lib/methods/helpers/localAuthentication'; import ScreenLockedView from './views/ScreenLockedView'; -// Outside Stack -import WithoutServersView from './views/WithoutServersView'; -// Inside Stack -import ShareListView from './views/ShareListView'; -import ShareView from './views/ShareView'; -import SelectServerView from './views/SelectServerView'; import { setCurrentScreen } from './lib/methods/helpers/log'; -import AuthLoadingView from './views/AuthLoadingView'; import { DimensionsContext } from './dimensions'; -import { ShareInsideStackParamList, ShareOutsideStackParamList, ShareAppStackParamList } from './definitions/navigationTypes'; import { colors, CURRENT_SERVER } from './lib/constants'; import Loading from './containers/Loading'; +import ShareExtensionStack from './stacks/ShareExtensionStack'; initStore(store); -const Inside = createStackNavigator(); -const InsideStack = () => { - const { theme } = useContext(ThemeContext); - - const screenOptions = { - ...defaultHeader, - ...themedHeader(theme) - }; - screenOptions.headerStyle = { ...screenOptions.headerStyle, height: 57 }; - - return ( - - - - - - ); -}; - -const Outside = createStackNavigator(); -const OutsideStack = () => { - const { theme } = useContext(ThemeContext); - - return ( - - - - ); -}; - -// App -const Stack = createStackNavigator(); -export const App = ({ root }: { root: string }): React.ReactElement => ( - - <> - {!root ? : null} - {root === 'outside' ? : null} - {root === 'inside' ? : null} - - -); - const { width, height, scale, fontScale } = Dimensions.get('screen'); const initialTheme = initialThemeFunction(); const theme = getTheme(initialTheme); @@ -131,7 +81,7 @@ const Root = (): React.ReactElement => { Navigation.routeNameRef.current = currentRouteName; }} > - + diff --git a/app/stacks/ShareExtensionStack/index.tsx b/app/stacks/ShareExtensionStack/index.tsx new file mode 100644 index 000000000..a803ed3c7 --- /dev/null +++ b/app/stacks/ShareExtensionStack/index.tsx @@ -0,0 +1,57 @@ +import React, { useContext } from 'react'; +import { createStackNavigator } from '@react-navigation/stack'; + +import { defaultHeader, themedHeader } from '../../lib/methods/helpers/navigation'; +import { ThemeContext } from '../../theme'; +// Outside Stack +import WithoutServersView from '../../views/WithoutServersView'; +// Inside Stack +import ShareListView from '../../views/ShareListView'; +import ShareView from '../../views/ShareView'; +import SelectServerView from '../../views/SelectServerView'; +import AuthLoadingView from '../../views/AuthLoadingView'; +import { ShareAppStackParamList, ShareInsideStackParamList, ShareOutsideStackParamList } from './types'; + +const Inside = createStackNavigator(); +const InsideStack = () => { + const { theme } = useContext(ThemeContext); + + const screenOptions = { + ...defaultHeader, + ...themedHeader(theme) + }; + screenOptions.headerStyle = { ...screenOptions.headerStyle, height: 57 }; + + return ( + + + + + + ); +}; + +const Outside = createStackNavigator(); +const OutsideStack = () => { + const { theme } = useContext(ThemeContext); + + return ( + + + + ); +}; + +// App +const Stack = createStackNavigator(); +const ShareExtensionStack = ({ root }: { root: string }): React.ReactElement => ( + + <> + {!root ? : null} + {root === 'outside' ? : null} + {root === 'inside' ? : null} + + +); + +export default ShareExtensionStack; diff --git a/app/stacks/ShareExtensionStack/types.ts b/app/stacks/ShareExtensionStack/types.ts new file mode 100644 index 000000000..2dc9e120b --- /dev/null +++ b/app/stacks/ShareExtensionStack/types.ts @@ -0,0 +1,29 @@ +import { NavigatorScreenParams } from '@react-navigation/core'; + +import { TSubscriptionModel } from '../../definitions/ISubscription'; +import { TServerModel } from '../../definitions/IServer'; +import { IAttachment } from '../../definitions/IAttachment'; + +export type ShareInsideStackParamList = { + ShareListView: undefined; + ShareView: { + attachments: IAttachment[]; + isShareView?: boolean; + isShareExtension: boolean; + serverInfo: TServerModel; + text: string; + room: TSubscriptionModel; + thread?: any; // TODO: Change + }; + SelectServerView: undefined; +}; + +export type ShareOutsideStackParamList = { + WithoutServersView: undefined; +}; + +export type ShareAppStackParamList = { + AuthLoading?: undefined; + OutsideStack?: NavigatorScreenParams; + InsideStack?: NavigatorScreenParams; +}; diff --git a/app/stacks/types.ts b/app/stacks/types.ts index d7848058d..ab62720e6 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -9,11 +9,25 @@ import { IMessage, TAnyMessageModel, TMessageModel } from '../definitions/IMessa import { ISubscription, SubscriptionType, TSubscriptionModel } from '../definitions/ISubscription'; import { ICannedResponse } from '../definitions/ICannedResponse'; import { TDataSelect } from '../definitions/IDataSelect'; -import { ModalStackParamList } from './MasterDetailStack/types'; +import { MasterDetailInsideStackParamList, ModalStackParamList } from './MasterDetailStack/types'; import { TThreadModel } from '../definitions'; import { ILivechatDepartment } from '../definitions/ILivechatDepartment'; import { ILivechatTag } from '../definitions/ILivechatTag'; +export type SetUsernameStackParamList = { + SetUsernameView: { + title: string; + }; +}; + +export type StackParamList = { + AuthLoading: undefined; + OutsideStack: NavigatorScreenParams; + InsideStack: NavigatorScreenParams; + MasterDetailStack: NavigatorScreenParams; + SetUsernameStack: NavigatorScreenParams; +}; + export type ChatsStackParamList = { ModalStackNavigator: NavigatorScreenParams; E2ESaveYourPasswordStackNavigator: NavigatorScreenParams;