Rocket.Chat.ReactNative/app/views/RoomView/Header/RoomHeaderLeft.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-11-25 20:01:17 +00:00
import React from 'react';
import PropTypes from 'prop-types';
import { StyleSheet } from 'react-native';
import { HeaderBackButton } from 'react-navigation-stack';
import { isIOS } from '../../../utils/deviceInfo';
2019-12-04 16:39:53 +00:00
import { themes } from '../../../constants/colors';
2019-11-25 20:01:17 +00:00
import Avatar from '../../../containers/Avatar';
const styles = StyleSheet.create({
avatar: {
borderRadius: 10,
marginHorizontal: 16
}
});
const RoomHeaderLeft = ({
2019-12-04 16:39:53 +00:00
tmid, unreadsCount, navigation, baseUrl, userId, token, title, t, theme, goRoomActionsView, split
2019-11-25 20:01:17 +00:00
}) => {
if (!split || tmid) {
return (
<HeaderBackButton
title={unreadsCount > 999 ? '+999' : unreadsCount || ' '}
backTitleVisible={isIOS}
onPress={() => navigation.goBack()}
2019-12-04 16:39:53 +00:00
tintColor={themes[theme].headerTintColor}
2019-11-25 20:01:17 +00:00
/>
);
}
if (baseUrl && userId && token) {
return (
<Avatar
text={title}
size={30}
type={t}
baseUrl={baseUrl}
style={styles.avatar}
userId={userId}
token={token}
2019-12-04 16:39:53 +00:00
theme={theme}
2019-11-25 20:01:17 +00:00
onPress={goRoomActionsView}
/>
);
}
return null;
};
RoomHeaderLeft.propTypes = {
tmid: PropTypes.string,
unreadsCount: PropTypes.number,
navigation: PropTypes.object,
baseUrl: PropTypes.string,
userId: PropTypes.string,
token: PropTypes.string,
title: PropTypes.string,
t: PropTypes.string,
2019-12-04 16:39:53 +00:00
theme: PropTypes.string,
2019-11-25 20:01:17 +00:00
goRoomActionsView: PropTypes.func,
split: PropTypes.bool
};
export default RoomHeaderLeft;