From 2cc218a23f959eaa44d298fb836a6c1fee7c646b Mon Sep 17 00:00:00 2001 From: ArekChr Date: Tue, 14 Mar 2023 16:06:08 +0100 Subject: [PATCH] feat: extend disable transformation property --- .../com/dylanvann/fastimage/FastImageViewManager.java | 5 +++++ .../com/dylanvann/fastimage/FastImageViewWithUrl.java | 10 ++++++++++ src/index.tsx | 8 +++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java b/android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java index c7a795471..df739994d 100644 --- a/android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java +++ b/android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java @@ -61,6 +61,11 @@ public void setSource(FastImageViewWithUrl view, @Nullable ReadableMap source) { view.setSource(source); } + @ReactProp(name = "disableTransformation") + public void setDisableTransformation(FastImageViewWithUrl view, @Nullable Boolean disableTransformation) { + view.disableTransformation(disableTransformation); + } + @ReactProp(name = "defaultSource") public void setDefaultSource(FastImageViewWithUrl view, @Nullable String source) { view.setDefaultSource( diff --git a/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java b/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java index 34fcf898d..b098dcfee 100644 --- a/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java +++ b/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java @@ -30,6 +30,7 @@ class FastImageViewWithUrl extends AppCompatImageView { private boolean mNeedsReload = false; private ReadableMap mSource = null; private Drawable mDefaultSource = null; + private boolean mDisableTransformation = false; public GlideUrl glideUrl; @@ -42,6 +43,11 @@ public void setSource(@Nullable ReadableMap source) { mSource = source; } + public void disableTransformation(@Nullable boolean disableTransform) { + mNeedsReload = true; + mDisableTransformation = disableTransform; + } + public void setDefaultSource(@Nullable Drawable source) { mNeedsReload = true; mDefaultSource = source; @@ -144,6 +150,10 @@ public void onAfterUpdate( .placeholder(mDefaultSource) // show until loaded .fallback(mDefaultSource)); // null will not be treated as error + if (mDisableTransformation) { + builder = builder.dontTransform(); + } + if (key != null) builder.listener(new FastImageRequestListener(key)); diff --git a/src/index.tsx b/src/index.tsx index 478c629e9..018a7a65f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -116,9 +116,15 @@ export interface FastImageProps extends AccessibilityProps, ViewProps { * * If supplied, changes the color of all the non-transparent pixels to the given color. */ - tintColor?: ColorValue + /** + * If supplied, the original size of the resource without any transformations will be displayed. + * + * @platform android + */ + disableTransformation?: boolean + /** * A unique identifier for this element to be used in UI Automation testing scripts. */