Skip to content

[FloatingActionButton] Fix labelOpacity property #4594

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pubiqq
Copy link
Contributor

@pubiqq pubiqq commented Feb 10, 2025

This PR:

  • Fixes an incorrect implementation of the Property#get(Object) method of the labelOpacity property:

    Before:

    @Override
    public Float get(ExtendedFloatingActionButton object) {
        int originalOpacity = Color.alpha(<original text color>);
        float currentOpacity = Color.alpha(<current text color>) / 255F;  // <-
        return lerp(0F, 1F, currentOpacity / originalOpacity);
    }

    After:

    @Override
    public Float get(ExtendedFloatingActionButton object) {
        int originalOpacity = Color.alpha(<original text color>);
        float currentOpacity = Color.alpha(<current text color>);  // <-
        return lerp(0F, 1F, currentOpacity / originalOpacity);
    }
  • Simplifies the calculation of the target color in the Property#set(Object, Object) method. In particular, it eliminates unnecessary blah-blah / 255F * 255, which only result in a loss of accuracy.

  • Avoids calculating the target color when it's not needed.

@kendrickumstattd kendrickumstattd self-assigned this Feb 18, 2025
@kendrickumstattd
Copy link
Contributor

Hey, there! Thanks for the PR. Could you provide some more context on how this fixes labelOpacity, including screenshots? Thanks.

@pubiqq pubiqq mentioned this pull request Nov 11, 2024
@pubiqq pubiqq force-pushed the fab/fix-label-opacity-property branch from c199701 to f3ae9c5 Compare May 12, 2025 20:34
@kendrickumstattd
Copy link
Contributor

Happy to review this! Thanks for sending in the change. Could you include a description of how this fixes labelOpacity, including screenshots? Cheers!

@pubiqq
Copy link
Contributor Author

pubiqq commented May 27, 2025

Sure, I've added a description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants