Skip to content

Slider's minimumTrackTintColor & maximumTrackTintColor props are reversed on Android #16672

@dekelev

Description

@dekelev

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
    OS: Windows 10
    Node: 6.11.4
    Yarn: 1.1.0
    npm: 4.6.1
    Android Studio: Android Studio 2.3.2, Build #AI-162.3934792

  Packages: (wanted => installed)
    react-native: 0.47.2 => 0.47.2
    react: 16.0.0-alpha.12 => 16.0.0-alpha.12

Steps to Reproduce

  1. Set minimumTrackTintColor & maximumTrackTintColor props on the Slider component
  2. Run on Android

Expected Behavior

minimumTrackTintColor should set the progress color while the maximumTrackTintColor should set the background color.

Actual Behavior

On Android, minimumTrackTintColor sets the background color while the maximumTrackTintColor sets the progress color.

From ReactSliderManager.java

@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);
    if (color == null) {
      background.clearColorFilter();
    } else {
      background.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);
    if (color == null) {
      progress.clearColorFilter();
    } else {
      progress.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    }
  }

Reproducible Demo

import { Slider } from 'react-native';
...
<Slider
        minimumTrackTintColor="white"
        maximumTrackTintColor="gray"
      />

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions