2018-05-18 16:41:47 +00:00
|
|
|
import React from 'react';
|
2020-06-05 13:28:58 +00:00
|
|
|
import { StyleSheet } from 'react-native';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2019-04-08 12:35:28 +00:00
|
|
|
import { CustomIcon } from '../lib/Icons';
|
2020-05-08 17:36:10 +00:00
|
|
|
import { STATUS_COLORS, themes } from '../constants/colors';
|
2021-03-31 17:47:17 +00:00
|
|
|
import Status from './Status/Status';
|
|
|
|
import { withTheme } from '../theme';
|
2018-05-18 16:41:47 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2020-06-05 13:28:58 +00:00
|
|
|
icon: {
|
|
|
|
marginRight: 4
|
2018-05-18 16:41:47 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
interface IRoomTypeIcon {
|
|
|
|
theme: string;
|
|
|
|
type: string;
|
|
|
|
isGroupChat: boolean;
|
|
|
|
teamMain: boolean;
|
|
|
|
status: string;
|
|
|
|
size: number;
|
|
|
|
style: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
const RoomTypeIcon = React.memo(({ type, isGroupChat, status, style, theme, teamMain, size = 16 }: IRoomTypeIcon) => {
|
2018-05-24 20:17:45 +00:00
|
|
|
if (!type) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-31 17:47:17 +00:00
|
|
|
const color = themes[theme].titleText;
|
2021-09-13 20:41:05 +00:00
|
|
|
const iconStyle = [styles.icon, { color }, style];
|
2021-03-31 17:47:17 +00:00
|
|
|
|
|
|
|
if (type === 'd' && !isGroupChat) {
|
|
|
|
return <Status style={[iconStyle, { color: STATUS_COLORS[status] ?? STATUS_COLORS.offline }]} size={size} status={status} />;
|
|
|
|
}
|
2019-12-04 16:39:53 +00:00
|
|
|
|
[NEW] Add/Create/Remove channel on a team (#3090)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* One way to refactor :P
* Next level refactor :)
* Fix create group dm
* Refactor renderItem
* Minor bug fixes
* Fix stories
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-19 21:14:42 +00:00
|
|
|
// TODO: move this to a separate function
|
2020-07-27 19:53:33 +00:00
|
|
|
let icon = 'channel-private';
|
2021-04-07 18:31:25 +00:00
|
|
|
if (teamMain) {
|
2021-09-13 20:41:05 +00:00
|
|
|
icon = `teams${type === 'p' ? '-private' : ''}`;
|
2021-04-07 18:31:25 +00:00
|
|
|
} else if (type === 'discussion') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'discussions';
|
2020-06-05 13:28:58 +00:00
|
|
|
} else if (type === 'c') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'channel-public';
|
2020-06-05 13:28:58 +00:00
|
|
|
} else if (type === 'd') {
|
2020-04-01 12:28:54 +00:00
|
|
|
if (isGroupChat) {
|
2021-03-31 17:47:17 +00:00
|
|
|
icon = 'message';
|
2020-06-05 13:28:58 +00:00
|
|
|
} else {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'mention';
|
2020-04-01 12:28:54 +00:00
|
|
|
}
|
2020-06-05 13:28:58 +00:00
|
|
|
} else if (type === 'l') {
|
2020-07-27 19:53:33 +00:00
|
|
|
icon = 'omnichannel';
|
2018-08-31 16:46:33 +00:00
|
|
|
}
|
2020-06-05 13:28:58 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
return <CustomIcon name={icon} size={size} style={iconStyle} />;
|
2019-03-01 16:49:11 +00:00
|
|
|
});
|
2018-05-18 16:41:47 +00:00
|
|
|
|
2021-03-31 17:47:17 +00:00
|
|
|
export default withTheme(RoomTypeIcon);
|