mattermost-mobile/app/screens/reaction_list/reaction_header.js
Daniel Espino García 4c8594d330
Add linter rules for import order and type member delimiters (#5514)
* Add linter rules for import order and type member delimiters

* Remove unneeded group

* Group all app/* imports before the internal imports

* Move app/ imports before parent imports

* Separate @node_modules imports into a different group

* Substitute app paths by aliases

* Fix @node_modules import order and add test related modules

* Add aliases for types and test, and group import types
2021-07-23 11:06:04 +02:00

87 lines
2.5 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import PropTypes from 'prop-types';
import React, {PureComponent} from 'react';
import {
Animated,
Platform,
ScrollView,
} from 'react-native';
import {NativeViewGestureHandler} from 'react-native-gesture-handler';
import {makeStyleSheetFromTheme} from '@utils/theme';
import ReactionHeaderItem from './reaction_header_item';
export default class ReactionHeader extends PureComponent {
static propTypes = {
forwardedRef: PropTypes.object,
selected: PropTypes.string.isRequired,
onSelectReaction: PropTypes.func.isRequired,
reactions: PropTypes.array.isRequired,
theme: PropTypes.object.isRequired,
};
handleOnPress = (emoji) => {
this.props.onSelectReaction(emoji);
};
renderReactionHeaderItems = () => {
const {selected, reactions, theme} = this.props;
return reactions.map((reaction) => (
<ReactionHeaderItem
key={reaction.name}
count={reaction.count}
emojiName={reaction.name}
highlight={selected === reaction.name}
onPress={this.handleOnPress}
theme={theme}
/>
));
};
render() {
const {theme} = this.props;
const style = getStyleSheet(theme);
return (
<NativeViewGestureHandler
ref={this.props.forwardedRef}
>
<Animated.View style={style.container}>
<ScrollView
alwaysBounceHorizontal={false}
horizontal={true}
overScrollMode='never'
>
{this.renderReactionHeaderItems()}
</ScrollView>
</Animated.View>
</NativeViewGestureHandler>
);
}
}
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
container: {
backgroundColor: theme.centerChannelBg,
height: 36.5,
paddingHorizontal: 0,
width: '100%',
maxWidth: 450,
...Platform.select({
android: {
borderTopRightRadius: 2,
borderTopLeftRadius: 2,
},
ios: {
borderTopRightRadius: 10,
borderTopLeftRadius: 10,
},
}),
},
};
});