2018-05-18 16:41:47 +00:00
|
|
|
import React from 'react';
|
2022-01-17 16:10:39 +00:00
|
|
|
import { StyleSheet, ViewStyle } from 'react-native';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2019-04-08 12:35:28 +00:00
|
|
|
import { CustomIcon } from '../lib/Icons';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { STATUS_COLORS, themes } from '../lib/constants';
|
2021-03-31 17:47:17 +00:00
|
|
|
import Status from './Status/Status';
|
2022-04-12 16:27:05 +00:00
|
|
|
import { useTheme } from '../theme';
|
2022-03-25 20:05:49 +00:00
|
|
|
import { TUserStatus } from '../definitions';
|
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 {
|
|
|
|
type: string;
|
2022-01-17 16:10:39 +00:00
|
|
|
isGroupChat?: boolean;
|
|
|
|
teamMain?: boolean;
|
2022-03-25 20:05:49 +00:00
|
|
|
status?: TUserStatus;
|
2022-01-17 16:10:39 +00:00
|
|
|
size?: number;
|
|
|
|
style?: ViewStyle;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
2022-04-12 16:27:05 +00:00
|
|
|
const RoomTypeIcon = React.memo(({ type, isGroupChat, status, style, teamMain, size = 16 }: IRoomTypeIcon) => {
|
|
|
|
const { theme } = useTheme();
|
2018-05-24 20:17:45 +00:00
|
|
|
if (!type) {
|
|
|
|
return null;
|
|
|
|
}
|
2022-04-12 16:27:05 +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) {
|
2022-03-25 20:05:49 +00:00
|
|
|
if (!status) {
|
|
|
|
status = 'offline';
|
|
|
|
}
|
|
|
|
return <Status style={[iconStyle, { color: STATUS_COLORS[status] }]} size={size} status={status} />;
|
2021-03-31 17:47:17 +00:00
|
|
|
}
|
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
|
|
|
|
2022-04-12 16:27:05 +00:00
|
|
|
export default RoomTypeIcon;
|