mattermost-mobile/app/components/user_status/user_status.js
Michał Odziemczyk 3a3be22af0 Remove svg usage for user status (#1486)
* Remove SVG usage for status indicators to speedup channel loading

* Add needed assets for status icons (72x72)

* correct folder name

* Delete offline.png

* Delete dnd.png

* Delete online.png

* Delete away.png

* make icons white

* correct size
2018-03-14 10:31:58 -04:00

60 lines
1.5 KiB
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React, {PureComponent} from 'react';
import {Image} from 'react-native';
import PropTypes from 'prop-types';
import {General} from 'mattermost-redux/constants';
import away from 'assets/images/status/away.png';
import dnd from 'assets/images/status/dnd.png';
import offline from 'assets/images/status/offline.png';
import online from 'assets/images/status/online.png';
const statusToIcon = {
away,
dnd,
offline,
online,
};
export default class UserStatus extends PureComponent {
static propTypes = {
size: PropTypes.number,
status: PropTypes.string,
theme: PropTypes.object.isRequired,
};
static defaultProps = {
size: 14,
status: General.OFFLINE,
};
render() {
const {size, status, theme} = this.props;
const Icon = statusToIcon[status];
let iconColor;
switch (status) {
case General.AWAY:
iconColor = theme.awayIndicator;
break;
case General.DND:
iconColor = theme.dndIndicator;
break;
case General.ONLINE:
iconColor = theme.onlineIndicator;
break;
default:
iconColor = theme.centerChannelColor;
break;
}
return (
<Image
source={Icon}
style={{height: size, width: size, tintColor: iconColor}}
/>
);
}
}