Permalink
Browse files

Fix slider colors in Android

Summary:
Hey !

I noticed that the `minimumTrackTintColor` and `maximumTrackTintColor` are exchanged in iOS and Android.
In iOS, `minimumTrackTintColor` is the left color and `maximumTrackTintColor` is the right color.
In Android, `minimumTrackTintColor` is the right color and `maximumTrackTintColor` is the left color.

With this code :
```jsx
<Slider
  style={{ width: 300 }}
  minimumTrackTintColor="red"
  maximumTrackTintColor="blue"
/>
```

|iOS|Android|
|----|----|
|![image](https://user-images.githubusercontent.com/17292331/30700555-2b8ae828-9ee8-11e7-94a3-f1d3adee7fd5.png)|![screenshot_2017-09-21-15-59-59](https://user-images.githubusercontent.com/17292331/30699855-246c1280-9ee6-11e7-9653-e61c4798a50f.png)|

|iOS|Android|
|----|----|
|![image](https://user-images.githubusercontent.com/17292331/30700563-2fc8c25c-9ee8-11e7-9c0d-955d9921660f.png) (same)|![screenshot_2017-09-21-16-12-04](https://user-images.githubusercontent.com/17292331/30700418-def3e136-9ee7-11e7-982b-48aeba23a5ea.png)|
Closes #16053

Differential Revision: D5910299

Pulled By: shergin

fbshipit-source-id: 74851e4cc6d54f72ea2755200e26b0d921890b48
  • Loading branch information...
martinezguillaume authored and facebook-github-bot committed Sep 26, 2017
1 parent 9796295 commit 31904d523dbe79a8a4a37690cd821b3ec21e16b0
@@ -160,22 +160,22 @@ public void setThumbTintColor(ReactSlider view, Integer color) {
@ReactProp(name = "minimumTrackTintColor", customType = "Color")
public void setMinimumTrackTintColor(ReactSlider view, Integer color) {
LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent();
Drawable background = drawable.findDrawableByLayerId(android.R.id.background);
Drawable progress = drawable.findDrawableByLayerId(android.R.id.progress);
if (color == null) {
background.clearColorFilter();
progress.clearColorFilter();
} else {
background.setColorFilter(color, PorterDuff.Mode.SRC_IN);
progress.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
}
@ReactProp(name = "maximumTrackTintColor", customType = "Color")
public void setMaximumTrackTintColor(ReactSlider view, Integer color) {
LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent();
Drawable progress = drawable.findDrawableByLayerId(android.R.id.progress);
Drawable background = drawable.findDrawableByLayerId(android.R.id.background);
if (color == null) {
progress.clearColorFilter();
background.clearColorFilter();
} else {
progress.setColorFilter(color, PorterDuff.Mode.SRC_IN);
background.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
}

0 comments on commit 31904d5

Please sign in to comment.