Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Extend Disable Transformation property for Android #984

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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