litho icon indicating copy to clipboard operation
litho copied to clipboard

Automirrored vector drawables do not get mirrored when layout is RTL

Open Fs00 opened this issue 3 years ago • 2 comments

Version

Excerpt of my app's build.gradle file:

implementation "com.facebook.litho:litho-core:0.41.2"
implementation "com.facebook.litho:litho-widget:0.41.2"
kapt "com.facebook.litho:litho-processor:0.41.2"

Issues and Steps to Reproduce

It seems that the Litho Image component does not honor the autoMirrored attribute on vector drawables when rendering, which results in drawables not getting mirrored when layout direction is RTL (I've reproduced it by forcing RTL layout in Android developer settings -> Force RTL layout direction).

Expected Behavior

The automirrored vector drawable should be mirrored when using an RTL language or when forcing RTL layout via Android developer settings.

Code

Minimal component that can be used to reproduce the issue:

@LayoutSpec
public class PlaygroundComponentSpec {
  @OnCreateLayout
  static Component onCreateLayout(ComponentContext c) {
      return Column.create(context)
        .backgroundColor(Color.BLACK)
        .child(Image.create(context).drawableRes(R.drawable.ic_back).build())
        .build()
  }
}

The automirrored vector drawable referenced by the component (placed in res/drawable/ic_back.xml):

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24"
    android:autoMirrored="true">
  <path
      android:fillColor="@android:color/white"
      android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

Fs00 avatar Jun 21 '22 16:06 Fs00

Hey @Fs00, thanks for the report and simple repro. I'll put this on our backlog, however we would also take a PR if you're interested in tackling it yourself.

astreet avatar Jun 21 '22 17:06 astreet

Thanks for the quick answer! I don't have enough time and motivation to go ahead and open a PR these days, feel free to start working on it 🙂

Fs00 avatar Jun 21 '22 19:06 Fs00