* Unable to open previews from search, pinned and mentions * Updated Compass Icons * Added Icon to LHS and Channel Info * Added Icons to Manage/View Members list * Added Icon to shared users in posts * Added icon to channel header, fixed header style * Added Icons in autocomplete * WIP: Add shared shannels to browse * Adding Shared Channels string to i18n * Added remote organization to remote user profile * Updated snapshot for channel header * Added browsing shared channels * Removed the exmpty line * Added snapshot when user is remote * Reverted compass icons and added icons only needed for shared channels * Fixed i18n swapped * Copied compass-icons from webapp * Fixed showing shared channels as deleted after browsing them * Added new compass ttf to android & fixed icon style for browse channel listing * Fixed search for shared channels * user profile snapshot updated with testId * User list row snapshot updated with testID * Moved shared user check to util function * Fixed required props warning for ChannelIcon component * Update app/screens/user_profile/index.js Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * Removed Request related redux * Reverted client4 * Added rest calls * Updated snapshot * Reverted files * Adding back shared channels stuff to channel icon & showing shared channels only when enabled in browse channels * Fixed misc issues * moved empty array outside the function to avoid re-render * Removed renaming fields Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
194 lines
5.7 KiB
TypeScript
194 lines
5.7 KiB
TypeScript
// 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<ViewStyle>;
|
|
style?: StyleProp<ViewStyle>;
|
|
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 = (
|
|
<CompassIcon
|
|
name='archive-outline'
|
|
style={[style.icon, unreadIcon, activeIcon, {fontSize: props.size, left: 1}]}
|
|
testID={`${props.testID}.archive`}
|
|
/>
|
|
);
|
|
} else if (props.hasDraft) {
|
|
icon = (
|
|
<CompassIcon
|
|
name='pencil-outline'
|
|
style={[style.icon, unreadIcon, activeIcon, {fontSize: props.size, left: 2}]}
|
|
testID={`${props.testID}.draft`}
|
|
/>
|
|
);
|
|
} 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 = (
|
|
<CompassIcon
|
|
name={iconName}
|
|
style={[style.icon, unreadIcon, activeIcon, {fontSize: props.size, left: 0.5}]}
|
|
testID={sharedTestID}
|
|
/>
|
|
);
|
|
} else if (props.type === General.OPEN_CHANNEL) {
|
|
icon = (
|
|
<CompassIcon
|
|
name='globe'
|
|
style={[style.icon, unreadIcon, activeIcon, {fontSize: props.size, left: 1}]}
|
|
testID={`${props.testID}.public`}
|
|
/>
|
|
);
|
|
} else if (props.type === General.PRIVATE_CHANNEL) {
|
|
icon = (
|
|
<CompassIcon
|
|
name='lock-outline'
|
|
style={[style.icon, unreadIcon, activeIcon, {fontSize: props.size, left: 0.5}]}
|
|
testID={`${props.testID}.private`}
|
|
/>
|
|
);
|
|
} else if (props.type === General.GM_CHANNEL) {
|
|
const fontSize = (props.size - 12);
|
|
const boxSize = (props.size - 4);
|
|
icon = (
|
|
<View style={[style.groupBox, unreadGroupBox, activeGroupBox, {width: boxSize, height: boxSize}]}>
|
|
<Text
|
|
style={[style.group, unreadGroup, activeGroup, {fontSize}]}
|
|
testID={`${props.testID}.gm_member_count`}
|
|
>
|
|
{props.membersCount}
|
|
</Text>
|
|
</View>
|
|
);
|
|
} else if (props.type === General.DM_CHANNEL) {
|
|
icon = (
|
|
<ProfilePicture
|
|
size={props.size}
|
|
statusSize={12}
|
|
userId={props.userId}
|
|
testID={props.testID}
|
|
statusStyle={props.statusStyle}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<View style={[style.container, {width: props.size, height: props.size}, props.style]}>
|
|
{icon}
|
|
</View>
|
|
);
|
|
};
|
|
|
|
ChannelIcon.defaultProps = {
|
|
hasDraft: false,
|
|
isActive: false,
|
|
isArchived: false,
|
|
isInfo: false,
|
|
isUnread: false,
|
|
membersCount: 0,
|
|
size: 12,
|
|
};
|
|
|
|
export default ChannelIcon;
|