Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable changing active options label color #103

Open
vellvj opened this issue Sep 6, 2023 · 0 comments
Open

enable changing active options label color #103

vellvj opened this issue Sep 6, 2023 · 0 comments

Comments

@vellvj
Copy link

vellvj commented Sep 6, 2023

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-multi-selectbox/.DS_Store b/node_modules/react-native-multi-selectbox/.DS_Store
new file mode 100644
index 0000000..9a874b5
Binary files /dev/null and b/node_modules/react-native-multi-selectbox/.DS_Store differ
diff --git a/node_modules/react-native-multi-selectbox/index.js b/node_modules/react-native-multi-selectbox/index.js
index 665fba2..7d733c7 100644
--- a/node_modules/react-native-multi-selectbox/index.js
+++ b/node_modules/react-native-multi-selectbox/index.js
@@ -23,6 +23,7 @@ function SelectBox({
   optionsLabelStyle,
   optionContainerStyle,
   multiOptionContainerStyle,
+  activeOptionsLabelStyle,
   multiOptionsLabelStyle,
   multiListEmptyLabelStyle,
   listEmptyLabelStyle,
@@ -35,12 +36,19 @@ function SelectBox({
   const [showOptions, setShowOptions] = useState(false)
 
   function renderLabel(item) {
-    const kOptionsLabelStyle = {
+    let kOptionsLabelStyle = {
       fontSize: 17,
       color: 'rgba(60, 60, 67, 0.6)',
-      ...optionsLabelStyle,
+      ...optionsLabelStyle
     }
-    return <Text style={kOptionsLabelStyle}>{item}</Text>
+
+    if(activeOptionsLabelStyle && selectedValues.some(i => item.id === i.id)){
+      kOptionsLabelStyle = {
+        fontSize: 17,
+        ...activeOptionsLabelStyle
+      }
+    }
+    return <Text style={kOptionsLabelStyle}>{item.item}</Text>
   }
 
   function renderItem({ item }) {
@@ -62,7 +70,7 @@ function SelectBox({
         {isMulti ? (
           <>
             <TouchableOpacity hitSlop={hitSlop} style={renderItemStyle} onPress={onPressMultiItem()}>
-              {renderLabel(item.item)}
+              {renderLabel(item)}
             </TouchableOpacity>
             <Toggle
               iconColor={toggleIconColor}
@@ -73,7 +81,7 @@ function SelectBox({
         ) : (
           <>
             <TouchableOpacity hitSlop={hitSlop} style={renderItemStyle} onPress={onPressItem()}>
-              {renderLabel(item.item)}
+              {renderLabel(item)}
               <View />
             </TouchableOpacity>
           </>
diff --git a/node_modules/react-native-multi-selectbox/src/.DS_Store b/node_modules/react-native-multi-selectbox/src/.DS_Store
new file mode 100644
index 0000000..659d42c
Binary files /dev/null and b/node_modules/react-native-multi-selectbox/src/.DS_Store differ

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant