diff --git a/app/components/channel_list/categories/body/channel/__snapshots__/badge.test.tsx.snap b/app/components/channel_list/categories/body/channel/__snapshots__/badge.test.tsx.snap new file mode 100644 index 000000000..b9aeb9ca7 --- /dev/null +++ b/app/components/channel_list/categories/body/channel/__snapshots__/badge.test.tsx.snap @@ -0,0 +1,38 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/channel_list/categories/body/channel/badge should match snapshot 1`] = ` + + + 10 + + +`; diff --git a/app/components/channel_list/categories/body/channel/badge.test.tsx b/app/components/channel_list/categories/body/channel/badge.test.tsx new file mode 100644 index 000000000..0696f225e --- /dev/null +++ b/app/components/channel_list/categories/body/channel/badge.test.tsx @@ -0,0 +1,20 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; + +import {renderWithIntlAndTheme} from '@test/intl-test-helper'; + +import Badge from './badge'; + +describe('components/channel_list/categories/body/channel/badge', () => { + it('should match snapshot', () => { + const wrapper = renderWithIntlAndTheme( + , + ); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); +}); diff --git a/app/components/channel_list/categories/body/channel/badge.tsx b/app/components/channel_list/categories/body/channel/badge.tsx new file mode 100644 index 000000000..7a7270f38 --- /dev/null +++ b/app/components/channel_list/categories/body/channel/badge.tsx @@ -0,0 +1,62 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React, {useMemo} from 'react'; +import {Text, View} from 'react-native'; + +import {useTheme} from '@context/theme'; +import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; +import {typography} from '@utils/typography'; + +const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ + badge: { + backgroundColor: theme.mentionBg, + borderRadius: 10, + height: 20, + marginTop: 5, + paddingHorizontal: 8, + alignItems: 'center', + justifyContent: 'center', + textAlignVertical: 'center', + }, + text: { + color: theme.mentionColor, + ...typography('Body', 75), + }, + mutedBadge: { + backgroundColor: changeOpacity(theme.mentionBg, 0.4), + }, + mutedText: { + color: changeOpacity(theme.mentionColor, 0.4), + }, +})); + +const Badge = ({count, muted}: {count: number; muted: boolean}) => { + const theme = useTheme(); + const styles = getStyleSheet(theme); + + const viewStyle = useMemo(() => [ + styles.badge, + muted && styles.mutedBadge, + ], [muted]); + + const textStyle = useMemo(() => [ + styles.text, + + muted && styles.mutedText, + ], [muted]); + + if (!count) { + return null; + } + + return ( + + + {`${count}`} + + + ); +}; + +export default Badge; diff --git a/app/components/channel_list/categories/body/channel/channel_list_item.tsx b/app/components/channel_list/categories/body/channel/channel_list_item.tsx index f364bd3ec..475035688 100644 --- a/app/components/channel_list/categories/body/channel/channel_list_item.tsx +++ b/app/components/channel_list/categories/body/channel/channel_list_item.tsx @@ -15,6 +15,8 @@ import {useTheme} from '@context/theme'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; +import Badge from './badge'; + import type ChannelModel from '@typings/database/models/servers/channel'; import type MyChannelModel from '@typings/database/models/servers/my_channel'; @@ -65,7 +67,7 @@ const ChannelListItem = ({channel, isActive, isOwnDirectMessage, isMuted, myChan const serverUrl = useServerUrl(); // Make it brighter if it's not muted, and highlighted or has unreads - const bright = !isMuted && (myChannel.isUnread || myChannel.mentionsCount > 0); + const bright = !isMuted && (isActive || myChannel.isUnread || myChannel.mentionsCount > 0); const sharedValue = useSharedValue(collapsed && !bright); @@ -117,6 +119,7 @@ const ChannelListItem = ({channel, isActive, isOwnDirectMessage, isMuted, myChan shared={channel.shared} size={24} type={channel.type} + isMuted={isMuted} /> {displayName} + {myChannel.mentionsCount > 0 && + + }