Skip to content

Commit

Permalink
fix(android): fix Android FAB tintColor
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Jan 22, 2024
1 parent 87a105a commit 7a78a09
Showing 1 changed file with 12 additions and 0 deletions.
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"));
}
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));
}
}
}

0 comments on commit 7a78a09

Please sign in to comment.