vn-verdnaturachat/app/containers/RoomTypeIcon.tsx

62 lines
1.5 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { StyleSheet, ViewStyle } from 'react-native';
2019-04-08 12:35:28 +00:00
import { CustomIcon } from '../lib/Icons';
import { STATUS_COLORS, themes } from '../lib/constants';
import Status from './Status/Status';
import { useTheme } from '../theme';
import { TUserStatus } from '../definitions';
const styles = StyleSheet.create({
icon: {
marginRight: 4
}
});
interface IRoomTypeIcon {
type: string;
isGroupChat?: boolean;
teamMain?: boolean;
status?: TUserStatus;
size?: number;
style?: ViewStyle;
}
const RoomTypeIcon = React.memo(({ type, isGroupChat, status, style, teamMain, size = 16 }: IRoomTypeIcon) => {
const { theme } = useTheme();
if (!type) {
return null;
}
const color = themes[theme].titleText;
const iconStyle = [styles.icon, { color }, style];
if (type === 'd' && !isGroupChat) {
if (!status) {
status = 'offline';
}
return <Status style={[iconStyle, { color: STATUS_COLORS[status] }]} 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';
if (teamMain) {
icon = `teams${type === 'p' ? '-private' : ''}`;
} else if (type === 'discussion') {
2020-07-27 19:53:33 +00:00
icon = 'discussions';
} else if (type === 'c') {
2020-07-27 19:53:33 +00:00
icon = 'channel-public';
} else if (type === 'd') {
if (isGroupChat) {
icon = 'message';
} else {
2020-07-27 19:53:33 +00:00
icon = 'mention';
}
} else if (type === 'l') {
2020-07-27 19:53:33 +00:00
icon = 'omnichannel';
}
return <CustomIcon name={icon} size={size} style={iconStyle} />;
});
export default RoomTypeIcon;