110 Commits

Author SHA1 Message Date
Nobody
5c9ba055ee Internal change now button height defined by the text size.
PiperOrigin-RevId: 713948536
2025-01-10 00:55:31 -08:00
Cody Weaver
086b1d5947 #MDC Delete failing Dialog tests
PiperOrigin-RevId: 606726995
2024-02-13 13:25:37 -08:00
Cody Weaver
8fa0811d63 #Dialog Add an API for the Dialog insets
PiperOrigin-RevId: 525523575
2023-04-19 12:45:42 -07: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
Wenyu Zhang
2ff701bbbe [Dialogs] Fix the calculation for actionSize by removing the double counted actionsInsets and avoiding using fixed bounding width for justified layout, which causes multiple layout passes to stabilize the frame calculation - wrong frame.
PiperOrigin-RevId: 449314001
2022-05-17 14:22:06 -07:00
Janette James
505c27cd9f Fix dialog button layout on text size changes
PiperOrigin-RevId: 447858819
2022-05-10 16:48:06 -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
597995a27b Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 401224810
2021-10-06 06:13:40 -07:00
Jeff Verkoeyen
171f827a4e Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 401082996
2021-10-05 15:23:14 -07:00
Randall Li
502bc5d910 Ran a Swift formatter
PiperOrigin-RevId: 395947664
2021-09-10 09:48:14 -07:00
Alyssa Weiss
420449a5c2 Remove adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable API from MDCAlertController.
PiperOrigin-RevId: 376847751
2021-06-01 09:15:56 -07:00
Cody Weaver
bb30d81642 [Dialogs] Add convenience API for adding actions.
PiperOrigin-RevId: 374488229
2021-05-18 13:13:46 -07:00
Jeff Verkoeyen
1c14fb5e7b Internal change.
PiperOrigin-RevId: 363294413
2021-03-16 16:23:36 -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
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