Skip to content

add active color for text and support left align for container #343

@congduong97

Description

@congduong97

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-element-dropdown@2.12.4 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx b/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx
index 2a73f2f..779e6d1 100644
--- a/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx
+++ b/node_modules/react-native-element-dropdown/src/components/Dropdown/index.tsx
@@ -95,6 +95,8 @@ const DropdownComponent = React.forwardRef<IDropdownRef, DropdownProps<any>>(
       closeModalWhenSelectedItem = true,
       excludeItems = [],
       excludeSearchItems = [],
+      activeTextColor,
+      containerLeftAlign = 0
     } = props;
 
     const ref = useRef<View>(null);
@@ -514,6 +516,9 @@ const DropdownComponent = React.forwardRef<IDropdownRef, DropdownProps<any>>(
                       styles.textItem,
                       itemTextStyle,
                       font(),
+                      selected && !!activeTextColor && {
+                        color: activeTextColor
+                      }
                     ])}
                   >
                     {_get(item, labelField)}
@@ -709,6 +714,9 @@ const DropdownComponent = React.forwardRef<IDropdownRef, DropdownProps<any>>(
                           width,
                         },
                         containerStyle,
+                        {
+                         left: left - containerLeftAlign
+                        }
                       ])}
                     >
                       {_renderList(isTopPosition)}
diff --git a/node_modules/react-native-element-dropdown/src/components/Dropdown/model.ts b/node_modules/react-native-element-dropdown/src/components/Dropdown/model.ts
index e4212a9..8ceab1b 100644
--- a/node_modules/react-native-element-dropdown/src/components/Dropdown/model.ts
+++ b/node_modules/react-native-element-dropdown/src/components/Dropdown/model.ts
@@ -71,4 +71,6 @@ export interface DropdownProps<T> {
   searchQuery?: (keyword: string, labelValue: string) => boolean;
   onChangeText?: (search: string) => void;
   onConfirmSelectItem?: (item: T) => void;
+  activeTextColor?: string;
+  containerLeftAlign?: number;
 }

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions