272 Commits

Author SHA1 Message Date
Andrew Overton
a29eb2c3c7 [TextFields] Deprecate MDCTextField and its associated classes/protocols
PiperOrigin-RevId: 360449716
2021-03-02 09:48:45 -08:00
Jeff Verkoeyen
2a8a6ac1c9 Optimizing imports
PiperOrigin-RevId: 357185734
2021-02-12 07:31:35 -08:00
Jeff Verkoeyen
c53f44398e Optimizing imports
PiperOrigin-RevId: 357185618
2021-02-12 07:29:28 -08:00
Jeff Verkoeyen
09a07ca6d2 Internal change
PiperOrigin-RevId: 333130898
2020-09-22 12:11:00 -07:00
Nobody
b3a632da46 Updates MDCMultilineTextField to better support being embedded in self-sizing cells.
PiperOrigin-RevId: 318269826
2020-06-25 07:49:40 -07:00
Nobody
e214be3b2d Updates MDCMultilineTextField's bottom textfield constraint to use the textInsets as the constant.
This brings parallels the calculation done in sizeThatFits and will ensure the set textInsets are always adhered to.

PiperOrigin-RevId: 318268981
2020-06-25 07:42:40 -07:00
Bryan Oltman
d4880b4600 [TextFields] Return the empty string instead of nil in MDCTextField's accessibilityValue method to avoid VoiceOver defaulting to [super accessibilityValue].
PiperOrigin-RevId: 316103878
2020-06-12 07:55:20 -07:00
Nobody
fb10ae1b1f Add borderRadius property
PiperOrigin-RevId: 309425430
2020-05-01 10:04:46 -07:00
Wenyu Zhang
81bd1dd07f Internal change.
PiperOrigin-RevId: 309284703
2020-04-30 13:09:22 -07:00
Dave MacLachlan
ebac2a8eb7 As of iOS 9/macOS 10.11 (circa 2015) removing objective C objects from the NSNotificationCenter in - (void)dealloc. is no longer required (the classic example is: [[NSNotificationCenter defaultCenter] removeObserver:self] but there are several variations).
In many cases this is the only thing being done in - (void)dealloc, so we can remove the whole thing.

PiperOrigin-RevId: 307663440
2020-04-21 13:00:30 -07:00
Bryan Oltman
cc3fa165b8 [TextFields] Move protocol definitions into separate header files
PiperOrigin-RevId: 302059436
2020-03-20 11:00:42 -07:00
featherless
057bfd0b95
[TextFields] Lower the error VoiceOver announcement delay to near zero. (#9822)
Prior to this change, error VoiceOver announcements would be initiated half a second after the error state was set, potentially resulting in about half a second of other VoiceOver notifications being announced before being interrupted by the error announcement.

The error announcement is intended to take precedent over the other informative announcements (such as character counts). Unfortunately, the error state is often set before the internal textInputDidChange: event which means that if we fire the error announcement immediately, then the error announcement will be cut off by the textInputDidChange: announcement for character counts. To combat this, https://github.com/material-components/material-components-ios/pull/7256 had introduced a dispatch_after to kick off the error event half a second later.

To address the first problem without breaking the second, this change reduces the delay of the error announcement to 0.05 seconds, a window of time small enough to avoid hearing any of the character count announcement, but large enough to happen after the character count announcement is posted, resulting in the error announcement being the one that is read out.

Closes https://github.com/material-components/material-components-ios/issues/7625
2020-03-03 10:30:42 -05:00
Bryan Oltman
d83af534c3
[TextFields] implement resignFirstResponder in MDCMultilineTextField (#9793) 2020-02-25 16:17:19 -05:00
Bryan Oltman
86b4fbcb2c
[TextFields] Delete deprecated MDCTextFieldTypographyThemer (#9689)
MDCTextFieldTypographyThemer is deprecated and has no internal usage.

Fixes #9661
2020-02-11 18:22:22 -05:00
Cody Weaver
6c2b38e46f [TextFields] Use correct localization API.
We were using the `NSLocalizedStringWithDefaultValue` API which is supposed to be used with the `genstrings` tool. This updates us to use the correct API which is `localizedStringForKey:value:table:`.

For more context on the `genstrings` tool see: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html.

Closes #5616

PiperOrigin-RevId: 292469399
2020-01-30 19:09:59 -08:00
Cody Weaver
7dbd3e0ef5 [TextFields] Add localized clear text string for multiline text field.
PiperOrigin-RevId: 292146071
2020-01-29 08:25:20 -08:00
Andrew Overton
7a48d3997f
[TextFields] Add identity check in -setTextColor: in MDCTextField (#9480)
This PR adds an identity check in `-setTextColor:` in MDCTextField. This identity check short circuits an infinite loop triggered by `-setTextColor:` under certain mysterious circumstances involving the MDCTextField layout pass and MDCFlexibleHeaderView KVO stuff surrounding safeAreaInset changes. I don't fully understand what's going on tbh :)

The internal bug ([b/148159587](http://b/148159587)) has links to before and after gifs in the comments.

Closes #9470

### Update: The internal client who reported the bug was unable to reproduce it with these changes.
2020-01-24 12:58:43 -05:00
Andrew Overton
b28e09d345
[TextFields] MDCTextInputControllerOutlinedTextArea border width fix (#9454)
This PR includes the changes from @istvanp's https://github.com/material-components/material-components-ios/pull/7588 with updates to the screenshot goldens. Original PR description from https://github.com/material-components/material-components-ios/pull/7588:

Fixes border width not changing to 2 points wide when editing field (issue #7587)

## Screenshots
**Tested Device:** iPhone 6, iOS 12.3.1
### Before
[Editing](https://user-images.githubusercontent.com/179335/59697846-8f907900-91bc-11e9-9eb9-46601ecfbfe9.PNG)
[Not Editing](https://user-images.githubusercontent.com/179335/59697849-8f907900-91bc-11e9-9f94-18e84ea76d64.PNG)

### After
[Editing](https://user-images.githubusercontent.com/179335/59698057-e5fdb780-91bc-11e9-99bd-5a921c78a442.PNG)
2020-01-21 16:44:19 -05:00
Cody Weaver
3b3d288ea4
[TextFields] Add theming extension for underline controller (#9437)
In #9109  we removed the color themer for the underline controller. This change closes #9371  which will allow clients to theme their underline controller text fields via a theming extension. This change will theme both color and typography.

*Note* [Material](material.io) recommends using a [filled or outlined text field](https://material.io/components/text-fields/).

| Resting | Active |
| --- | --- |
|![Simulator Screen Shot - iPhone 8 Plus - 2020-01-16 at 13 13 28](https://user-images.githubusercontent.com/7131294/72563237-1811ed80-3862-11ea-8788-816c927f03e4.png)|![Simulator Screen Shot - iPhone 8 Plus - 2020-01-16 at 13 13 26](https://user-images.githubusercontent.com/7131294/72563252-1cd6a180-3862-11ea-97c9-6d7c82f6878d.png)|

Closes #9371 
Closes #9242
2020-01-16 14:20:09 -08:00
Andrew Overton
703589b3eb
[TextFields] Give MDCTextField clear button proper hit area insets (#8790)
This PR makes the MDCTextField clear button always meet the minimum touch target.

Closes #5373.
2020-01-02 08:31:46 -05:00
Andrew Overton
f8d9897aac
Removes requirement that the textView delegate be set when informing layout delegate of a size change (#9337)
This PR contains the changes from #9263. CI didn't seem to be working on the original PR so I just copied the changes here.
2019-12-23 16:32:40 -05:00
Andrew Overton
f4ec87ac39
Ensures that constraints used for the trailing view are properly removed when a new trailing view is set (#9336)
This PR contains the changes from #9258. CI didn't seem to be working on the original PR, and then it got messy as a result of bad merges, so I just copied the changes here.
2019-12-23 16:32:21 -05:00
Andrew Overton
8a510746f6
Delete MDCOutlinedTextFieldColorThemer (#9274)
BUILD and Podspec changes coming with the deletion of MDCFilledTextFieldColorThemer.

Closes #9080.
2019-12-16 09:51:34 -05:00
Andrew Overton
df1ac34ea1
Delete MDCTextFieldFontThemer (#9226)
Delete MDCTextFieldFontThemer. Closes #9086.
2019-12-10 12:32:48 -05:00
Andrew Overton
747844b4bb
deprecate-MDCOutlinedTextFieldColorThemer (#9215)
Related to #9080, should be merged after #9214.
2019-12-10 11:56:47 -05:00
Andrew Overton
63a7c6f3f6
[TextFields] Update MDCTextInputControllerOutlined theming extension to not use color themer (#9223)
Related to #9080
2019-12-10 11:04:47 -05:00
Andrew Overton
4b450aecc3
Deprecate MDCTypographyThemer (#9175)
Related to #9176
2019-12-10 10:51:09 -05:00
Andrew Overton
4c75e862d4
[TextFields] Don't use MDCTextFieldTypographyThemer (#9170)
Related to #9168
2019-12-09 10:13:34 -05:00
Andrew Overton
6d2bfc4e3b
[TextFields] Deprecate MDCTextFieldFontThemer (#9169)
Related to #9168
2019-12-08 22:41:54 -05:00
Bryan Oltman
87b9dd5a7d
[TextFields] Delete MDCTextFieldColorThemer (#9109)
Fixes #9083 
Fixes #9084
Fixes #9085
Fixes #9112
2019-12-05 16:38:39 -05:00
Bryan Oltman
9adc054ce0
[TextFields] Mark MDCTextFieldColorThemer as deprecated (#9076) 2019-12-04 20:35:45 -05:00
Wenyu Zhang
593cf1e621 Revert "[TextFields] Check if placeholder is hidden before verbalizing it in voice over. (#8804)"
This reverts commit f9c17caf1bffd8e4538ee2c587d780e55437243c.
2019-11-22 10:56:15 -05:00
Wenyu Zhang
39fe0f89f1 Revert "[TextFields] Correction to the accessibility label (#8976)"
This reverts commit c498516b358998c9853e9934df9b643d4256b9da.
2019-11-22 10:51:57 -05:00
Randall Li
c498516b35
[TextFields] Correction to the accessibility label (#8976)
UITextField verbalizes the placeholder in a lower pitch when no text has been entered. This change incorporates this behavior into what values get added to the MDCTextField's accessibilityLabel.

Before after videos:
[singleFix.zip](https://github.com/material-components/material-components-ios/files/3853326/singleFix.zip)


QA=Notice that "state" is verbalized when it is not visible on screen in the after.
more info at #7513
2019-11-15 22:41:01 -05:00
Randall Li
1c17792b36
[MDCTextfields] Added accessibility label tests for MDCMultilineTextFields (#8902)
Copied the logic from the single line textfield. over to the multiline one.

part of https://github.com/material-components/material-components-ios/issues/7513
2019-11-15 13:24:54 -05:00
Randall Li
f9c17caf1b
[TextFields] Check if placeholder is hidden before verbalizing it in voice over. (#8804)
[TextFields] Add check for placeholder before adding to the accessibility strings spoken by voice over.

Also added changed example to remove the floating label so that we can check that voice over correctly verbalizes only the visible text.

Before and After zip:
[BeforeAfterVideos.zip](https://github.com/material-components/material-components-ios/files/3843558/BeforeAfterVideos.zip)

QA=Notice that "state" is verbalized when it is not visible on screen in the after.
more info at #7513
2019-11-15 12:21:40 -05:00
Randall Li
3c0d7953ad [TextFields] Added header comment: placeholder APIs are for label text (#8803)
Added header comment clarifying that the placeholder APIs are really for label text and not placeholder.

more info at #7513
2019-11-15 07:32:17 -08:00
Bryan Oltman
42e220d9c1
[TextFields] Convert clear button to MDCButton (#8784)
* [TextFields] Convert clear button to MDCButton

* Add buttons to build file

* Build file update

* Update build file again

* [Dialogs] Set dialog message accessibilityFrame based on visible message text

* Revert "[Dialogs] Set dialog message accessibilityFrame based on visible message text"

This reverts commit ae6154ed8b2df5a3ad73ad2e7923ed404297f821.

* Add snapshot test for clear button ripple

* Add ripple snapshot goldens

* Remove unnecessary cornerRadius setting

* Cast clear button ink color alpha to CGFloat

* Add Button and Ripple dependencies to snapshot tests

* PR feedback

* clang

* Fix imports
2019-11-13 10:11:27 -05:00
Bryan Oltman
118dfa3d58
[TextFields] Update character count announcement in MDCTextInputControllerFullWidth (#8789) 2019-11-12 17:02:45 -05:00
Bryan Oltman
be03cec767
[TextFields] Update announcement text for fields with a character limit (#8777) 2019-11-12 14:13:07 -05:00
Andrew Overton
02f9c9f01d
Move new TextFields into TextControls directory (#8726)
In this PR I extract the new TextFields from the old TextFields directory. In the future, if we bring over the input chip view and text area, they will go under this new TextControls directory as well.

Closes #8684.
2019-11-07 14:17:56 -05:00
Andrew Overton
dec1670f8b
[TextFields] Capture snapshots outside of view (#8718)
This PR makes it so that textcontrol snapshot test cases validate UIView snapshots of text controls inside container views as opposed to validating just UIView snapshots of text controls themselves. This is so that when floating labels go outside the bounds, as they partially do with the outline style, that can be captured in the snapshot.

It also (I think) gets rid of some flakiness in the MDCOutlinedTextFieldSnapshotTests with the changes to MDCTextControlStyleOutlined.

Here's an example snapshot diff:

<img width="868" alt="Screen Shot 2019-11-04 at 4 48 31 PM" src="https://user-images.githubusercontent.com/8020010/68161034-ff608f80-ff22-11e9-8a64-1234635f3681.png">
2019-11-04 19:51:59 -05:00
Andrew Overton
cfc699b199
[TextFields] Add outlined textfield (#8705)
This PR adds the outlined textfields. The snapshots look a little weird because the way the snapshot tests are currently implemented they only get an image that's as big as the frame of the view. In a follow up PR I'm going to change that, so the images will have the entire floating label (which goes above the top of the view) for example.

![textfield-example](https://user-images.githubusercontent.com/8020010/67978102-ba212280-fbef-11e9-8802-7a0b230f900a.gif)


Closes #6942.
2019-11-01 16:23:55 -04:00
Andrew Overton
918dd0b042
[TextFields] Fix minor animation glitch when opening example (#8716)
This PR fixes a minor bug that would occur when opening the example with the textfields.

I attached some before and after videos but the effect is actually subtle enough that mov2gif doesn't really capture it haha :/

Before:
![bug](https://user-images.githubusercontent.com/8020010/68038712-f52f5e80-fca0-11e9-8510-85c5964751ee.gif)

After:
![fixed](https://user-images.githubusercontent.com/8020010/68038711-f52f5e80-fca0-11e9-90ff-f0d3e149ae6e.gif)

Related to #6942.
2019-11-01 14:05:39 -04:00
Andrew Overton
cc5d2c1504
[TextFields] Change base textfield floating label scale factor. (#8704)
In a recent PR I made the floating label the same size as the non-floating label because I thought it brought the MDCBaseTextField closer to being the "absence of style." In this PR I make it smaller again because I decided I think it just looks bad.

I also added an override for `-setBorderStyle:` that will prevent non-base textfields from having border styles like `.roundedRect`.

Related to #6942.
2019-10-31 14:58:14 -04:00
Andrew Overton
4fb5f96a44
[TextFields] Change label animation again (#8703)
There's been this bug for a long time now with the floating label animation (only on simulators using below iOS 13, and not on devices, for some reason) where the animation is sometimes skipped entirely. I thought I had a fix for it with #8700, but when I started preparing the PR for the outlined textfields (which is blocked on #8674) I noticed that it was still a problem for them, for some reason. This PR I _think_ fixes it for everything though, despite being more complicated than I'd like.

Related to #6942.
2019-10-31 14:09:29 -04:00
Andrew Overton
f2e5fe4fbd
Add filled textfields (#8674)
This PR adds MDCFilledTextField, updates the example to include it, and adds some unit tests for MDCFilledTextField's public API. I will add snapshot tests to this PR after #8670 is merged in.

Related to #6942.
2019-10-31 12:50:35 -04:00
Andrew Overton
64ff7086dc
Refactor label animation (#8700)
This PR fixes a bug where the label animation would sometimes skip on simulators (but not devices) running lower than iOS 13.

Related to #6942.
2019-10-30 11:46:12 -04:00
Andrew Overton
2ea2f01207
[TextFields] Add animation duration property to properly snapshot test MDCBaseTextField's subclasses (#8693)
This PR adds an `animationDuration` property to MDCBaseTextField. I'm doing this because I ran into problems snapshot testing MDCFilledTextField. Its style object uses Core Animation, so the `[UIView setAnimationsEnabled:{NO/YES}]` calls I'm making in `-setUp`/`-tearDown` don't have any effect on it. However, they do have an effect on the label animation, which uses UIView animations. This PR has no behavioral or public API changes. 

On one hand, this change goes against the idea that you shouldn't change source code for the sake of testing. On the other hand, there's nothing wrong with rewriting existing code so that it's more testable.

Related to #6942.
2019-10-30 09:22:50 -04:00
Yarden Eitan
5707f863a1
[TextFields] Add safety return to new multiline logic to make i… (#8695)
If numberOfLines == 1 (which is the current default), I prefer we don't go into the logic of calculation at all, due to the recently found bug with Apple's generated attributedText removing the textAlignment Natural logic.
2019-10-29 16:18:12 -04:00