2 Commits

Author SHA1 Message Date
Andrew Overton
41428ef329
[TextFields] Updates to MDCContainedInputView and SimpleTextField (#6904)
* Refactor simple text field manual layout example code

* Make clear button layout calculation more understandable

* Have density informer protocol provide floating font scale factor instead of floating font size

* Send editingChanged event when clearing text

* Extract some placeholder management into a common object

* Run clang format

* Add WIP fancy animations to filled style

* In the middle of dealing with vertical density

* ITF vertical density is in a good place at the expense of ICV vertical density

* Run clang format

* Update input chip view density and example

* Add dynamic type support

* Ran clang format

* remove dead code

* Add a density informer method for the padding around the toprow/bottomrow divider

* Refactor placeholder animation code

* Ran clang format

* Refactor some placeholder layout logic

* Add nullability annotations

* Add missing nullability annotation

* Get rid of framework import for now

* Cast CAAnimation to CABasicAnimation

* Rename containerRect to containerFrame

* A bunch of property, class, and file renamings

* beginning to split floating label and placeholder. also some renamings

* Ran clang format

* More renamings

* More renamings

* Ran clang format

* A ton of renamings, some of which may need a second look ...

* More work separating floating label and placeholder

* Ran clang format

* About to make placeholder a UILabel again :(

* Placeholder and floating label are behaving pretty well together

* Fix placeholder appearance in text field

* Get rid of unneeded method

* Added some docs and got rid of the density informer method for bottom padding

* Get rid of some dead code

* Ran clang format

* Add nullability annotation

* Add CGFloat cast

* Renamed some things

* Positioning delegates no longer inherit from a root class, and they are passed into style object initializers
2019-04-11 15:12:30 -04:00
Andrew Overton
1d7fedd32d
[TextFields] Updates to SimpleTextFIeld and InputChipView prototype (#6647)
[TextFields] Updates to SimpleTextFIeld and InputChipView prototype

This PR contains a lot of updates to SimpleTextField. Some of these updates are for little things I noticed I got wrong after looking at the guidelines a bit more. The more substantial changes introduced here, however, are related to feedback given in the design doc overview meeting in January. As a reminder, the two takeaways from that meeting were:

1. SimpleTextField shouldn't depend on MDCContainerScheme
2. The styles should not be represented as enum cases. Instead, they should be objects.

These changes address those pieces of feedback. While I still need to get around to updating the design doc to reflect the changes, I don't see the harm in merging the updates into their home in a MaterialComponentsExamples experimental directory.

This PR also contains changes that are not directly related to SimpleTextField!

Late last year, when we had the week of free time to do whatever we wanted, I began thinking about incorporating chips into SimpleTextFields. Not far into it I decided that any view implementing input chip functionality should be its own view, i.e. it shouldn't be stuffed in a UITextField, which carries inheritance-related burden. I started work on such a view in January, and briefly used it during the SimpleTextField design doc overview meeting to demonstrate how SimpleTextField styling could be generalized across views.

Following that meeting, and following the refactoring work to address feedback on SimpleTextFields, I updated the InputChipView to see how extensible my "container style as object" approach was. I think the work here, while definitely not a finished product, demonstrates that it's fairly usable. MDCSimpleTextField (I added an MDC) and InputChipView (no MDC) both conform to a protocol called MDCContainedInputView. That protocol declares a property for objects conforming to MDCContainerStyling. There are a few other classes and protocols in there, but I will write or talk more about those in a different setting. The key here is that I think it all might work, based off these changes. There are still some loose ends, but they can be taken care of. They _will_ be taken care of if the team decides to take this direction. They maybe won't if we decide to continue investing in MDCTextFields for all of our user input needs. If we do end up deciding to bring all this into the codebase I want the next addition to this family of contained input views to be a subclass of UITextView, for multiline text input.

This gif shows the updated MDCSimpleTextField styled as an "outlined" text field:
![stf_outlined_2](https://user-images.githubusercontent.com/8020010/53023951-2a09c700-342c-11e9-88df-9605d652c46c.gif)
This gif shows the updated MDCSimpleTextField styled as a "filled" text field:
![stf_filled_2](https://user-images.githubusercontent.com/8020010/53023948-29713080-342c-11e9-9581-8891fa090ec1.gif)
This gif shows the updated InputChipView styled as an "outlined" input chip view whose chips do not wrap:
![outlined_non_wrapping_2](https://user-images.githubusercontent.com/8020010/53023945-28d89a00-342c-11e9-9138-c63ff1a4c3ea.gif)

This gif shows the updated InputChipView styled as an "outlined" input chip view whose chips wrap:
![outlined_wrapping_2](https://user-images.githubusercontent.com/8020010/53023944-28d89a00-342c-11e9-8e9d-ec185bcdf468.gif)
This gif shows the updated InputChipView styled as a "filled" input chip view whose chips do not wrap:
![filled_non_wrapping_2](https://user-images.githubusercontent.com/8020010/53023946-28d89a00-342c-11e9-9a4c-1fb5e87673e9.gif)
This gif shows the updated InputChipView styled as a "filled" input chip view whose chips wrap:
![filled_wrapping_2](https://user-images.githubusercontent.com/8020010/53023947-29713080-342c-11e9-98d2-3fe2f971d878.gif)
2019-02-20 09:47:42 -05:00