Skip to content

Feat/ Add customElement prop to Drawer #1402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion generatedTypes/components/drawer/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PureComponent, RefObject } from 'react';
import React, { PureComponent, ReactNode, RefObject } from 'react';
import { Animated, ViewStyle, TextStyle } from 'react-native';
import Swipeable, { SwipeableProps } from './Swipeable';
interface ItemProps {
Expand All @@ -10,6 +10,7 @@ interface ItemProps {
keepOpen?: boolean;
style?: ViewStyle;
testID?: string;
customElement?: ReactNode;
}
interface Props {
/**
Expand Down
8 changes: 5 additions & 3 deletions src/components/drawer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import React, {PureComponent, RefObject} from 'react';
import React, {PureComponent, ReactNode, RefObject} from 'react';
import memoize from 'memoize-one';
import {Animated, Easing, StyleSheet, ViewStyle, TextStyle, AccessibilityActionEvent} from 'react-native';
import {RectButton} from 'react-native-gesture-handler';
Expand All @@ -23,6 +23,7 @@ interface ItemProps {
keepOpen?: boolean;
style?: ViewStyle;
testID?: string;
customElement?: ReactNode;
}

interface Props {
Expand Down Expand Up @@ -347,7 +348,8 @@ class Drawer extends PureComponent<Props> {
]}
onPress={() => this.onActionPress(item)}
>
{item.icon && (
{item.customElement}
{!item.customElement && item.icon && (
<Animated.Image
source={item.icon}
style={[
Expand All @@ -362,7 +364,7 @@ class Drawer extends PureComponent<Props> {
]}
/>
)}
{item.text && (
{!item.customElement && item.text && (
<Animated.Text
style={[
styles.actionText,
Expand Down