// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import {StyleProp, Text, View, ViewStyle} from 'react-native'; import CompassIcon from '@components/compass_icon'; import ProfilePicture from '@components/profile_picture'; import {General} from '@mm-redux/constants'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import type {Theme} from '@mm-redux/types/preferences'; type Props = { hasDraft: boolean; isActive: boolean; isArchived: boolean; isInfo: boolean; isUnread: boolean; membersCount: number; shared: boolean; size: number; statusStyle?: StyleProp; style?: StyleProp; testID?: string; theme: Theme; type: string; userId?: string; }; const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { return { container: { alignItems: 'center', justifyContent: 'center', }, icon: { color: changeOpacity(theme.sidebarText, 0.4), }, iconActive: { color: theme.sidebarTextActiveColor, }, iconUnread: { color: theme.sidebarUnreadText, }, iconInfo: { color: theme.centerChannelColor, }, groupBox: { alignItems: 'center', backgroundColor: changeOpacity(theme.sidebarText, 0.16), borderRadius: 4, justifyContent: 'center', }, groupBoxActive: { backgroundColor: changeOpacity(theme.sidebarTextActiveColor, 0.3), }, groupBoxUnread: { backgroundColor: changeOpacity(theme.sidebarUnreadText, 0.3), }, groupBoxInfo: { backgroundColor: changeOpacity(theme.centerChannelColor, 0.3), }, group: { color: theme.sidebarText, fontSize: 10, fontWeight: '600', }, groupActive: { color: theme.sidebarTextActiveColor, }, groupUnread: { color: theme.sidebarUnreadText, }, groupInfo: { color: theme.centerChannelColor, }, }; }); const ChannelIcon = (props: Props) => { const style = getStyleSheet(props.theme); let activeIcon; let unreadIcon; let activeGroupBox; let unreadGroupBox; let activeGroup; let unreadGroup; if (props.isUnread) { unreadIcon = style.iconUnread; unreadGroupBox = style.groupBoxUnread; unreadGroup = style.groupUnread; } if (props.isActive) { activeIcon = style.iconActive; activeGroupBox = style.groupBoxActive; activeGroup = style.groupActive; } if (props.isInfo) { activeIcon = style.iconInfo; activeGroupBox = style.groupBoxInfo; activeGroup = style.groupInfo; } let icon; if (props.isArchived) { icon = ( ); } else if (props.hasDraft) { icon = ( ); } else if (props.shared) { const iconName = props.type === General.PRIVATE_CHANNEL ? 'circle-multiple-outline-lock' : 'circle-multiple-outline'; const sharedTestID = props.type === General.PRIVATE_CHANNEL ? 'channel_icon.shared_private' : 'channel_icon.shared_open'; icon = ( ); } else if (props.type === General.OPEN_CHANNEL) { icon = ( ); } else if (props.type === General.PRIVATE_CHANNEL) { icon = ( ); } else if (props.type === General.GM_CHANNEL) { const fontSize = (props.size - 12); const boxSize = (props.size - 4); icon = ( {props.membersCount} ); } else if (props.type === General.DM_CHANNEL) { icon = ( ); } return ( {icon} ); }; ChannelIcon.defaultProps = { hasDraft: false, isActive: false, isArchived: false, isInfo: false, isUnread: false, membersCount: 0, size: 12, }; export default ChannelIcon;