Skip to content

Commit 2712377

Browse files
authored
Merge pull request #2 from ArekChr/feat/extend_dont_transform_prop
feat: Extend Disable Transformation property for Android
2 parents 9ab80fc + 2cc218a commit 2712377

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

android/src/main/java/com/dylanvann/fastimage/FastImageViewManager.java

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public void setSource(FastImageViewWithUrl view, @Nullable ReadableMap source) {
6161
view.setSource(source);
6262
}
6363

64+
@ReactProp(name = "disableTransformation")
65+
public void setDisableTransformation(FastImageViewWithUrl view, @Nullable Boolean disableTransformation) {
66+
view.disableTransformation(disableTransformation);
67+
}
68+
6469
@ReactProp(name = "defaultSource")
6570
public void setDefaultSource(FastImageViewWithUrl view, @Nullable String source) {
6671
view.setDefaultSource(

android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class FastImageViewWithUrl extends AppCompatImageView {
3030
private boolean mNeedsReload = false;
3131
private ReadableMap mSource = null;
3232
private Drawable mDefaultSource = null;
33+
private boolean mDisableTransformation = false;
3334

3435
public GlideUrl glideUrl;
3536

@@ -42,6 +43,11 @@ public void setSource(@Nullable ReadableMap source) {
4243
mSource = source;
4344
}
4445

46+
public void disableTransformation(@Nullable boolean disableTransform) {
47+
mNeedsReload = true;
48+
mDisableTransformation = disableTransform;
49+
}
50+
4551
public void setDefaultSource(@Nullable Drawable source) {
4652
mNeedsReload = true;
4753
mDefaultSource = source;
@@ -144,6 +150,10 @@ public void onAfterUpdate(
144150
.placeholder(mDefaultSource) // show until loaded
145151
.fallback(mDefaultSource)); // null will not be treated as error
146152

153+
if (mDisableTransformation) {
154+
builder = builder.dontTransform();
155+
}
156+
147157
if (key != null)
148158
builder.listener(new FastImageRequestListener(key));
149159

src/index.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ export interface FastImageProps extends AccessibilityProps, ViewProps {
116116
*
117117
* If supplied, changes the color of all the non-transparent pixels to the given color.
118118
*/
119-
120119
tintColor?: ColorValue
121120

121+
/**
122+
* If supplied, the original size of the resource without any transformations will be displayed.
123+
*
124+
* @platform android
125+
*/
126+
disableTransformation?: boolean
127+
122128
/**
123129
* A unique identifier for this element to be used in UI Automation testing scripts.
124130
*/

0 commit comments

Comments
 (0)