2018-06-05 01:17:02 +00:00
|
|
|
import React from 'react';
|
2018-06-13 01:33:00 +00:00
|
|
|
import { Platform, TouchableOpacity } from 'react-native';
|
2018-05-21 18:39:26 +00:00
|
|
|
import { createStackNavigator, createDrawerNavigator } from 'react-navigation';
|
2018-06-05 01:17:02 +00:00
|
|
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
import Sidebar from '../../containers/Sidebar';
|
|
|
|
import RoomsListView from '../../views/RoomsListView';
|
|
|
|
import RoomView from '../../views/RoomView';
|
2018-02-19 21:19:39 +00:00
|
|
|
import RoomActionsView from '../../views/RoomActionsView';
|
2017-09-21 17:08:00 +00:00
|
|
|
import CreateChannelView from '../../views/CreateChannelView';
|
2018-04-24 19:34:03 +00:00
|
|
|
import SelectedUsersView from '../../views/SelectedUsersView';
|
2017-12-20 19:20:06 +00:00
|
|
|
import NewServerView from '../../views/NewServerView';
|
2018-02-19 21:19:39 +00:00
|
|
|
import StarredMessagesView from '../../views/StarredMessagesView';
|
|
|
|
import PinnedMessagesView from '../../views/PinnedMessagesView';
|
2018-03-02 15:11:34 +00:00
|
|
|
import MentionedMessagesView from '../../views/MentionedMessagesView';
|
2018-03-23 16:49:51 +00:00
|
|
|
import SnippetedMessagesView from '../../views/SnippetedMessagesView';
|
2018-04-24 19:34:03 +00:00
|
|
|
import SearchMessagesView from '../../views/SearchMessagesView';
|
2018-03-23 16:49:51 +00:00
|
|
|
import RoomFilesView from '../../views/RoomFilesView';
|
2018-03-02 15:11:34 +00:00
|
|
|
import RoomMembersView from '../../views/RoomMembersView';
|
2018-03-29 17:55:37 +00:00
|
|
|
import RoomInfoView from '../../views/RoomInfoView';
|
|
|
|
import RoomInfoEditView from '../../views/RoomInfoEditView';
|
2018-06-05 01:17:02 +00:00
|
|
|
import ProfileView from '../../views/ProfileView';
|
|
|
|
import SettingsView from '../../views/SettingsView';
|
2018-06-01 17:38:13 +00:00
|
|
|
import I18n from '../../i18n';
|
2018-06-13 01:33:00 +00:00
|
|
|
import sharedStyles from '../../views/Styles';
|
2018-06-01 17:38:13 +00:00
|
|
|
|
|
|
|
const headerTintColor = '#292E35';
|
2017-09-21 17:08:00 +00:00
|
|
|
|
2018-05-21 18:39:26 +00:00
|
|
|
const AuthRoutes = createStackNavigator(
|
2017-09-21 17:08:00 +00:00
|
|
|
{
|
|
|
|
RoomsList: {
|
2017-12-08 19:13:21 +00:00
|
|
|
screen: RoomsListView
|
2017-09-21 17:08:00 +00:00
|
|
|
},
|
|
|
|
Room: {
|
2017-12-08 19:13:21 +00:00
|
|
|
screen: RoomView
|
2017-09-21 17:08:00 +00:00
|
|
|
},
|
|
|
|
CreateChannel: {
|
|
|
|
screen: CreateChannelView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Create_Channel'),
|
|
|
|
headerTintColor
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
2017-09-25 13:15:28 +00:00
|
|
|
},
|
2018-04-24 19:34:03 +00:00
|
|
|
SelectedUsers: {
|
|
|
|
screen: SelectedUsersView,
|
2017-09-25 13:15:28 +00:00
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Select_Users'),
|
|
|
|
headerTintColor
|
2017-09-25 13:15:28 +00:00
|
|
|
}
|
2017-12-20 19:20:06 +00:00
|
|
|
},
|
|
|
|
AddServer: {
|
|
|
|
screen: NewServerView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('New_Server'),
|
|
|
|
headerTintColor
|
2017-12-20 19:20:06 +00:00
|
|
|
}
|
2018-02-19 21:19:39 +00:00
|
|
|
},
|
|
|
|
RoomActions: {
|
|
|
|
screen: RoomActionsView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Actions'),
|
|
|
|
headerTintColor
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
StarredMessages: {
|
|
|
|
screen: StarredMessagesView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Starred_Messages'),
|
|
|
|
headerTintColor
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
PinnedMessages: {
|
|
|
|
screen: PinnedMessagesView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Pinned_Messages'),
|
|
|
|
headerTintColor
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
2018-03-02 15:11:34 +00:00
|
|
|
},
|
|
|
|
MentionedMessages: {
|
|
|
|
screen: MentionedMessagesView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Mentioned_Messages'),
|
|
|
|
headerTintColor
|
2018-03-02 15:11:34 +00:00
|
|
|
}
|
|
|
|
},
|
2018-03-23 16:49:51 +00:00
|
|
|
SnippetedMessages: {
|
|
|
|
screen: SnippetedMessagesView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Snippet_Messages'),
|
|
|
|
headerTintColor
|
2018-03-23 16:49:51 +00:00
|
|
|
}
|
|
|
|
},
|
2018-04-24 19:34:03 +00:00
|
|
|
SearchMessages: {
|
|
|
|
screen: SearchMessagesView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Search_Messages'),
|
|
|
|
headerTintColor
|
2018-04-24 19:34:03 +00:00
|
|
|
}
|
|
|
|
},
|
2018-03-23 16:49:51 +00:00
|
|
|
RoomFiles: {
|
|
|
|
screen: RoomFilesView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Room_Files'),
|
|
|
|
headerTintColor
|
2018-03-23 16:49:51 +00:00
|
|
|
}
|
|
|
|
},
|
2018-03-02 15:11:34 +00:00
|
|
|
RoomMembers: {
|
|
|
|
screen: RoomMembersView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Room_Members'),
|
|
|
|
headerTintColor
|
2018-03-02 15:11:34 +00:00
|
|
|
}
|
2018-03-29 17:55:37 +00:00
|
|
|
},
|
|
|
|
RoomInfo: {
|
|
|
|
screen: RoomInfoView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Room_Info'),
|
|
|
|
headerTintColor
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
RoomInfoEdit: {
|
|
|
|
screen: RoomInfoEditView,
|
|
|
|
navigationOptions: {
|
2018-06-01 17:38:13 +00:00
|
|
|
title: I18n.t('Room_Info_Edit'),
|
|
|
|
headerTintColor
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
|
|
|
},
|
2017-12-11 20:37:33 +00:00
|
|
|
{
|
|
|
|
navigationOptions: {
|
|
|
|
headerTitleAllowFontScaling: false
|
|
|
|
}
|
|
|
|
}
|
2017-09-21 17:08:00 +00:00
|
|
|
);
|
|
|
|
|
2018-06-13 01:33:00 +00:00
|
|
|
const MenuButton = ({ navigation, testID }) => (
|
|
|
|
<TouchableOpacity
|
|
|
|
style={sharedStyles.headerButton}
|
|
|
|
onPress={navigation.toggleDrawer}
|
|
|
|
accessibilityLabel={I18n.t('Toggle_Drawer')}
|
|
|
|
accessibilityTraits='button'
|
|
|
|
testID={testID}
|
|
|
|
>
|
|
|
|
<Icon name='menu' size={30} color='#292E35' />
|
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
|
2018-05-21 18:39:26 +00:00
|
|
|
const Routes = createDrawerNavigator(
|
2017-09-25 13:15:28 +00:00
|
|
|
{
|
2018-06-05 01:17:02 +00:00
|
|
|
Chats: {
|
|
|
|
screen: AuthRoutes,
|
|
|
|
navigationOptions: {
|
2018-06-13 01:33:00 +00:00
|
|
|
drawerLabel: I18n.t('Chats'),
|
2018-06-05 01:17:02 +00:00
|
|
|
drawerIcon: () => <Icon name='chat-bubble' size={20} />
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ProfileView: {
|
|
|
|
screen: createStackNavigator({
|
|
|
|
ProfileView: {
|
|
|
|
screen: ProfileView,
|
|
|
|
navigationOptions: ({ navigation }) => ({
|
2018-06-13 01:33:00 +00:00
|
|
|
title: I18n.t('Profile'),
|
2018-06-05 01:17:02 +00:00
|
|
|
headerTintColor: '#292E35',
|
2018-06-13 01:33:00 +00:00
|
|
|
headerLeft: <MenuButton navigation={navigation} testID='profile-view-sidebar' />
|
2018-06-05 01:17:02 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
SettingsView: {
|
|
|
|
screen: createStackNavigator({
|
|
|
|
SettingsView: {
|
|
|
|
screen: SettingsView,
|
|
|
|
navigationOptions: ({ navigation }) => ({
|
2018-06-13 01:33:00 +00:00
|
|
|
title: I18n.t('Settings'),
|
2018-06-05 01:17:02 +00:00
|
|
|
headerTintColor: '#292E35',
|
2018-06-13 01:33:00 +00:00
|
|
|
headerLeft: <MenuButton navigation={navigation} testID='settings-view-sidebar' />
|
2018-06-05 01:17:02 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
2017-09-25 13:15:28 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
contentComponent: Sidebar,
|
2018-06-13 01:33:00 +00:00
|
|
|
drawerLockMode: Platform.OS === 'ios' ? 'locked-closed' : 'unlocked',
|
2018-06-05 01:17:02 +00:00
|
|
|
initialRouteName: 'Chats',
|
|
|
|
backBehavior: 'initialRoute'
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
2017-09-25 13:15:28 +00:00
|
|
|
);
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
export default Routes;
|