53 Commits

Author SHA1 Message Date
Cody Weaver
086b1d5947 #MDC Delete failing Dialog tests
PiperOrigin-RevId: 606726995
2024-02-13 13:25:37 -08:00
Nobody
ce92681b38 Fix A11Y on alert views when the message contains an attributed string.
PiperOrigin-RevId: 496876783
2022-12-21 03:02:43 -08:00
Nobody
e6003808d0 [GM3] Add apply capsule corners to layoutSubviews.
PiperOrigin-RevId: 490540360
2022-11-23 10:54:43 -08:00
Nobody
1ffbee43b2 Fixed up imports and nullability for Dialogs
PiperOrigin-RevId: 485926719
2022-11-03 11:31:45 -07:00
Rob Moore
520dac76c6 [Dialogs] Test that setting titlePinsToTop does not cause the alert view to load.
Minor test update to validate that the new property doesn't cause the view to load.

Also removed some unused imports found during code review.

PiperOrigin-RevId: 484516340
2022-10-28 06:37:07 -07:00
Cody Weaver
42bea2922d [Dialogs] Remove tests for mdc_adjustContentForSizeCategory
PiperOrigin-RevId: 443184826
2022-04-20 13:57:01 -07:00
Alyssa Weiss
18c9da00e0 Add an option that allows the title to scroll with the message for a MDCAlertController.
PiperOrigin-RevId: 406822869
2021-11-01 07:45:03 -07:00
Jeff Verkoeyen
171f827a4e Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 401082996
2021-10-05 15:23:14 -07:00
Alyssa Weiss
420449a5c2 Remove adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable API from MDCAlertController.
PiperOrigin-RevId: 376847751
2021-06-01 09:15:56 -07:00
Jeff Verkoeyen
25c9049d5a Optimizing imports
PiperOrigin-RevId: 356791916
2021-02-10 12:00:57 -08:00
Nobody
584294efff Support value comparison for MDCAlertAction
Implements isEqual in MDCAlertAction to support equality check.

PiperOrigin-RevId: 339687443
2020-10-29 09:50:10 -07:00
Alyssa Weiss
bd6484925b Delete deprecated buttonFont for MDCAlert and make all appropriate changes following deletion
PiperOrigin-RevId: 333566191
2020-09-24 12:03:36 -07:00
Alyssa Weiss
d40c6d8608 Remove iOS 10+ checks now that the minimum support contract is iOS 10.
PiperOrigin-RevId: 332836975
2020-09-21 06:28:30 -07:00
Bryan Oltman
da4b8f7c7f Fix mdc_elevationDidChangeBlock block parameter types for Xcode 12
PiperOrigin-RevId: 331843566
2020-09-15 13:39:15 -07:00
Galia Kaufman
ea8887e284 [Dialogs] Adding attributed link color API and updating theming extension
PiperOrigin-RevId: 314453930
2020-06-02 20:00:28 -07:00
Galia Kaufman
6bb3ece393 [Dialogs] Adding tappable link support to the alert message
Adding an action API for notifying caller when a message link is tapped.

PiperOrigin-RevId: 314135831
2020-06-01 08:45:13 -07:00
Galia Kaufman
f4fd6d015f [Dialogs] replace the message UILabel type to UITextview
The type of the message in Material Dialogs was switched from UILabel to UITextView, That is done in order to support links in attributed text. We're seeing some differences in the text rendering in dialog snapshots. In some cases, the width of the dialog may also change, which can result in some other elements moving to maintain required spacing from the edges. Based on our testing, we're not expecting any other changes, so please let us know if you find anything unusual.

This change set includes:
* `messageLabel` was renamed to `messageTextView`.
* The UITextView has its editable flag set to false, and all internal padding set to
  zero, to ensure spacing remain the same as it was with UILabel.
* `scrollEnabled` was set to false to ensure text does't scroll when not needed (it
  still enables scrolling when needed: when there's more text than the visible area.)
* `backgroundColor` was set to `clear`. It seems UITextView's default is white, which
   breaks inverted/dark mode support.

Noticeable differences:
* `sizeThatFits` occasionally returns different width for some texts:
   -- Some texts result in a wider layout (ie: dialogs-presented-with-emphasis-buttons.png)
   -- Empty text views may have a non-zero height. Determining zero
      size based on `hasText` before calling `sizeThatFits` resolved the issue.
* Text rendering is slightly different in almost all snapshots.
* Links in attributed texts are rendered differently then before (ie: color).
* In a couple of RTL snapshot tests, I needed to set the RTL test direction before
  setting the message alignment for the test to work properly.

PiperOrigin-RevId: 313607718
2020-05-28 10:03:43 -07:00
Jake Rockland
776d028861 [Dialogs] Allow MDCAlertController to become first responder via its view.
PiperOrigin-RevId: 310506900
2020-05-07 23:07:58 -07:00
Wenyu Zhang
da54c6f67a [Dialogs] Allow MDCAlertController to become first responder.
PiperOrigin-RevId: 309437429
2020-05-01 11:06:19 -07:00
Galia Kaufman
bffc2c3d07 [Dialogs] Fix incorrect initialization of properties
Three MDCAlertController properties were not initialized during object initialization.
Their initialization during viewDidLoad caused values previously assigned to them to be reverted to default during presentation or theming.
Adding unit tests that reproduce the issue.

PiperOrigin-RevId: 308075191
2020-04-23 10:05:34 -07:00
Wenyu Zhang
d36b5e8f3d [Dialogs] Add UIPointerInteraction support for buttons..
PiperOrigin-RevId: 305871918
2020-04-10 07:20:14 -07:00
Vladimir Pomsztein
19a973ff44 [Dialogs] Add support for attributed dialog message text
## Description

Adds attributed text support for the message inside dialogs in order to provide further customizability and allow for a more liberal use of the component

Closes https://github.com/material-components/material-components-ios/pull/9937

COPYBARA_INTEGRATE_REVIEW=https://github.com/material-components/material-components-ios/pull/9937 from blastervla:feature/attributed-dialog-text d271cea6e37319c95dcef22e65182abdc3e4241c
PiperOrigin-RevId: 303768487
2020-03-30 10:23:51 -07:00
Bryan Oltman
f08507474c
[Dialogs] Expose MDCAlertController presentation animation properties (#9314)
Exposes MDCDialogTransitionController scaleAnimationDuration, opacityAnimationDuration, and dialogInitialScaleFactor presentation configuration properties through MDCAlertController. 

Fixes #9313
2019-12-19 14:55:16 -05:00
Cody Weaver
8becfc1ec5
[Dialogs] Allow clients to customize message accessibility label (#8801)
This change allows clients to customize the message accessibility label.

Closes to #8779
2019-11-13 13:49:30 -08:00
Cody Weaver
0796e54332
[Dialogs] Allow clients to customize title accessibilityLabel. (#8799)
This change allows clients to customize the title accessibility label.

Related to #8779
2019-11-13 09:37:59 -08:00
Robert Moore
8c445f6138
[Dialogs] Title supports Dynamic Type. (#8691)
Enables MDCAlertController and the title font to support automatic resizing of
fonts generated from a UIFontMetrics or UIFont preferredFont.

Part of #8672
2019-11-01 08:28:22 -04:00
Robert Moore
27b170cf91
[Dialogs] Add tests for Dynamic Type. (#8675)
Adds unit and snapshot tests for Dynamic Type support using both MDCTypography
and MDCFontScaler.

Part of #5418
2019-10-28 15:53:20 -04:00
Robert Moore
dce2d98f92
[Dialogs] Add MaterialElevation support to AlertController. (#8098)
Adds conformance to `MDCElevatable` and `MDCElevationOverriding` to
`MDCAlertController`.

Part of #8020
2019-07-28 20:15:49 -04:00
Robert Moore
9b5c2faf21
[Dialogs] Remove iOS 9 guards. (#7998)
Part of #2651
2019-07-23 12:22:15 -04:00
Bryan Oltman
1a29c33790
[Dialogs] Add traitCollectionDidChangeBlock to MDCAlertController (#7981)
Adds a traitCollectionDidChangeBlock to MDCAlertController, called when its trait collection changes.

Closes #7951
2019-07-22 14:44:00 -04:00
Cody Weaver
8c2bcdc9d8
[Dialogs] Add shadow color API (#7911)
This PR adds a shadowColor API to MDCAlertController and presentation controller. Snapshot test have been added for both MDCAlertController and the trackingView that the presentation controller uses since the MDCAlertController.view is a different view than the view that represents the shadow. This new API supports dynamic color.

Closes #7875
2019-07-16 14:29:37 -07:00
Cody Weaver
8eff3fd1b5
[Dialogs] Add test for legacy dynamic type behavior around buttonFont (#7509)
This changes adds test for legacy dynamic type, mainly focused on the behavior around adjustFontForContentSizeCategoryWhenScaledFontIsUnavailable and mdc_adjustFontForContentSizeCategory with respect to the buttonFont property.

Related to #7464
2019-05-28 21:52:28 -04:00
Cody Weaver
2cae47ac22
[Dialogs] Add test for legacy dynamic type with the messageFont property (#7498)
This change adds test within Dialogs around the behavior `adjustFontForContentSizeCategoryWhenScaledFontIsUnavailable` and `mdc_adjustFontForContentSizeCategory` specifically for the `messageFont`.

Related to #7464 & #7386
2019-05-28 16:34:05 -04:00
Cody Weaver
03e37c2f7a
[Dialogs] Test title font legacy behavior when dynamic type is enabled. (#7468)
This changes adds test for _legacy_ dynamic type, mainly focused on the behavior around `adjustFontForContentSizeCategoryWhenScaledFontIsUnavailable` and `mdc_adjustFontForContentSizeCategory`. This additionally fixes a bug in Dialogs where it would set `mdc_adjustFontForContentSizeCategory` before other properties were set.

This only updates the behavior for `titleFont` within `MDCAlertController` in a follow up PR I will add test and the correct behavior for `messageFont` and `buttonFont`.

Related to #7464
2019-05-28 10:28:54 -04:00
Cody Weaver
a1b7788a86
[Dialogs] Add flag for legacy behavior for dynamic type (#7446)
## Motivation
In order to closely match UIKit behavior we need to have a flag for when a component wants to update some fonts for dynamic type but only those with scaling curves. Currently this is not possible to do because if dynamic type is on we automatically scale everything.

## Detailed changes
Add a runtime flag that can turn on scaling fonts no matter what or scales only if scalingCurves are attached to the font.


Related to #7386
2019-05-22 12:40:36 -04:00
Robert Moore
3447c7b719
{Tests} Fix font comparison in Objective-C. (#6789)
Several unit tests were using identity comparison operations
(`XCTAssertEqual`) instead of equality comparison (`XCTAssertEqualObjects`).
Because UIFont supports `NSCopying`, assigning a UIFont to a `copy` property
can result in a copied object.

Unit tests seemed to flake sometimes, most recently in a Pull Request for
Dynamic Type (#6733).

QA=Unit tests pass
2019-03-07 10:04:40 -05:00
Galia Kaufman
f472cab956
[Dialogs] adding backgroundColor property for dark theme support (#6066)
Adding a backgroundColor property to MDCAlertController, which enables dark theming of MDCAlertController (b/121269110).
2019-01-08 10:29:31 -05:00
featherless
d9c801e773
[all]! Remove remaining property coding. (#5792)
Our components should not implement or support property coding unless explicitly required. We generally removed support for this type of behavior early in 2018.

Many components were still implementing coding support.

Property coding has been removed from every component.

This change also removes `NS_DESIGNATED_INITIALIZER` from all initWithCoder APIs.
2018-11-20 09:06:46 -05:00
Cody Weaver
dd79e5c6b1
[Dialogs] Refactor test to use setup and teardown (#5482)
### Context
In working on #5296 I noticed a lot of the test had repeated code that can be pulled into a `setup` function. Additionally some of the test were missing _Given_, _When_, and _Then_ statements so those were added. This change hopefully makes this code more readable to future maintainers. I also noticed some of the test had extra work in the _Given_ that wasn't necessary so I removed that.
### The problem
Repeated steps in the _Given_ section of the test
### The fix
Implement the `setup` and `teardown` functions as well as add missing _Given_, _When_, and _Then_ comments.

### Related bugs
This isn't related to any bugs this is just something that I saw that could be improved.
2018-10-23 09:16:21 -04:00
Galia Kaufman
d55d7ab9f2
[Dialogs] Theming action buttons in DialogThemer (#5416)
Adding semantic emphasis to Dialog actions which allows conditional theming of buttons. The MDCDailogScheme now has a button scheme which can be used to theme buttons according to their action's assigned emphasis.
Issue: b/117608629
Design Review document (go/gmdc-ios-dialogs-design-doc).
2018-10-22 12:31:03 -04:00
Robert Moore
d994fe7531
[Dialogs] Enable misspelled test. (#5399)
One of the tests was misspelled and not executing.
2018-10-12 09:28:35 -04:00
Cody Weaver
cba82b4d06
[Dialogs] Add shadow elevation (#5296)
### Context
Clients may need to set custom elevation levels for their custom dialogs
### The problem
Currently we don't expose any of the necessary properties to do this.
### The fix
Expose those properties so clients can have a custom elevation for their Dialog.

### Additionally
Test and Examples have been added.


### Screenshots
| Default | Custom |
| - | - |
|![simulator screen shot - iphone x - 2018-10-02 at 15 40 25](https://user-images.githubusercontent.com/7131294/46372705-e7e91000-c659-11e8-875c-132ba70c4b9f.png)|![simulator screen shot - iphone x - 2018-10-02 at 15 40 21](https://user-images.githubusercontent.com/7131294/46372715-ecadc400-c659-11e8-81a7-2f253ebf38e8.png)|
2018-10-02 16:07:49 -04:00
Galia Kaufman
fcd70cad6e
[Dialogs] Expose corner radius property (#4988)
Exposing a corner radius property on MDCAlertController.

Setting the Alert's corner radius updates its view's corner radius, as well as propagate the radius to the presentation controller so it can correctly render the tracking/shadow layer.

Issue: #4964
Issue: b/113257098
2018-09-12 08:03:27 -04:00
featherless
2181084272
[automated] Standardize our open source license stanza to what Xcode generates. (#4985)
Removes the need to copy-paste stanzas from other files anymore as we'll rely on #4478 to generate the correct stanza for us instead.

This was an automated change generated by running a find-and-replace regular expression:

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at

 http://www\.apache\.org/licenses/LICENSE-2\.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
/\*
Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

Licensed under the Apache License, Version 2\.0 \(the "License"\);
you may not use this file except in compliance with the License\.
You may obtain a copy of the License at

http://www\.apache\.org/licenses/LICENSE-2\.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
See the License for the specific language governing permissions and
limitations under the License\.
\*/
```

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.
 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at
 http://www\.apache\.org/licenses/LICENSE-2\.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
// Copyright $1-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
```
2018-08-31 12:13:07 -04:00
Robert Moore
823776e6ba
[Dialogs] Add accessibilityIdentifier to Actions. (#4917)
To improve support for UI testing, `accessibilityIdentifier` values
should be attached to the action buttons of MDCAlertController views.
Instead of exposing the views and the buttons, an
`accessibilityIdentifier` property can be assigned to the MDCAlertAction
directly using the UIAccessibilityIdentification protocol.

Closes #4916
2018-08-28 16:45:41 -04:00
Robert Moore
cce878a837
[Dialogs] Adding 'buttonInkColor' (#4847)
[Dialogs] Adding 'buttonInkColor' 

Allows changing the ink color effect of the action buttons.

Internal change: cl/209173946
2018-08-21 14:23:03 -04:00
Mohammad Cazi
39030e7b20
[Dialogs] Setting Properties on Alert controller will not force the view to load. (#4238)
* Setting Properties on Alert controller will not force the view to load.

* Changed to the old approach on how to handle custom view and setting its properties.

* alertview check for alert title was missing.

* Unit tests Added.

https://github.com/material-components/material-components-ios/pull/4238
2018-05-23 15:05:32 -04:00
Mohammad Cazi
de1119c21e
[Dialogs] Loading the view manually caused view did load not to be called. (#3281)
* Using the same approach as featureHighlight and making view internally a MDCAlertControllerView. this way we don't have to handle the situations where view is not loaded yet.

* adding a test to cover this case.
2018-04-09 11:51:38 -04:00
Mohammad Cazi
a61f529825
[Dialogs] Expose typography and color API. (#3218)
* Extracting Accessibility out of FeatureHighlightViewController to a mutator.
Tests added.
Example updated.

* Revert "Extracting Accessibility out of FeatureHighlightViewController to a mutator."

This reverts commit 0b5433ebf86366087b240c4dc4992a0603fa73e0.

* Expose typography API and Color API by exposing the MDCAlertControllerView.
Cleaning up the Dynamic Font size code.

* Setting mdc_adjustsFontForContentSizeCategory to false should reset fonts back to default.

* making the code more clear.

* exposing font and color properties for MDCAlertController.

* Fix the document update.

* loadViewIfNeeded is iOS 9+

* made buttonTitleColor Property name clear and fix the documentation.
2018-04-06 10:22:05 -04:00
ianegordon
f88160007e
[Dialogs] Temporarily revert MMotion (#2921)
* Revert "[Dialogs] Migrate to Material Motion. (#2481)"

This reverts commit 211ca772ea0456b56e522c0c67bd44312ddfe4d1.

* Bump animator back to 2.5.0

* Pull in develop project file

* Remove test for MMotion
2018-02-13 14:27:24 -05:00