Skip to content

Commit

Permalink
Set color filter so that the arrow matches the text color
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Emily Janzer authored and kelset committed Nov 27, 2020
1 parent f0b6eb7 commit 29972f9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/

* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/
package com.facebook.react.viewmanagers;

import android.view.View;
Expand All @@ -16,10 +15,14 @@
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class AndroidDropdownPickerManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & AndroidDropdownPickerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class AndroidDropdownPickerManagerDelegate<
T extends View,
U extends BaseViewManagerInterface<T> & AndroidDropdownPickerManagerInterface<T>>
extends BaseViewManagerDelegate<T, U> {
public AndroidDropdownPickerManagerDelegate(U viewManager) {
super(viewManager);
}

@Override
public void setProperty(T view, String propName, @Nullable Object value) {
switch (propName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.views.picker;

import android.widget.Spinner;
import androidx.annotation.NonNull;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewManagerDelegate;
Expand Down Expand Up @@ -41,4 +42,9 @@ protected ReactPicker createViewInstance(ThemedReactContext reactContext) {
protected ViewManagerDelegate<ReactPicker> getDelegate() {
return mDelegate;
}

@Override
public void setBackgroundColor(@NonNull ReactPicker view, int backgroundColor) {
view.setStagedBackgroundColor(backgroundColor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
package com.facebook.react.views.picker;

import android.content.Context;
import android.content.res.ColorStateList;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Spinner;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatSpinner;
import androidx.core.view.ViewCompat;
import com.facebook.react.common.annotations.VisibleForTesting;
import java.util.List;

Expand Down Expand Up @@ -173,6 +175,7 @@ public OnSelectListener getOnSelectListener() {
&& adapter != null
&& mStagedPrimaryTextColor != adapter.getPrimaryTextColor()) {
adapter.setPrimaryTextColor(mStagedPrimaryTextColor);
ViewCompat.setBackgroundTintList(this, ColorStateList.valueOf(mStagedPrimaryTextColor));
mStagedPrimaryTextColor = null;
}

Expand Down

0 comments on commit 29972f9

Please sign in to comment.