91 Commits

Author SHA1 Message Date
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
Wenyu Zhang
313135ece2 [Dialogs] Add visibleAreaInsets support.
PiperOrigin-RevId: 317137957
2020-06-18 11:01:22 -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
Galia Kaufman
b3cf4e42e6 Consider the size of the longest action in horizontally justified action alignment - testing if it can fit the available horizontal space to determine if the actions should be aligned vertically.
PiperOrigin-RevId: 309943747
2020-05-05 07:45:14 -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
Galia Kaufman
7346de3ce0 [Dialogs] Using the new Testing target in insets unit tests.
A followup for cl/305814799 - replacing calls to all private APIs in MDCAlertControllerInsetsTests.m with the new testing utilities in MDCAlertController+Testing.h

PiperOrigin-RevId: 305863373
2020-04-10 05:46:11 -07:00
Jeff Verkoeyen
9c32878a48 [Dialogs] Disable broken test.
b/153457451 tracking fix of the test.

PiperOrigin-RevId: 305861929
2020-04-10 05:26:51 -07:00
Galia Kaufman
e5b43d2e72 [Dialogs] Size justified-aligned title-icons to fit the alert's width.
To allow a meaningful contentMode setting for the titleIcon image view, the title icon image is sized to fit the alert's width. The height is then adjusted proportionally.

To maintain backward compatibility (and minimize client UI changes), the icon frame size is not adjusted for non-justified alignments.

This is a potential breaking change for clients that use Justified title, however it is unlikely that many clients (if any) would do that, since it's in most cases a bad UI/UX.

PiperOrigin-RevId: 304213073
2020-04-01 10:31:53 -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
Galia Kaufman
a4d690cb1c [Dialogs] Support custom alignment for the title image (independent of title)
Adding support for customizing the alignment of the title icon, independently of the alignment of the title.

To preserve backward compatibility, the default title-icon alignment is the same as the title. We're using the internal _alignIconWithTitle flag to track if the alignment had been implicitly assigned. Once the value is implicitly assigned, the title icon alignment is independent from the title.

## Issues
Closes #9545, #9824.

PiperOrigin-RevId: 303748434
2020-03-30 08:47:44 -07:00
Galia Kaufman
144b2f61dc [Dialogs] Calculate title Insets independently of content insets
## (Visually) Breaking Changes

The padding between the title or title icon, and the actions, when there is no message is now determined by titleInsets.bottom instead of contentInsets.top (no sense in using contentInsets when there is no content).  The actual inset value has is different, and is now 20 (changed from 24), which caused some client scuba diffs.

## Background

Insets calculations of the title and content panes in dialogs were using the same insets values, causing various misalignments.  This is fixed by ensuring that title calculations are using the titleInsets and that content calculations (of the message or accessory view) are using the content insets.

## Additional (non-breaking) misalignment fixes

#### The title Label stretches too long (pink title has no right inset):
```
titletInsets = UIEdgeInsetsMake(24.f, 24.f, 24.f, 24.f);
contentInsets = UIEdgeInsetsMake(10.f, 10.f, 10.f, 10.f);
```
![image](https://user-images.githubusercontent.com/2329102/76694455-6a487280-6649-11ea-96e9-5eca7f37b86d.png)

#### The title label is too short (pink title right inset is too large):
```
titleInsets = UIEdgeInsetsMake(12.f, 12.f, 12.f, 12.f);
```
![image](https://user-images.githubusercontent.com/2329102/76694524-391c7200-664a-11ea-9f81-47389711af7f.png)

#### A dialog with no message has a message pane (yellow):
![image](https://user-images.githubusercontent.com/2329102/76694587-f4dda180-664a-11ea-979f-ecc45b28966e.png)

#### A dialog with no title has a title pane (pink):
![image](https://user-images.githubusercontent.com/2329102/76694595-12127000-664b-11ea-8d22-9d954ad7570b.png)

## Issues
Fixes #9545, #9824.
b/133006455, b/148572399

PiperOrigin-RevId: 303368923
2020-03-27 11:31:24 -07:00
Galia Kaufman
8c7be049e9 [Dialogs] Moving static c helper functions outside of test classes.
PiperOrigin-RevId: 303289751
2020-03-27 02:46:49 -07:00
Galia Kaufman
6b790fe2e1 [Dialogs] Calculate title Insets independently of content insets (resolve scuba diff)
Insets calculations of the title and content panes in dialogs were using the same insets values, causing various misalignments.  This is fixed by ensuring that title calculations are using the titleInsets and that content calculations (of the message or accessory view) are using the content insets.

PiperOrigin-RevId: 303166366
2020-03-26 12:16:07 -07:00
Cody Weaver
fdf87c5995 [MDC/ColorScheme] Remove usage of init within MDC.
We recommend using `initWithDefaults` and we should follow the recommendation. This change removes all usage of `init` within MDC components in order to let us remove that initializer from the public surface.

PiperOrigin-RevId: 302958447
2020-03-25 13:36:51 -07:00
Bryan Oltman
511da587d4
[Dialogs] Delete deprecated DialogThemer (#9776)
DialogThemer (`MDCAlertControllerThemer` and `MDCAlertScheme`) is deprecated and has no internal use.
2020-02-24 14:03:29 -05:00
Iryna Berezan
ecb0ddcae0 Add a private API for passing a custom title icon view. It can be used for passing a custom animation into the title.
PiperOrigin-RevId: 292824168
2020-02-02 16:12:39 -08: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
8cebc56185
[*] Suppress deprecation warnings. (#8481)
Suppresses deprecation warnings either for implementations of our own
deprecated APIs or for their use in tests and elsewhere.

Part of #7537
2019-09-23 12:48:42 -04:00
Wenyu Zhang
3c9355711c
[Dialogs] Rewrite tests in ObjC to prevent the failing unit tests on iOS 13 (#8257)
closes https://github.com/material-components/material-components-ios/issues/8256.

## Context
Error occurs when testing using Bazel.
```
Test Case '-[components_Dialogs_unit_test_swift_sources.MDCDialogPresentationControllerTests testTraitCollectionDidChangeCalledWithCorrectParameters]' started.
Child process terminated with signal 11: Segmentation fault
```
2019-08-09 11:46:01 -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
Yarden Eitan
90938fe59f
[Dialogs] Adds the Ripple behavior to Dialogs. (#7595)
## Related links
* Bug: Closes #7379 
* Ripple: [Ripple](https://github.com/material-components/material-components-ios/tree/develop/components/Ripple)

## Introduction
This PR allows enabling the Ripple Behavior for [`MDCAlertController and MDCAlertControllerView`](https://github.com/material-components/material-components-ios/tree/develop/components/Dialogs) by enabling the ripple behavior of the internal `MDCButton`. This behavior is an opt in flag property added to MDCAlertController, `enableRippleBehavior`.  This improves the visual touch feedback for our users as MDCInkView didn't support our current motion guidelines.

## Videos
| Before | After |
| - | - |
|![oldRipple](https://user-images.githubusercontent.com/4066863/59470021-81c9a500-8e04-11e9-8071-cdc2d3a81ceb.gif)|![newRipple](https://user-images.githubusercontent.com/4066863/59470027-85f5c280-8e04-11e9-834b-a180c8805e40.gif)|
2019-06-15 12:47:00 -04: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
Cody Weaver
936d04ab35
[Buttons] Update outline theming extension (#7403)
## Motivation
In working on #7390 it was discovered that the _outline_ theme for `MDCButton` was not theming the icon. This change now sets the correct values in the theming extension.

## Detailed changes
*imageTintColor* This wasn't being set and now is being set to the correct value
*inkColor* This is now being set to the correct value, previously this was the wrong value
Formatting changes also

## Alternatives
I elected not to change the Themer object because that will soon be deprecated and we need to move off of it. This copies what was in the themer where applicable and updates the needed changes.

Closes #7400
2019-05-16 13:38:03 -07:00
Andrew Overton
bf5d5e1c1d
[Dialogs] Graduate Dialogs theming extensions to ready (#7190)
This PR updates the dialogs theming extensions to ready.

Closes #7163.
2019-04-23 11:28:02 -04:00
Andrew Overton
94e5a978d7
[Buttons] Graduate Buttons+Theming to ready (#7187)
This PR graduates the buttons theming extension to ready.

Closes #7158.
2019-04-19 13:57:00 -04:00
Yarden Eitan
5bed3961e6
[ContainerScheme] Graduate ContainerScheme to ready. (#7170)
This PR graduates ContainerScheme to ready.

This includes updating the podspecs, podfile, all the import statements related to ContainerScheme, updating .kokoro rewrite rules, and finally the readme to not have ContainerScheme regarded to as being in beta.

Ran locally kokoro with -b bazel successfully.

Resolves #6732
2019-04-18 09:25:02 -04:00
Wenyu Zhang
8c407c22c4
[Dialogs] Layout MDC Dialogs correctly for tall fonts. (#7126)
Closes https://github.com/material-components/material-components-ios/issues/7062

Reference: cl/241537224

Layout MDC Dialogs correctly for tall fonts

The MDC Dialog layout code had some hard coded assumptions about the amount of vertical space to allocate for action buttons that were violated when using taller fonts such as Urdu with large Dynamic Type sizes.
There was also a related bug where vertical vs. horizontal action button layout was calculated in two different places.

Snapshot test before change:
<img width="569" alt="snapshot_test_goldens_goldens_64_MDCAlertControllerLocalizationSnapshotTests_testPreferredContentSizeWithNotoNastaliqUrdu_11_2@2x_Before_01dd7fb1a36bc24b27e05c1079c6420994c9f904" src="https://user-images.githubusercontent.com/8836258/56166158-dc7c8700-5fa2-11e9-8fa1-ed4dbfdc947b.png">

Snapshot test result after change:
<img width="569" alt="snapshot_test_goldens_goldens_64_MDCAlertControllerLocalizationSnapshotTests_testPreferredContentSizeWithNotoNastaliqUrdu_11_2@2x_After_78d3fd9172a202641400c0536a9c2e3a33b0455b" src="https://user-images.githubusercontent.com/8836258/56166182-e7371c00-5fa2-11e9-976e-4f9c93efc98f.png">


Example screenshot before change:
![Simulator Screen Shot - iPhone 7 - 2019-04-15 at 17 42 09](https://user-images.githubusercontent.com/8836258/56167426-1dc26600-5fa6-11e9-9d5f-180f7960f458.png)


Example screenshot after change:
![Simulator Screen Shot - iPhone 7 - 2019-04-15 at 17 43 58](https://user-images.githubusercontent.com/8836258/56167432-2024c000-5fa6-11e9-8e44-5a88b48425f2.png)
2019-04-15 19:26:55 -04:00
ianegordon
861cebe7e1 Revert "[Typography] Dynamic Type 2.0 (#6733)" (#6848)
This reverts commit 648f2499e80a02de28a545a223cc50f00c715097.
2019-03-12 16:36:54 -04:00
ianegordon
648f2499e8
[Typography] Dynamic Type 2.0 (#6733)
Next iteration of our Dynamic Type.

Mimics Apple's new APIs. (UIFontMetrics)
Adds MDCFontScalar to attach curves.
Adds UIFont category to expose fontScaledForCategory methods.
Adds new MDCTypographyScheme with scalable fonts.
Adds sample to demonstrate new curves.
2019-03-08 16:15:24 -05: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
df2a4a8c1d
[Dialogs] Fix presented corner radius in custom view controllers (#6696)
DialogPresentationController changes the corner radius dynamically during presentation while ensuring that the presented view's corner radius always matches the corner radius of the tracking view which draws the shadow behind the presented view.
2019-03-02 10:03:55 -05:00
Cody Weaver
50307bb330
[Container] Fix colorScheme and typographyScheme to be nonnull. (#6699)
## Introduction
Before we move container scheme to ready we need to have both the `colorScheme` and `typographyScheme` nonnull. By making colorScheme and typographyScheme of MDCContainerScheming nonnull, clients will reduce the amount of conditional checks required in their apps and reduce a category of potential errors (accidentally passing nil to a nonnull parameter).

## The problem
Both `colorScheme` and `typographyScheme` were nullable in the container scheme making it harder for clients to use the container scheme throughout their app on non Material UIElements, i.e. UIView.backgroundColor

## The fix
Make both of these properties nonnull.

## Additional work
- [x]  I had to update the swift examples to not be optional and I additionally removed the nil checks from the ObjC examples.
2019-02-27 15:47:26 -05:00
Yarden Eitan
7665eba879 Revert "[Dialogs] Use test Typography scheme (#6694)"
This reverts commit 81bab4571f0c38efde43afaae3dc3b886bc2519a.
2019-02-26 11:48:35 -05:00