vn-verdnaturachat/app/stacks/InsideStack.js

336 lines
10 KiB
JavaScript
Raw Normal View History

[CHORE] Update react-navigation to v5 (#2154) * react-navigation v5 installed * compiling * Outside working * InsideStack compiling * Switch stack * Starting room * RoomView header * SafeAreaView * Slide from right stack animation * stash * Fix params * Create channel * inapp notification * Custom status * Add server working * Refactor appStart * Attachment * in-app notification * AuthLoadingView * Remove compat * Navigation * Outside animations * Fix new server icon * block modal * AttachmentView header * Remove unnecessary code * SelectedUsersView header * StatusView * CreateDiscussionView * RoomInfoView * RoomInfoEditView style * RoomMembersView * RoomsListView header * RoomView header * Share extension * getParam * Focus/blur * Trying to fix inapp * Lint * Simpler app container * Update libs * Revert "Simpler app container" This reverts commit 1e49d80bb49481c34f415831b9da5e9d53e66057. * Load messages faster * Fix safearea on ReactionsModal * Update safe area to v3 * lint * Fix transition * stash - drawer replace working * stash - modal nav * RoomActionsView as tablet modal * RoomStack * Stop showing RoomView header when there's no room * Custom Header and different navigation based on stack * Refactor setHeader * MasterDetailContext * RoomView header * Fix isMasterDetail rule * KeyCommands kind of working * Create channel on tablet * RoomView sCU * Remove withSplit * Settings opening as modal * Settings * StatusView headerLeft * Admin panel * TwoFactor style * DirectoryView * ServerDropdown and SortDropdown animations * ThreadMessagesView * Navigate to empty RoomView on server switch when in master detail * ProfileView header * Fix navigation issues * Nav to any room info on tablet * Room info * Refactoring * Fix rooms search * Roomslist commands * SearchMessagesView close modal * Key commands * Fix undefined subscription * Disallow navigate to focused room * isFocused state on RoomsListView * Blur text inputs when focus is lost * Replace animation * Default nav theme * Refactoring * Always open Attachment with close modal button * ModalContainer backdrop following themes * Screen tracking * Refactor get active route for in-app notification * Only mark room as focused when in master detail layout * Lint * Open modals as fade from bottom on Android * typo * Fixing tests * Fix in-app update * Fixing goRoom issues * Refactor stack names * Fix unreadsCount * Fix stack * Fix header animation * Refactor ShareNavigation * Refactor navigation theme * Make sure title is set * Fix create discussion navigation * Remove unused variable * Create discussions from actions fixed * Layout animation * Screen lock on share extension * Unnecessary change * Admin border * Set header after state callback * Fix key commands on outside stack * Fix back button pressed * Remove layout animations from Android * Tweak animations on Android * Disable swipe gesture to open drawer * Fix current item on RoomsListView * Fix add server * Fix drawer * Fix broadcast * LayoutAnimation instead of Transitions * Fix onboarding back press * Fix assorted tests * Create discussion fix * RoomInfoView header * Drawer active item
2020-06-15 14:00:46 +00:00
import React from 'react';
import PropTypes from 'prop-types';
import { createStackNavigator } from '@react-navigation/stack';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { ThemeContext } from '../theme';
import {
defaultHeader, themedHeader, ModalAnimation, StackAnimation
} from '../utils/navigation';
import Toast from '../containers/Toast';
import Sidebar from '../views/SidebarView';
import NotificationBadge from '../notifications/inApp';
// Chats Stack
import RoomView from '../views/RoomView';
import RoomsListView from '../views/RoomsListView';
import RoomActionsView from '../views/RoomActionsView';
import RoomInfoView from '../views/RoomInfoView';
import RoomInfoEditView from '../views/RoomInfoEditView';
import RoomMembersView from '../views/RoomMembersView';
import SearchMessagesView from '../views/SearchMessagesView';
import SelectedUsersView from '../views/SelectedUsersView';
import InviteUsersView from '../views/InviteUsersView';
import InviteUsersEditView from '../views/InviteUsersEditView';
import MessagesView from '../views/MessagesView';
import AutoTranslateView from '../views/AutoTranslateView';
import DirectoryView from '../views/DirectoryView';
import NotificationPrefView from '../views/NotificationPreferencesView';
import VisitorNavigationView from '../views/VisitorNavigationView';
import ForwardLivechatView from '../views/ForwardLivechatView';
import LivechatEditView from '../views/LivechatEditView';
import PickerView from '../views/PickerView';
import ThreadMessagesView from '../views/ThreadMessagesView';
import MarkdownTableView from '../views/MarkdownTableView';
import ReadReceiptsView from '../views/ReadReceiptView';
// Profile Stack
import ProfileView from '../views/ProfileView';
// Settings Stack
import SettingsView from '../views/SettingsView';
import LanguageView from '../views/LanguageView';
import ThemeView from '../views/ThemeView';
import DefaultBrowserView from '../views/DefaultBrowserView';
import ScreenLockConfigView from '../views/ScreenLockConfigView';
// Admin Stack
import AdminPanelView from '../views/AdminPanelView';
// NewMessage Stack
import NewMessageView from '../views/NewMessageView';
import CreateChannelView from '../views/CreateChannelView';
// InsideStackNavigator
import AttachmentView from '../views/AttachmentView';
import ModalBlockView from '../views/ModalBlockView';
import JitsiMeetView from '../views/JitsiMeetView';
import StatusView from '../views/StatusView';
import CreateDiscussionView from '../views/CreateDiscussionView';
// ChatsStackNavigator
const ChatsStack = createStackNavigator();
const ChatsStackNavigator = () => {
const { theme } = React.useContext(ThemeContext);
return (
<ChatsStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>
<ChatsStack.Screen
name='RoomsListView'
component={RoomsListView}
/>
<ChatsStack.Screen
name='RoomView'
component={RoomView}
/>
<ChatsStack.Screen
name='RoomActionsView'
component={RoomActionsView}
options={RoomActionsView.navigationOptions}
/>
<ChatsStack.Screen
name='RoomInfoView'
component={RoomInfoView}
options={RoomInfoView.navigationOptions}
/>
<ChatsStack.Screen
name='RoomInfoEditView'
component={RoomInfoEditView}
options={RoomInfoEditView.navigationOptions}
/>
<ChatsStack.Screen
name='RoomMembersView'
component={RoomMembersView}
options={RoomMembersView.navigationOptions}
/>
<ChatsStack.Screen
name='SearchMessagesView'
component={SearchMessagesView}
options={SearchMessagesView.navigationOptions}
/>
<ChatsStack.Screen
name='SelectedUsersView'
component={SelectedUsersView}
/>
<ChatsStack.Screen
name='InviteUsersView'
component={InviteUsersView}
options={InviteUsersView.navigationOptions}
/>
<ChatsStack.Screen
name='InviteUsersEditView'
component={InviteUsersEditView}
options={InviteUsersEditView.navigationOptions}
/>
<ChatsStack.Screen
name='MessagesView'
component={MessagesView}
options={MessagesView.navigationOptions}
/>
<ChatsStack.Screen
name='AutoTranslateView'
component={AutoTranslateView}
options={AutoTranslateView.navigationOptions}
/>
<ChatsStack.Screen
name='DirectoryView'
component={DirectoryView}
options={DirectoryView.navigationOptions}
/>
<ChatsStack.Screen
name='NotificationPrefView'
component={NotificationPrefView}
options={NotificationPrefView.navigationOptions}
/>
<ChatsStack.Screen
name='VisitorNavigationView'
component={VisitorNavigationView}
options={VisitorNavigationView.navigationOptions}
/>
<ChatsStack.Screen
name='ForwardLivechatView'
component={ForwardLivechatView}
options={ForwardLivechatView.navigationOptions}
/>
<ChatsStack.Screen
name='LivechatEditView'
component={LivechatEditView}
options={LivechatEditView.navigationOptions}
/>
<ChatsStack.Screen
name='PickerView'
component={PickerView}
options={PickerView.navigationOptions}
/>
<ChatsStack.Screen
name='ThreadMessagesView'
component={ThreadMessagesView}
options={ThreadMessagesView.navigationOptions}
/>
<ChatsStack.Screen
name='MarkdownTableView'
component={MarkdownTableView}
options={MarkdownTableView.navigationOptions}
/>
<ChatsStack.Screen
name='ReadReceiptsView'
component={ReadReceiptsView}
options={ReadReceiptsView.navigationOptions}
/>
</ChatsStack.Navigator>
);
};
// ProfileStackNavigator
const ProfileStack = createStackNavigator();
const ProfileStackNavigator = () => {
const { theme } = React.useContext(ThemeContext);
return (
<ProfileStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>
<ProfileStack.Screen
name='ProfileView'
component={ProfileView}
options={ProfileView.navigationOptions}
/>
</ProfileStack.Navigator>
);
};
// SettingsStackNavigator
const SettingsStack = createStackNavigator();
const SettingsStackNavigator = () => {
const { theme } = React.useContext(ThemeContext);
return (
<SettingsStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>
<SettingsStack.Screen
name='SettingsView'
component={SettingsView}
options={SettingsView.navigationOptions}
/>
<SettingsStack.Screen
name='LanguageView'
component={LanguageView}
options={LanguageView.navigationOptions}
/>
<SettingsStack.Screen
name='ThemeView'
component={ThemeView}
options={ThemeView.navigationOptions}
/>
<SettingsStack.Screen
name='DefaultBrowserView'
component={DefaultBrowserView}
options={DefaultBrowserView.navigationOptions}
/>
<SettingsStack.Screen
name='ScreenLockConfigView'
component={ScreenLockConfigView}
options={ScreenLockConfigView.navigationOptions}
/>
</SettingsStack.Navigator>
);
};
// AdminPanelStackNavigator
const AdminPanelStack = createStackNavigator();
const AdminPanelStackNavigator = () => {
const { theme } = React.useContext(ThemeContext);
return (
<AdminPanelStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>
<AdminPanelStack.Screen
name='AdminPanelView'
component={AdminPanelView}
options={AdminPanelView.navigationOptions}
/>
</AdminPanelStack.Navigator>
);
};
// DrawerNavigator
const Drawer = createDrawerNavigator();
const DrawerNavigator = () => (
<Drawer.Navigator
drawerContent={({ navigation, state }) => <Sidebar navigation={navigation} state={state} />}
screenOptions={{ swipeEnabled: false }}
drawerType='back'
>
<Drawer.Screen name='ChatsStackNavigator' component={ChatsStackNavigator} />
<Drawer.Screen name='ProfileStackNavigator' component={ProfileStackNavigator} />
<Drawer.Screen name='SettingsStackNavigator' component={SettingsStackNavigator} />
<Drawer.Screen name='AdminPanelStackNavigator' component={AdminPanelStackNavigator} />
</Drawer.Navigator>
);
// NewMessageStackNavigator
const NewMessageStack = createStackNavigator();
const NewMessageStackNavigator = () => {
const { theme } = React.useContext(ThemeContext);
return (
<NewMessageStack.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>
<NewMessageStack.Screen
name='NewMessageView'
component={NewMessageView}
options={NewMessageView.navigationOptions}
/>
<NewMessageStack.Screen
name='SelectedUsersViewCreateChannel'
component={SelectedUsersView}
/>
<NewMessageStack.Screen
name='CreateChannelView'
component={CreateChannelView}
options={CreateChannelView.navigationOptions}
/>
<NewMessageStack.Screen
name='CreateDiscussionView'
component={CreateDiscussionView}
/>
</NewMessageStack.Navigator>
);
};
// InsideStackNavigator
const InsideStack = createStackNavigator();
const InsideStackNavigator = () => {
const { theme } = React.useContext(ThemeContext);
return (
<InsideStack.Navigator mode='modal' screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...ModalAnimation }}>
<InsideStack.Screen
name='DrawerNavigator'
component={DrawerNavigator}
options={{ headerShown: false }}
/>
<InsideStack.Screen
name='NewMessageStackNavigator'
component={NewMessageStackNavigator}
options={{ headerShown: false }}
/>
<InsideStack.Screen
name='AttachmentView'
component={AttachmentView}
/>
<InsideStack.Screen
name='StatusView'
component={StatusView}
/>
<InsideStack.Screen
name='ModalBlockView'
component={ModalBlockView}
options={ModalBlockView.navigationOptions}
/>
<InsideStack.Screen
name='JitsiMeetView'
component={JitsiMeetView}
options={{ headerShown: false }}
/>
</InsideStack.Navigator>
);
};
const RootInsideStack = ({ navigation, route }) => (
<>
<InsideStackNavigator navigation={navigation} />
<NotificationBadge navigation={navigation} route={route} />
<Toast />
</>
);
RootInsideStack.propTypes = {
navigation: PropTypes.object,
route: PropTypes.object
};
export default RootInsideStack;