Skip to content

Commit bb8d0f5

Browse files
Emily Janzerfacebook-github-bot
Emily Janzer
authored andcommitted
Set color filter so that the arrow matches the text color
Summary: We support setting the text color in the ReactPicker component, but we don't apply the text color to the little arrow icon that appears next to it. This diff applies the color tint from the picker's primary text color (set with a style prop on the main picker component, *not* the 'color' prop on the Picker.Item) to the background of the picker, which tints the arrow icon. Reviewed By: makovkastar Differential Revision: D24480642 fbshipit-source-id: 7ce84d616ae677da8975be9444428392020c57dc
1 parent 1e78e06 commit bb8d0f5

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

ReactAndroid/src/main/java/com/facebook/react/viewmanagers/AndroidDropdownPickerManagerDelegate.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/**
2-
* Copyright (c) Facebook, Inc. and its affiliates.
3-
*
4-
* This source code is licensed under the MIT license found in the
5-
* LICENSE file in the root directory of this source tree.
6-
*
7-
* @generated by codegen project: GeneratePropsJavaDelegate.js
8-
*/
9-
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5+
* directory of this source tree.
6+
*
7+
* @generated by codegen project: GeneratePropsJavaDelegate.js
8+
*/
109
package com.facebook.react.viewmanagers;
1110

1211
import android.view.View;
@@ -16,10 +15,14 @@
1615
import com.facebook.react.uimanager.BaseViewManagerInterface;
1716
import com.facebook.react.uimanager.LayoutShadowNode;
1817

19-
public class AndroidDropdownPickerManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & AndroidDropdownPickerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
18+
public class AndroidDropdownPickerManagerDelegate<
19+
T extends View,
20+
U extends BaseViewManagerInterface<T> & AndroidDropdownPickerManagerInterface<T>>
21+
extends BaseViewManagerDelegate<T, U> {
2022
public AndroidDropdownPickerManagerDelegate(U viewManager) {
2123
super(viewManager);
2224
}
25+
2326
@Override
2427
public void setProperty(T view, String propName, @Nullable Object value) {
2528
switch (propName) {

ReactAndroid/src/main/java/com/facebook/react/views/picker/ReactDropdownPickerManager.java

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package com.facebook.react.views.picker;
99

1010
import android.widget.Spinner;
11+
import androidx.annotation.NonNull;
1112
import com.facebook.react.module.annotations.ReactModule;
1213
import com.facebook.react.uimanager.ThemedReactContext;
1314
import com.facebook.react.uimanager.ViewManagerDelegate;
@@ -41,4 +42,9 @@ protected ReactPicker createViewInstance(ThemedReactContext reactContext) {
4142
protected ViewManagerDelegate<ReactPicker> getDelegate() {
4243
return mDelegate;
4344
}
45+
46+
@Override
47+
public void setBackgroundColor(@NonNull ReactPicker view, int backgroundColor) {
48+
view.setStagedBackgroundColor(backgroundColor);
49+
}
4450
}

ReactAndroid/src/main/java/com/facebook/react/views/picker/ReactPicker.java

+3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
package com.facebook.react.views.picker;
99

1010
import android.content.Context;
11+
import android.content.res.ColorStateList;
1112
import android.util.AttributeSet;
1213
import android.view.View;
1314
import android.widget.AdapterView;
1415
import android.widget.Spinner;
1516
import androidx.annotation.Nullable;
1617
import androidx.appcompat.widget.AppCompatSpinner;
18+
import androidx.core.view.ViewCompat;
1719
import com.facebook.react.common.annotations.VisibleForTesting;
1820
import java.util.List;
1921

@@ -173,6 +175,7 @@ public OnSelectListener getOnSelectListener() {
173175
&& adapter != null
174176
&& mStagedPrimaryTextColor != adapter.getPrimaryTextColor()) {
175177
adapter.setPrimaryTextColor(mStagedPrimaryTextColor);
178+
ViewCompat.setBackgroundTintList(this, ColorStateList.valueOf(mStagedPrimaryTextColor));
176179
mStagedPrimaryTextColor = null;
177180
}
178181

0 commit comments

Comments
 (0)