Material-components-ios: [TextFields] MDCTextInputControllerUnderline doesn't support theming

Created on 11 Dec 2019  路  4Comments  路  Source: material-components/material-components-ios

MDCTextInputControllerUnderline doesn't support theming via the applyThemeWithScheme: method. Since MDCTextFieldColorThemer has been removed from v96.0.0 onward, it renders the class broken.

While I have read the docs which discourage use of the MDCTextInputControllerUnderline style due to poor testing, as it's in use in existing projects we cannot use the recommended styles.

Please add theming to the MDCTextInputControllerUnderline class.


Internal data

[TextFields] Bug

Most helpful comment

After discussing with @randallli I opened #9371 to track writing the Theming Extension or removing the Underline controller.

All 4 comments

The title doesn't have a [Component] prefix.

Last compatible version seems to be 95.0.1, so I am stuck to that.

Hi @versoworks,

I think the underline style is considered a legacy style, and I think MDCTextInputControllerUnderline is considered a legacy class. I don't think writing a theming extension for it is a big priority for us right now.

Have you considered using the new TextControls component? It has a filled textfield class that can be configured to look like an underline textfield. See this gif:

underline

To achieve that behavior you would have to add something like this to your setup code:

[self.filledTextField setFilledBackgroundColor:[UIColor clearColor] forState:MDCTextControlStateNormal];
[self.filledTextField setFilledBackgroundColor:[UIColor clearColor] forState:MDCTextControlStateEditing];
[self.filledTextField setFilledBackgroundColor:[UIColor clearColor] forState:MDCTextControlStateDisabled];

I didn't do this for the gif, but if you want the underline color to be clear in all the non-editing states you could do this too:

[self.filledTextField setUnderlineColor:[UIColor clearColor] forState:MDCTextControlStateNormal];
[self.filledTextField setUnderlineColor:[UIColor clearColor] forState:MDCTextControlStateDisabled];

After discussing with @randallli I opened #9371 to track writing the Theming Extension or removing the Underline controller.

Was this page helpful?
0 / 5 - 0 ratings