2021-09-13 20:41:05 +00:00
|
|
|
import React from 'react';
|
2022-10-21 18:27:55 +00:00
|
|
|
import { Pressable, View } from 'react-native';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
2022-10-21 18:27:55 +00:00
|
|
|
import { useTheme } from '../../theme';
|
|
|
|
import { ITabBarProps } from './interfaces';
|
|
|
|
import { isIOS } from '../../lib/methods/helpers';
|
|
|
|
import { CustomIcon } from '../CustomIcon';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-10-21 18:27:55 +00:00
|
|
|
const TabBar = ({ activeTab, tabs, goToPage }: ITabBarProps): React.ReactElement => {
|
|
|
|
const { colors } = useTheme();
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-10-21 18:27:55 +00:00
|
|
|
return (
|
|
|
|
<View style={styles.tabsContainer}>
|
|
|
|
{tabs?.map((tab, i) => (
|
|
|
|
<Pressable
|
|
|
|
key={tab}
|
|
|
|
onPress={() => goToPage?.(i)}
|
|
|
|
testID={`emoji-picker-tab-${tab}`}
|
2024-01-25 14:11:07 +00:00
|
|
|
android_ripple={{ color: colors.buttonBackgroundSecondaryPress }}
|
2022-10-21 18:27:55 +00:00
|
|
|
style={({ pressed }: { pressed: boolean }) => [
|
|
|
|
styles.tab,
|
|
|
|
{
|
2024-01-25 14:11:07 +00:00
|
|
|
backgroundColor: isIOS && pressed ? colors.buttonBackgroundSecondaryPress : 'transparent'
|
2022-10-21 18:27:55 +00:00
|
|
|
}
|
|
|
|
]}
|
|
|
|
>
|
2024-01-25 14:11:07 +00:00
|
|
|
<CustomIcon name={tab} size={24} color={activeTab === i ? colors.strokeHighlight : colors.fontSecondaryInfo} />
|
2022-10-21 18:27:55 +00:00
|
|
|
<View
|
|
|
|
style={
|
|
|
|
activeTab === i
|
2024-01-25 14:11:07 +00:00
|
|
|
? [styles.activeTabLine, { backgroundColor: colors.strokeHighlight }]
|
|
|
|
: [styles.tabLine, { backgroundColor: colors.strokeExtraLight }]
|
2022-10-21 18:27:55 +00:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
</Pressable>
|
|
|
|
))}
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-10-21 18:27:55 +00:00
|
|
|
export default TabBar;
|