16 Commits

Author SHA1 Message Date
Nobody
1ffbee43b2 Fixed up imports and nullability for Dialogs
PiperOrigin-RevId: 485926719
2022-11-03 11:31:45 -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
25c9049d5a Optimizing imports
PiperOrigin-RevId: 356791916
2021-02-10 12:00:57 -08: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
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
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
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
Robert Moore
03f3351ad5
Global replace of single-precision floats with CGFloat casts. (#5718)
Replacing all non-integral, single-precision floating point literals with double-precision values explicitly cast to CGFloat.  For example, `0.1f` should become `(CGFloat)0.1`.

Regex used:
```
([0-9]*\.)([0-9]*?)([1-9]+)([0-9]*?)[fF]
```

PiperOrigin-RevId: 220683126
2018-11-12 10:50:01 -05:00
Robert Moore
675235ed05
{Tests} Deallocate test objects at the end of tests. (#5397)
Deallocating many of the properties created for each unit test. Since all
XCTestCase instances survive until the end of the test suite, any properties
created for a test will be preserved as well. This frees up around 3.7 MB
(~6%) of memory from the entire test suite, as measured on my desktop.

|Before|After|
|----|----|
|![test-objcs-before](https://user-images.githubusercontent.com/1753199/46813473-c3b9bd00-cd44-11e8-990c-28dff4ab5ad2.png)|![test-objcs-after](https://user-images.githubusercontent.com/1753199/46813481-c7e5da80-cd44-11e8-90e4-2e6d532ebbfb.png)|

See also: https://qualitycoding.org/xctestcase-teardown/

Closes #5395
2018-10-12 08:33:58 -04:00
Galia Kaufman
0beee09b20
[Dialogs] add scrimColor to MDCAlertController (#5362)
Adding scrimColor property to MDCAlertController, which controls the background color when the alert is presented by a MDCDialogPresentationController. 
Issues: b/116845327, b/117173678.
2018-10-10 10:44:04 -04:00
Galia Kaufman
1137a62d92
[Dialogs] Customizing scrim color in presentation controller (#5283)
Adding the API to customize the color of MDCAlertController's background scrim, and to apply the color during theming. Also includes tests & an example.
Issue: #5279
Issue: b/116845327
2018-10-02 04:53:32 -04:00
Galia Kaufman
d065e4536f
[Dialogs] Customize tint color of alert title icon (#5159)
Updating AlertController API to customize the tintColor of the alert's titleIcon. Includes tests and examples.
issue: #5174
issue: Update MDC API to customize MDCAlertController title🐛
2018-09-28 06:31:31 -04:00
Galia Kaufman
dc184ba549
[Dialogs] Customize alert title icon (#5167)
Adding a title icon property to MDCAlertController.

The title icon is an image that is shown above the dialog title, and is automatically aligned with the title, supporting all NSTextAlignment alignment options (center, natural, left, right, etc).

Includes tests and examples using the new property.

Issue: #5174
Issue: Update MDC API to customize MDCAlertController title🐛
2018-09-27 14:32:57 -04:00
Galia Kaufman
80145df58e
[Dialogs] Customize alert title alignment (#5164)
Set title alignment of MDCAlertController with NSTextAlignment options.
Issue: #5174
Issue: Update MDC API to customize MDCAlertController title🐛
2018-09-24 16:12:28 -04:00