163 Commits

Author SHA1 Message Date
Cody Weaver
f50ff96ac4 #Dialogs Remove legacy tests
PiperOrigin-RevId: 764821799
2025-05-29 11:51:05 -07:00
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
Nobody
9e1c0c0a45 Internal change
PiperOrigin-RevId: 477458164
2022-09-28 08:26:32 -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
Jeff Verkoeyen
dc91ec8ace [Dialogs] Migrate off of mdc_adjustsFontForContentSizeCategory.
PiperOrigin-RevId: 407210477
2021-11-02 16:59:14 -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
6b58d9548a Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 401326199
2021-10-06 13:36:15 -07:00
Jeff Verkoeyen
c4073fb36f Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 401325761
2021-10-06 13:33:07 -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
6ccb268a37 Move FontScaler APIs in MDCTypography to a separate directory.
PiperOrigin-RevId: 390642325
2021-08-13 10:33:45 -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
Alyssa Weiss
2844115021 Update Dialog's adjustFontForContentSizeCategory to set the property on the message and buttons, not just the title.
PiperOrigin-RevId: 371918504
2021-05-04 08:25:23 -07:00
Nobody
08d42c18d8 [MDCAlertControllerView] Avoid cutting off the top of Thai characters with diacritics.
In iOS platform, text font are not strictly required to fit within the UIFont.lineHeight. Some Thai characters with diacritics are rendered outside the UILabel/UITextView's bounds.

One solution is to increase the top margin of the UILabel/UITextView so we leave extra padding between the parent view's top edge and the top edge of the UILabel/UITextView (Like the _titleLabel in MDCAlertControllerView).

closes #10161

PiperOrigin-RevId: 363491472
2021-03-17 13:16:58 -07:00
Jeff Verkoeyen
1c14fb5e7b Internal change.
PiperOrigin-RevId: 363294413
2021-03-16 16:23:36 -07:00
Jeff Verkoeyen
8ce743ce8a Optimizing imports
PiperOrigin-RevId: 357185751
2021-02-12 07:33:30 -08: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
Galia Kaufman
9d9bd93847 [Dialogs] Adding accessoryViewHorizontalInset API
The API allows setting horizontal insets for the accessory view that are different from the message. This is most often used for dialogs that have both a message and an accessory view, as demonstrated in the attached example.

Additionally, this example demonstrates how to add an horizontal hairline as shown on the material.io spec for Confirmation Dialogs.

Note:
This new API is needed because clients do not always have control over the view that is being used as an accessory view, or that the view is used in multiple areas in the app, and cannot be customized.
Additionally, there's no way currently to set 0 insets for the accessory view, while still keeping the 24 value insets for the message, which is a relatively common scenario.
PiperOrigin-RevId: 334142026
2020-09-28 06:12:48 -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
8842f55760 Update the testing for the localization snapshot tests.
PiperOrigin-RevId: 332912160
2020-09-21 12:52:20 -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
8bf81b7d0a [Dialogs] Testing trailing actions in reversed vertical order
When actions are vertically aligned, the first trailing or leading action is positioned incorrectly, hiding the second trailing/leading action. This is fixed in a followup change list.

PiperOrigin-RevId: 318875437
2020-06-29 12:59:03 -07:00
Wenyu Zhang
313135ece2 [Dialogs] Add visibleAreaInsets support.
PiperOrigin-RevId: 317137957
2020-06-18 11:01:22 -07:00
Galia Kaufman
ba359990d5 Setting orderVerticalActionsByEmphasis incorrectly calculates top and bottom insets for actions.
PiperOrigin-RevId: 314793489
2020-06-04 13:35:05 -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
b3bf62df4e [Dialogs] Include insets in alignment calculations of long actions
Include insets in horizontal calculations when determining if all buttons fit horizontally. This will allow actions whose title is nearly half of the dialog to be aligned horizontally.

PiperOrigin-RevId: 310331603
2020-05-07 04:10:24 -07:00
Galia Kaufman
67cb856040 [Dialogs] Fixing broken unit test
Fixing the error:
`error: implicit conversion from enumeration type 'enum MDCContentHorizontalAlignment' to different enumeration type 'NSTextAlignment' (aka 'enum NSTextAlignment') [-Werror,-Wenum-conversion]`

PiperOrigin-RevId: 310164335
2020-05-06 09:16:47 -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
Iryna Berezan
99d6facc5b No public changes, just a test that reproduces the issue.
PiperOrigin-RevId: 309425831
2020-05-01 10:07:22 -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
Galia Kaufman
b98d977309 [Dialogs] Add manual and auto layout accessory view tests.
This CL demonstrates three different ways to present a message with a "Learn More" button under it in an alert. It also demonstrates accessory views with manual and auto layouts.

The 2 auto-layout tests create a view with a label and a button as subviews, and lay them out using constraints. One of them is testing a subclass, while the other adds the button/text directly to the accessory view.

The manual layout test uses the alert's default message property, and uses a button for the accessory view. It then uses the new 'accessoryViewVerticalInset' to customize the space between the message and the button.

Note: Using `sizeToFitContentInBounds:` for snapshot tests is now correctly resizing snapshot tests that were previously too wide (including the snapshot in b/147241131).
PiperOrigin-RevId: 307884732
2020-04-22 13:27:38 -07:00
Galia Kaufman
f7d799a9cf [Dialogs] Using the new Testing target in accessory snapshots.
A followup for cl/305814799 - replacing calls to all private APIs in MDCAlertControllerAccessoryTests.m with the new testing utilities in MDCAlertController+Testing.h

PiperOrigin-RevId: 305878401
2020-04-13 09:22:00 -04:00
Wenyu Zhang
d36b5e8f3d [Dialogs] Add UIPointerInteraction support for buttons..
PiperOrigin-RevId: 305871918
2020-04-10 07:20:14 -07:00
Galia Kaufman
e48d79a9cc [Dialogs] Using the new Testing target in actions snapshots.
A followup for cl/305814799 - replacing calls to all private APIs in MDCAlertControllerActionsTests.m with the new testing utilities in MDCAlertController+Testing.h

Removing the private header since it's no longer needed for testing.

PiperOrigin-RevId: 305865529
2020-04-10 06:11:33 -07:00