Skip to content

Commit

Permalink
fix: icon rendering and touchable on android issue
Browse files Browse the repository at this point in the history
  • Loading branch information
enesozturk committed Jul 19, 2022
1 parent 8bc071e commit f9b98fa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/components/menu/MenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import React, { useCallback } from 'react';
import { TouchableOpacity } from 'react-native';
import { TouchableOpacity as GHTouchableOpacity } from 'react-native-gesture-handler';
import Animated, { useAnimatedStyle } from 'react-native-reanimated';

import Separator from './Separator';
import styles from './styles';

import { MenuItemProps } from './types';
import { useInternal } from '../../hooks';
import { CONTEXT_MENU_STATE, IS_IOS } from '../../constants';
import { CONTEXT_MENU_STATE } from '../../constants';
import { BORDER_LIGHT_COLOR, BORDER_DARK_COLOR } from './constants';
import isEqual from 'lodash.isequal';
import { getColor } from './calculations';
import { AnimatedIcon } from '../provider/Provider';

const ItemComponent = IS_IOS ? TouchableOpacity : GHTouchableOpacity;
// @ts-ignore
const AnimatedTouchable = Animated.createAnimatedComponent(ItemComponent);
const AnimatedTouchable = Animated.createAnimatedComponent(TouchableOpacity);

type MenuItemComponentProps = {
item: MenuItemProps;
Expand Down Expand Up @@ -64,9 +62,14 @@ const MenuItemComponent = ({ item, isLast }: MenuItemComponentProps) => {
>
{item.text}
</Animated.Text>
{!item.isTitle && item.icon && (
<AnimatedIcon name={item.icon} size={18} style={textColor} />
)}
{!item.isTitle &&
item.icon &&
AnimatedIcon &&
(typeof item.icon === 'string' ? (
<AnimatedIcon name={item.icon} size={18} style={textColor} />
) : (
item.icon()
))}
</AnimatedTouchable>
{item.withSeparator && <Separator />}
</>
Expand Down

0 comments on commit f9b98fa

Please sign in to comment.