gwt-material icon indicating copy to clipboard operation
gwt-material copied to clipboard

MaterialIcon and IconType usage/purpose inconsistency.

Open masterdany88 opened this issue 8 years ago • 4 comments

I am creating a button like follow:

        final List<MaterialAnchorButton> buttons = new LinkedList<>();

        final MaterialIcon icon = new MaterialIcon();
        icon.setIconType(IconType.HOME);
        final MaterialAnchorButton addb = new MaterialAnchorButton(ButtonType.FLOATING, "D1", icon);
        addb.setBackgroundColor("red");

        buttons.add(addb);

and then I am adding it to MaterialFABList like follow

    @UiField
    MaterialAnchorButton mainButton;
    @UiField
    MaterialFABList additionalButtons;

for (final MaterialAnchorButton b : buttons) {
            if (b.equals(buttons.get(0))) {
                mainButton.setIconType(b.getIcon().getIconType());
                mainButton.setBackgroundColor(b.getBackgroundColor());
                mainButton.setText(b.getText());
            } else {
                b.setSize(ButtonSize.MEDIUM);
                b.setWaves(WavesType.LIGHT);
                b.setType(ButtonType.FLOATING);
                b.setIconType(b.getIcon().getIconType());
                b.setBackgroundColor("blue");
                additionalButtons.add(b);
            }
        }

To have programatically set buttons on fab. Problem is in those 2 lines:

mainButton.setIconType(b.getIcon().getIconType());
                 b.setIconType(b.getIcon().getIconType());

those 2 lines shouldn't be needed, cause Icon have been already set in first code snippet above. When I delete them the result is: image but the result should be: image

For sure there is some inconsistency in code/return types of getters I think.

masterdany88 avatar Jun 24 '16 10:06 masterdany88

I've noticed that AbstractIconButton has parameter icon private MaterialIcon icon = new MaterialIcon(); and also implements interfejs HasIcon:

public abstract class AbstractIconButton extends AbstractButton implements HasIcon {

which has methods:

    /**
     * Get the icon widget.
     */
    MaterialIcon getIcon();

    /**
     * Set Material Design icon.
     * {@link https://www.google.com/design/icons/}
     */
    void setIconType(IconType iconType);

In MaterialAnchorButton class we have setter for IconType, but no for MaterialIcon, and In MaterialAnchorButton class we have getter for MaterialIcon, but no for IconType In MaterialAnchorButton class we have constructor with MaterialIcon, but no for IconType.

Which cause that we have 2 separate Icon reference, which cause inconsistency in when and which one use. It have to be simplified.

        MaterialIcon i = new MaterialIcon();
        i.setIconType(IconType.AC_UNIT);
        MaterialAnchorButton a = new MaterialAnchorButton("TEST",i);
        a.getIcon().getIconType(); // will return IconType.AC_UNIT
        a.setIconType(IconType.ACCESS_ALARM);

In this code I've set 2 different icon types for one button.

We have to use only one parameter, IconType enum, or whole MaterialIcon object, and it should be done for whole gwt-materials.

masterdany88 avatar Jun 24 '16 10:06 masterdany88

I think the simplest will be use only of enum IconType and widget should internally create MaterialIcon. MaterialIcon should be completely hidden for end user. End user should only use IconType, IconPosition, IconColor etc. I think.

masterdany88 avatar Jun 24 '16 10:06 masterdany88

Giving access to the actual MaterialIcon is important to retain. There should also be methods for icon position and color available if I remember correctly.

BenDol avatar Jun 24 '16 11:06 BenDol

It is hard to speculate, cause this issue affect a lot of widgets. But it have to be standardized across whole sources.

masterdany88 avatar Jun 24 '16 11:06 masterdany88