153 Commits

Author SHA1 Message Date
Bryan Oltman
da4b8f7c7f Fix mdc_elevationDidChangeBlock block parameter types for Xcode 12
PiperOrigin-RevId: 331843566
2020-09-15 13:39:15 -07:00
Cody Weaver
2a5996b407 [MDC/Button] Add rippleMaximumRadius API.
This commit adds the ripple maximum radius API to match the inkMaxRippleRadius API that are soon to be deprecated. This also moves those APIs to a "ToBeDeprecated" category. In this commit I set an ivar instead of having pass through properties because in a follow up I think it would be a good optimization to have the ripple be lazy until a user interacts with the button. This will lower initialization time and make the setters potentially faster. Since we don't have pass through properties I defaulted it to 0 to match the legacy API from `MDCStatefulRippleView` to match here.

PiperOrigin-RevId: 323011293
2020-07-24 09:34:26 -07:00
Cody Weaver
9039d47602 [MDC/Button] Add rippleColor and rippleStyle APIs
This commit adds the ripple color and ripple style APIs to match the inkColor and inkStyle APIs that are soon to be deprecated. This also moves those APIs to a "ToBeDeprecated" category. In this commit I set an ivar instead of having pass through properties because in a follow up I think it would be a good optimization to have the ripple be lazy until a user interacts with the button. This will lower initialization time and make the setters potentially faster. Since we don't have pass through properties I mirrored the default rippleColor from `MDCStatefulRippleView` to match here.

PiperOrigin-RevId: 322585578
2020-07-22 09:05:16 -07:00
Bryan Oltman
7b45e787db [Buttons] Remove unused TitleColorAccessibilityMutator.
PiperOrigin-RevId: 322411522
2020-07-21 12:05:57 -07:00
Cody Weaver
330125967a [MDC/Button] Add rippleEdgeInsets API.
Currently we make the ripple the entire size of the button. This limits clients being able to customize if the ripple is inset or outset on a particular side of the button. Since MDCFloatingButton sets its contentEdgeInsets this API is needed to allow for the two values to be independent.

https://developer.apple.com/documentation/uikit/uibutton/1624036-contentedgeinsets

PiperOrigin-RevId: 322199718
2020-07-20 12:28:27 -07:00
Wenyu Zhang
222ae37fc9 [Floating Button] Add centerVisibleArea support for the FAB and deprecate visibleAreaMode
API.

PiperOrigin-RevId: 320291504
2020-07-08 16:44:05 -07:00
Wenyu Zhang
59c44fb3bd [Buttons] Add centerVisibleArea to MDCButton and mark visibleAreaInsets as to be deprecated.
PiperOrigin-RevId: 320085469
2020-07-07 16:36:33 -07:00
Yarden Eitan
afb87e9860 [Floating Button] Add visibleAreaInsets support for the FAB.
Like the MDCButton, this is opt-in, and the dictionary for the visibleAreaInsets per mode/shape combination is initially empty.

PiperOrigin-RevId: 315152916
2020-06-07 05:34:33 -07:00
Yarden Eitan
e8a1c4e7e1 [MDCButton] Add a visibleAreaInsets API.
This API allows clients to inset the visible content and allow it to be smaller than the frame.
In turn, clients can have a touch target that is bigger than the visible content.

PiperOrigin-RevId: 313556504
2020-05-28 03:17:34 -07:00
Wenyu Zhang
b19e4e964d [ShadowLayer] Add prepareShadowPath to MDCShadowLayer to allow its subclass preparing shadow path before MDCShadowLayer lays out its sublayers.
PiperOrigin-RevId: 313383830
2020-05-27 07:20:37 -07:00
Nobody
e035d70f50 Project import generated by Copybara.
PiperOrigin-RevId: 309039129
2020-04-29 17:00:59 +00:00
Bryan Oltman
f7f154d483 [Buttons] Move button alpha tests into their own file.
PiperOrigin-RevId: 308681214
2020-04-27 13:03:44 -07:00
Bryan Oltman
4f75f7c33f [Buttons] Disable pointer interactions for MDCFloatingButton during animation.
PiperOrigin-RevId: 305879022
2020-04-13 09:23:13 -04:00
Bryan Oltman
5a2b2caae0 [Button] Add custom UIButtonPointerStyleProvider to MDCButton for better iPadOS pointer interaction.
Note: MDCButton does not enable pointer interactivity by default.

This also adds an example to demonstrate MDCButtons with the default UIPointerInteraction enabled. The example exposes an issue with MDCFloatButton's collapse/expand animations (b/153666859), which will be addressed in a future CL.

PiperOrigin-RevId: 305872547
2020-04-13 09:20:43 -04:00
Jeff Verkoeyen
6ac7e6c3d8 [Buttons] Add support to MDCFloatingButton for animating mode changes.
The new API allows the floating button to animate changes between normal and expanded states.

PiperOrigin-RevId: 305703859
2020-04-09 09:57:44 -07:00
Jeff Verkoeyen
bc113b658c [Buttons] Add a snapshot test for floating buttons in normal mode with a label.
This snapshot test demonstrates the incorrect behavior of the title label being visible while the button is in normal mode.

PiperOrigin-RevId: 305668064
2020-04-09 05:49:02 -07:00
Jeff Verkoeyen
57ec631be2 [Buttons] Standardize all test names on <Symbol><TestCategory>Tests.
PiperOrigin-RevId: 305667188
2020-04-09 05:39:30 -07:00
Bryan Oltman
df522841a2 [Buttons] Add inkViewOffset property to allow adjustment of inkView/rippleView. This is pre-work to address an issue in MDCButtonBar, where buttons are assigned asymmetric contentEdgeInsets by MDCAppBarButtonBarBuilder
PiperOrigin-RevId: 304256452
2020-04-01 14:01: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
14c9d903cf
[Buttons] Deletes deprecated MDCFloatingButtonShapeThemer (#9746)
* [Buttons] Deletes deprecated MDCFloatingButtonShapeThemer

* Remove MDCFloatingButtonShapeThemer from tests

* Update docs

* clang
2020-02-18 10:12:36 -05:00
Bryan Oltman
1118f14124
[Buttons] Delete deprecated MDCOutlinedButtonThemer (#9688)
MDCOutlinedButtonThemer is deprecated and has no internal usage.

Fixes #9687
2020-02-11 18:20:18 -05:00
Bryan Oltman
0efb82cf5f
[Buttons] Delete deprecated MDCFloatingActionButtonThemer (#9662)
Deletes the deprecated and unused MDCFloatingActionButtonThemer.

Fixes #9663
2020-02-11 13:34:13 -05:00
Randall Li
fa62718bc5
add deps on availability for a bunch of components (#9679)
* add Availability build file

* add Button deps on availability

* added elevation

* corrected include statements to use import of the umbrella files

* revert unwanted changes

* spaces

* clangformat

* add availability dep

* added buttom nav deps on availibility

* Add FeatureHighlight build dep for Availability

* Add Availability build dep to FeatureHighlight private

* Add missing =

* fixed tabs spacing

Co-authored-by: Bryan Oltman <bryanoltman@gmail.com>
2020-02-11 13:14:09 -05:00
Nobody
421770ca2e [Material][Availability] Migrates Buttons to MDCAvailability.
PiperOrigin-RevId: 293865037
2020-02-07 16:07:05 -05:00
Wenyu Zhang
623986d513 [Buttons] Set contentEdgeInsets in theming for MDCFloatingButton with normal shape.
PiperOrigin-RevId: 292240032
2020-01-29 16:17:08 -08:00
Robert Moore
9c96aa9968
[Buttons] Support non-stateful fonts in theming. (#8650)
The Theming Extensions should support non-state-based title font APIs as
clients migrate to the non-state-based APIs.

Part of #8601
2019-10-24 20:48:31 -04:00
Robert Moore
86ebced717
[Buttons] Add API to disable state-based fonts. (#8606)
Introduces a new API to disable the `titleFont:forState:` APIs. This is the
first step toward removing those APIs.

State-based fonts make it impossible to support UIContentSizeCategoryAdjusting
behavior on the button's `titleLabel`. Providing support for automatic font
resizing for Dynamic Type means removing state-based font APIs.

Part of #8595
2019-10-18 22:37:03 -04:00
Wenyu Zhang
e3784afe25
[Buttons] overwrite intrinsicContentSize method. (#8370)
The `instrinsicContentSize` of `MDCButton` was not aware of `minimumSize` property, which is wrong.
2019-08-27 13:20:54 -04:00
Yarden Eitan
f4352d73e6
[Buttons] Add missing self to traitCollectionDidChangeBlock (#8276)
As part of our work of adding traitCollectionDidChangeBlocks to components, we add self as a parameter to the block, buttons is the only component that seems to be missing it.

This is essentially a breaking change based on our breaking changes conventions.
2019-08-12 10:50:49 -04:00
featherless
af29d5d737
[Buttons] Replace mdc_legacyFontScaling usage with adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable. (#8244)
Part of https://github.com/material-components/material-components-ios/issues/8243
2019-08-08 18:05:19 +00:00
Robert Moore
54fe07bd2e
[Buttons] Use Starlark macros. (#8162)
Updates the BUILD file to use more Starlark macros. This makes it easier to
perform releases. Also fixes a test import so `includes` amendments aren't
required.

Part of #8150
2019-08-01 16:19:02 -04:00
Robert Moore
66435f1b68
[Color] Create umbrella header. (#8091)
All components should have a top-level umbrella header for their includes.
This allows easier refactoring of classes and files within the component.
Creating an umbrella for Color and using it outside the component.

Part of #8086
2019-07-25 15:41:26 -04:00
Robert Moore
403c1b6a29
[Buttons] Support MaterialElevation. (#8073)
Adds protocol conformance for `MDCElevatable` and `MDCElevationOverriding`.

Closes #8023
2019-07-25 09:24:35 -04:00
Bryan Oltman
4fcf3cd5a2
[Buttons] Move MDCButton's defaultContentInset configuration to later in init (#8069)
After digging in a bit, I've found that this is an issue with UIButton in iOS 13 (as of Xcode 11 beta 4). To reproduce:

1) Create a `UIButton`.
2) Create a `UIImage` and flip it using `imageWithHorizontallyFlippedOrientation`.
3) *Before setting the button's image*, give the button non-zero contentEdgeInsets (I used `{20, 10, 20, 10}`).
4) Set the image on the button.

You should be able to see that the image is not visible, and that the button's internal UIImageView's bounds.origin is `{ -(i.left + i.right), -(i.top + i.bottom) }` (where `i` is the button's contentEdgeInsets). In iOS 12, the button's imageView's bounds.origin is `{0, 0}`.


Closes #7983
2019-07-24 16:38:49 -04:00
Cody Weaver
0f8e19aab5
[Buttons] Add dynamic color support (#7914)
In #7858 support for the background color and border color to update its layer was not added. This addresses that and updates the snapshot to reflect all the colors are that CGColors are being updated accordingly.
2019-07-15 10:41:31 -07:00
Cody Weaver
01a2002f9f
[Buttons] Add dynamic color support to MDCButton (#7858)
This change adds dynamic color support to MDCButton. Before this MDCButton wouldn't update its shadowColor in the proper methods causing it to not support Dark Mode properly. This change updates it to call updateShadowColor in layoutSubviews additionally there is a test added for iOS 13+.
2019-07-12 09:48:07 -04:00
Wenyu Zhang
04408e0407
[Buttons] add traitCollectionDidChangeBlock API. (#7853)
Provides an API for clients to respond to `traitCollectionDidChange` without subclassing.

closes https://github.com/material-components/material-components-ios/issues/7854
2019-07-10 16:54:37 -04:00
Cody Weaver
0563c90749
[Buttons] Add support for inkMaxRippleRadius when enableRippleBehavior is set to YES (#7539)
This changes adds support for `inkMaxRippleRadius` when `enableRippleBehavior` is set to `YES`. This was previously not added because Ripple didn't support `maximumRadius` when it was integrated in `Buttons` in #7087. Since `maximumRadius` was added in #7357 this should now be set in Buttons. The getter was removed from Buttons since this is currently setting two properties and then returning one. When we remove ink this could potentially cause a problem if we didn't update the getter. By setting an ivar this should help protect us against our future selfs when ink is removed.
2019-06-05 10:29:19 -04:00
Robert Moore
225decbfb0
[Buttons] Fix fallback behavior for Dynamic Type. (#7514)
The `titleFontForState:` API did not correctly reflect the rendered font
when no explicit fonts were set via the MDCButton APIs. As a result,
calling `updateTitleFont` internally could result in a different font
being returned than what was displayed.

Moving the "fall back" and Dynamic Type behavior into the
`titleFontForState:` method allows more consistent behavior (reduces the
risk of deviations) and corrects the APIs to reflect what is rendered.
This change should result in no visible changes to clients (the rendered
fonts should remain the same), but will result in non-`nil` results
being returned from `titleFontForState:` to correctly reflect the
rendered font for a given state.

Part of #7492
2019-05-30 10:25:13 -04:00
featherless
431988ba84
[Buttons] Add snapshot tests for floating button theming. (#7506)
This is pre-work for being able to annotate MDCFloatingActionButtonThemer as deprecated.

Part of https://github.com/material-components/material-components-ios/issues/5702
2019-05-28 12:03:46 -04:00
Cody Weaver
73adc97de9
[Buttons] Revert updating fonts after adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable has been updated (#7480)
This change reverts the changes in #7466 

This change deviates from the rest of our components therefore we are reverting it to bring buttons into alignment with our other components.
2019-05-24 14:44:04 -04:00
Cody Weaver
6b5cf3f153
[Buttons] Fix issue with legacy dynamic type (#7466)
## Motivation
The possible code paths for the legacy dynamic type when there are no scaling curves associated with a font are as follows

#### Case 1
```swift
button.mdc_adjustsFontForContentSizeCategory = true
button.adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable = true
// This should update the font use the legacy *magic* font
```
#### Case 2
```swift
button.adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable = true
button.mdc_adjustsFontForContentSizeCategory = true
// This should update the font use the legacy *magic* font
```
#### Case 3
```swift
button.adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable = false
button.mdc_adjustsFontForContentSizeCategory = true
// This should *not* update the font use the legacy *magic* font
```
#### Case 4
```swift
button.mdc_adjustsFontForContentSizeCategory = true
button.adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable = false
// This should *not* update the font use the legacy *magic* font
```

Currently we only cover cases 1-3, but it's reasonable for a client to get into _Case 4_, this requires a setter for `adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable` to _undo_ **magic** behavior if the **magic** behavior has been applied.

## Detailed changes
This change adds a setter to `adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable` to update the fonts accordingly and _undo_ any changes done to the component.

Related to #7464
2019-05-23 17:11:03 -04:00
Cody Weaver
face6eac24
[Buttons] Fix up test (#7461)
Fix up test comments added in #7452 and the error messages when the test fail.
2019-05-23 09:04:45 -04:00
Cody Weaver
a085565d50
[Buttons] Update name for fallback behavior. (#7452)
## Motivation
As a team we have decided that `mdc_legacyFontScaling` isn't the correct name for what the flag actually does. We have decided to change the name to `adjustFontForContentSizeCategoryWhenScaledFontIsUnavailable` is a more accurate name.

## Detailed changes
- Deprecate the older API `mdc_legacyFontScaling` so we can delete it in the upcoming release.
- Add API for `adjustFontForContentSizeCategoryWhenScaledFontIsUnavailable`
- Update the getter and setter for `mdc_legacyFontScaling` to mirror `adjustFontForContentSizeCategoryWhenScaledFontIsUnavailable`
2019-05-22 23:56:23 -04:00
Cody Weaver
03d1cbc9d5
[Buttons] Add snapshot test for dynamic type (#7429)
## Motivation
In order to capture the dynamic type visual changes within `MDCButton` for dynamic type we need to add test for the different size categories.

## Detailed changes
Add snapshot test for all `UIContentSizeCategory` values by overriding the `traitCollection` on a _fake_ MDCButton subclass. Currently these snapshots are the same because `MDCButton` uses the `mdc_scaledFontForCurrentSizeCategory` method within `MDCFontScaler` instead of `mdc_scaledFontForSizeCategory:`
2019-05-21 16:10:22 -04:00
Galia Kaufman
7c481c023e
[Buttons] [Ripple] fix button to update ripple states correctly (#7337)
Fixing programmatic interface of buttons to correctly set the Ripple highlighted and select state.

### Description

Buttons do not change the ripple state correctly when their selected or highlighted states are updated programmatically. To fix this issue, we're updating the RippleViews's highlighted and selected states to match the button's highlighted and selected states.

Steps to reproduce the highlighted state issued:
1. set: button.isHighlighted = true 
Expected: button is highlighted (background is light blue)
Outcome: button is not highlighted (background is white)

Steps to reproduce the selected state issued:
1. set: button.isSelected = true 
Expected: button is selected (background is light blue)
Outcome: button is not selected (background is white)

Before: 
![image](https://user-images.githubusercontent.com/2329102/57167435-c60c6300-6dcb-11e9-8e54-3aa96b0f8eb8.png)

After:
![image](https://user-images.githubusercontent.com/2329102/57167455-dd4b5080-6dcb-11e9-864e-cd4d960df464.png)

### Issue
b/128908676
Issue: https://github.com/material-components/material-components-ios/issues/7342
2019-05-19 12:18:34 -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
Cody Weaver
80037e4684
[Buttons] Update titleFont:forState: API (#7402)
## Motivation
As outlined in #5919 many of our `forState:` APIs don't match what `UIButton` is doing. This addresses that problem for our `titleFont` API. This updates the fallback behavior. Additionally this will help facilitate #7388.

## Test
In other test similar to this one we update a `UIButton` with a `UIColor` to make sure the colors match for a given state in given conditions, since `UIButton` doesn't have any `forState` APIs that set a font we can't test this as easily. Also this follows the same pattern outlined in the other PRs to address this issue.
2019-05-16 11:03:35 -07:00
Cody Weaver
62e747ea09
[Buttons] Add snapshot test for theming extensions (#7390)
Adding snapshot test for our theming extensions will allow us to make changes to the theming extensions and catch visual regressions. This additionally will help service our need to add dynamic type to the theming extensions as we now have a file for the theming extensions and we can add test where needed.

In service to #7388
Closes #7392
2019-05-16 05:19:18 -07:00
Wenyu Zhang
b5b4ecd95e
[Buttons] Add fallback behavior to setBorderColor API. (#7140)
closes https://github.com/material-components/material-components-ios/issues/3409
2019-04-21 14:32:01 -04:00