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

fix(android): fix Android FAB tintColor #13972

Merged
merged 2 commits into from
Feb 11, 2024
Merged
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 @@ -7,6 +7,7 @@
package ti.modules.titanium.ui.widget;

import android.content.res.ColorStateList;
import android.graphics.PorterDuff;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

Expand Down Expand Up @@ -54,6 +55,9 @@ public void processProperties(KrollDict d)
if (d.containsKey("maxImageSize")) {
setMaxImageSize(TiConvert.toInt(d.get("maxImageSize")));
}
if (d.containsKey(TiC.PROPERTY_TINT_COLOR)) {
setTintColor(d.getString("tintColor"));
m1ga marked this conversation as resolved.
Show resolved Hide resolved
}
if (d.containsKeyAndNotNull(TiC.PROPERTY_TOUCH_FEEDBACK_COLOR)) {
ColorStateList colorStateList = null;
colorStateList = ColorStateList.valueOf(
Expand Down Expand Up @@ -91,6 +95,12 @@ private void setImage(Object obj)
}
}

public void setTintColor(String color)
{
int tintColor = TiConvert.toColor(color, TiApplication.getAppCurrentActivity());
fab.setColorFilter(tintColor, PorterDuff.Mode.SRC_IN);
}

@Override
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy)
{
Expand All @@ -106,6 +116,8 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
ColorStateList colorStateList = null;
colorStateList = ColorStateList.valueOf(TiConvert.toColor(newValue, proxy.getActivity()));
fab.setRippleColor(colorStateList);
} else if (key.equals(TiC.PROPERTY_TINT_COLOR)) {
setTintColor(TiConvert.toString(newValue));
}
}
}
2 changes: 1 addition & 1 deletion apidoc/Titanium/UI/Android/FloatingActionButton.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ excludes:
backgroundImage, backgroundLeftCap, backgroundRepeat, backgroundSelectedColor,
backgroundSelectedImage, backgroundTopCap, borderColor, borderRadius, borderWidth, center,
children, clipMode, focusable, height, horizontalWrap, keepScreenOn, layout, opacity, overrideCurrentAnimation,
pullBackgroundColor, rect, size, softKeyboardOnFocus, tintColor, touchEnabled, touchFeedback, transform,
pullBackgroundColor, rect, size, softKeyboardOnFocus, touchEnabled, touchFeedback, transform,
viewShadowColor, viewShadowOffset, viewShadowRadius, width, zIndex]

events:
Expand Down
Loading