verdnatura-chat/app/containers/EmojiPicker/TabBar.tsx

48 lines
1.2 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import styles from './styles';
2019-12-04 16:39:53 +00:00
import { themes } from '../../constants/colors';
interface ITabBarProps {
goToPage({}): void;
activeTab: number,
tabs: [],
tabEmojiStyle: object,
theme: string
}
export default class TabBar extends React.Component<Partial<ITabBarProps>> {
shouldComponentUpdate(nextProps: any) {
2019-12-04 16:39:53 +00:00
const { activeTab, theme } = this.props;
if (nextProps.activeTab !== activeTab) {
return true;
}
2019-12-04 16:39:53 +00:00
if (nextProps.theme !== theme) {
return true;
}
return false;
}
render() {
const { tabs, goToPage, tabEmojiStyle, activeTab, theme } = this.props;
return (
<View style={styles.tabsContainer}>
2021-07-19 15:06:45 +00:00
{tabs!.map((tab, i) => (
<TouchableOpacity
activeOpacity={0.7}
key={tab}
2021-07-19 15:06:45 +00:00
onPress={() => goToPage!(i)}
style={styles.tab}
2018-05-23 13:39:18 +00:00
testID={`reaction-picker-${ tab }`}
>
<Text style={[styles.tabEmoji, tabEmojiStyle]}>{tab}</Text>
2021-07-19 15:06:45 +00:00
{activeTab === i ? <View style={[styles.activeTabLine, { backgroundColor: themes[theme!].tintColor }]} /> : <View style={styles.tabLine} />}
</TouchableOpacity>
))}
</View>
);
}
}