MaterialLogin icon indicating copy to clipboard operation
MaterialLogin copied to clipboard

Colors in attrs.xml too

Open StefMa opened this issue 9 years ago • 3 comments

I'm very confused why the colors are handled over the colors.xml file instead like the texts via the attributes file?

We can set it up like this too:

    <declare-styleable name="MaterialLoginView">
        <attr name="loginTitle" format="string" />
        <attr name="loginHint" format="string" />
        <attr name="loginPasswordHint" format="string" />
        <attr name="loginActionText" format="string" />
        <attr name="loginTextColor" format="reference" />

        <attr name="registerTitle" format="string" />
        <attr name="registerHint" format="string" />
        <attr name="registerPasswordHint" format="string" />
        <attr name="registerRepeatPasswordHint" format="string" />
        <attr name="registerActionText" format="string" />
        <attr name="registerTextColor" format="reference" />
        <attr name="registerIcon" format="reference" />
    </declare-styleable>

and use it like

        app:loginTextColor="@color/material_login_register_color"

Any opinion not to do this?

StefMa avatar Jan 27 '16 07:01 StefMa

Great question, I've struggling it for a few hours how to do it right, even ask on SO.

I can't just pass the color as an attribute to the view because this color is showing up in a couple of places, for example- the "login" color is in the view background, in the text style and in the login button background drawable, so I preferred putting it all in the xml's and not in code (and there are some things that I can event not set up in code, like the hint text style)

shem8 avatar Jan 27 '16 08:01 shem8

Ok, all right :point_up_2: But would it be better when we create a style like MaterialLoginThemeLight.ColorScheme and MaterialLoginThemeDark.ColorScheme to override the colors in styles.xml?

StefMa avatar Jan 28 '16 07:01 StefMa

So the user will be able to inheritance from those styles? If so- we'll need to create also LightDarkActionBar or more for some custom styles, am I right? Isn't it better just use the color like we do now?

shem8 avatar Jan 28 '16 08:01 shem8