Skip to content

Commit

Permalink
Merge pull request #2 from ArekChr/feat/extend_dont_transform_prop
Browse files Browse the repository at this point in the history
feat: Extend Disable Transformation property for Android
  • Loading branch information
cristipaval authored Mar 16, 2023
2 parents 9ab80fc + 2cc218a commit 2712377
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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));

Expand Down
8 changes: 7 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 2712377

Please sign in to comment.