eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.
Apache License 2.0
119 stars 17 forks source link

Upgrade to MaterialComponents #64

Closed mtotschnig closed 3 years ago

mtotschnig commented 3 years ago

fixes #54

eltos commented 3 years ago

@mtotschnig

Thanks a lot for your PR.

While the style Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu that you propose does indeed not suffer from #54, it drastically changes the appearance and design.
I don't think we should make such a change in the default layout and design. Especially because putting the style into the layout xml file seems to prevents users from supplying their own textInputStyle via a custom theme.

My proposal is to instead change the values/styles.xml and use Widget.Design.TextInputLayout:

    <style name="SimpleDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
        <item name="textInputStyle">@style/Widget.Design.TextInputLayout</item>
    </style>

This style does not alter the input field appearance and also fixes #54. It would also allow users to overwrite the textInputStyle attribute and e.g. use the style you suggest. Together with #63 this should meet everyone's requirement.

Additionally, we could provide more than just one default style in the values/styles.xml:

    <!-- default style -->
    <style name="SimpleDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
        <item name="textInputStyle">@style/Widget.Design.TextInputLayout</item>
    </style>

    <!-- material design style -->
    <style name="SimpleDialogMaterialTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
        <item name="textInputStyle">@style/SimpleDialogMaterialTextInputStyle</item>
    </style>
    <style name="SimpleDialogMaterialTextInputStyle" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
        <item name="endIconMode">none</item>
    </style>

With this, users can quickly opt-in to the new style by adding just a single line to their AppTheme:

<item name="simpleDialogTheme">@style/SimpleDialogMaterialTheme</item>

Maybe for the next major version release we can change the default.

See 22594d44