mattermost-mobile/app/components/profile_picture/status.tsx
Daniel Espino García b27ebce2e0
[Gekidou] [MM-39718] Add Create DM screen (#5900)
* Add Create DM screen

* Add channel toggle and minor improvements

* Fix tests and apply new UI

* Address feedback UX feedback and fix missing menu item by adding another item height

* Add display name to channels and piggyback improvement on fetchUserByIds action and translations fix

* Address feedback

* Fix hardcoded colors

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2022-03-11 12:57:31 -03:00

58 lines
1.6 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useMemo} from 'react';
import {StyleProp, View, ViewProps} from 'react-native';
import UserStatus from '@components/user_status';
import {makeStyleSheetFromTheme} from '@utils/theme';
import type UserModel from '@typings/database/models/servers/user';
type Props = {
author?: UserModel | UserProfile;
statusSize: number;
statusStyle?: StyleProp<ViewProps>;
theme: Theme;
}
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
return {
statusWrapper: {
position: 'absolute',
bottom: 0,
right: 0,
overflow: 'hidden',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: theme.centerChannelBg,
borderWidth: 1,
borderColor: theme.centerChannelBg,
},
};
});
const Status = ({author, statusSize, statusStyle, theme}: Props) => {
const styles = getStyleSheet(theme);
const containerStyle = useMemo(() => ([
styles.statusWrapper,
statusStyle,
{borderRadius: statusSize / 2},
]), [statusStyle]);
const isBot = author && (('isBot' in author) ? author.isBot : author.is_bot);
if (author?.status && !isBot) {
return (
<View
style={containerStyle}
>
<UserStatus
size={statusSize}
status={author.status}
/>
</View>
);
}
return null;
};
export default Status;