149 Commits

Author SHA1 Message Date
Nobody
9e1c0c0a45 Internal change
PiperOrigin-RevId: 477458164
2022-09-28 08:26:32 -07:00
Nobody
7b8b54a3cf [MDCButton] titleFontForState: return value is never null, mark as nonnull.
PiperOrigin-RevId: 425549752
2022-02-01 00:14:07 -08:00
Alyssa Weiss
2c8d5d5fe8 Remove custom pointer interaction handling from MDCButton.
PiperOrigin-RevId: 410787812
2021-11-18 06:42:53 -08:00
Randall Li
502bc5d910 Ran a Swift formatter
PiperOrigin-RevId: 395947664
2021-09-10 09:48:14 -07:00
Alyssa Weiss
07075f8e7a Remove adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable property from MDCButton.
PiperOrigin-RevId: 377352366
2021-06-03 12:53:33 -07:00
Jeff Verkoeyen
a8e4831fd0 Flattening all unit tests into single directories as per convention.
PiperOrigin-RevId: 367426300
2021-04-08 07:33:29 -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
Bill Griesau
9a8399a566 [Buttons] Fix bug where updating MDCButton's title case does not affect attributed titles.
PiperOrigin-RevId: 345738853
2020-12-04 12:59:45 -08:00
Wenyu Zhang
a25c55ee80 [MDC-iOS/FAB] Add shape API to allow changing FAB's shape after it is initialized.
PiperOrigin-RevId: 340492344
2020-11-03 11:52:40 -08:00
Wenyu Zhang
615f273a41 [MDC-iOS/FAB] Remove deprecated setVisibleAreaInsets:forShape:inMode: API.
PiperOrigin-RevId: 340446430
2020-11-03 08:14:18 -08:00
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
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
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
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
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
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
403c1b6a29
[Buttons] Support MaterialElevation. (#8073)
Adds protocol conformance for `MDCElevatable` and `MDCElevationOverriding`.

Closes #8023
2019-07-25 09:24:35 -04: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
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
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
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
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