2019-03-12 16:23:06 +00:00
|
|
|
import React from 'react';
|
2021-10-01 18:12:19 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2019-03-12 16:23:06 +00:00
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
import Touch from '../../utils/touch';
|
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
import { withTheme } from '../../theme';
|
2021-10-01 18:12:19 +00:00
|
|
|
import styles from './styles';
|
2019-03-12 16:23:06 +00:00
|
|
|
|
2021-11-25 14:25:11 +00:00
|
|
|
interface SidebarItemProps {
|
|
|
|
left: JSX.Element;
|
|
|
|
right: JSX.Element;
|
|
|
|
text: string;
|
|
|
|
current: boolean;
|
|
|
|
onPress(): void;
|
|
|
|
testID: string;
|
|
|
|
theme: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Item = React.memo(({ left, right, text, onPress, testID, current, theme }: SidebarItemProps) => (
|
2019-12-04 16:39:53 +00:00
|
|
|
<Touch
|
2019-03-12 16:23:06 +00:00
|
|
|
key={testID}
|
|
|
|
testID={testID}
|
|
|
|
onPress={onPress}
|
2019-12-04 16:39:53 +00:00
|
|
|
theme={theme}
|
2021-10-01 18:12:19 +00:00
|
|
|
style={[styles.item, current && { backgroundColor: themes[theme].borderColor }]}>
|
|
|
|
<View style={styles.itemHorizontal}>{left}</View>
|
2019-03-12 16:23:06 +00:00
|
|
|
<View style={styles.itemCenter}>
|
2020-05-08 17:09:36 +00:00
|
|
|
<Text style={[styles.itemText, { color: themes[theme].titleText }]} numberOfLines={1}>
|
2019-03-12 16:23:06 +00:00
|
|
|
{text}
|
|
|
|
</Text>
|
|
|
|
</View>
|
2021-10-01 18:12:19 +00:00
|
|
|
<View style={styles.itemHorizontal}>{right}</View>
|
2019-12-04 16:39:53 +00:00
|
|
|
</Touch>
|
2019-03-12 16:23:06 +00:00
|
|
|
));
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
export default withTheme(Item);
|