133 Commits

Author SHA1 Message Date
Jeff Verkoeyen
1abdf16760 Optimizing imports
PiperOrigin-RevId: 357185990
2021-02-12 07:36:41 -08:00
Yarden Eitan
30b6cc1703 [ButtonBar] Deprecate inkColor API.
Please use rippleColor instead.

PiperOrigin-RevId: 333366306
2020-09-23 13:57:08 -07:00
Nobody
4511a9f5e4 [ButtonBar] Removes nullability modifiers from file.
PiperOrigin-RevId: 327016891
2020-08-17 07:35:05 -07:00
Yarden Eitan
ae3fc08aac [ButtonBar] Fall back to accessibilityLabel for UILargeContentView when there is an image and no title.
PiperOrigin-RevId: 327013666
2020-08-17 07:08:15 -07:00
Yarden Eitan
7f9d2cc350 [ButtonBar] Adds Large Content Viewer support to MDCButtonBar, MDCNavigationBar, and MDCAppBar.
PiperOrigin-RevId: 326652230
2020-08-14 07:35:52 -07:00
Bryan Oltman
f75ff1a02f Add checks for existence of UIPointerInteraction class to avoid iOS 13 beta crashes
PiperOrigin-RevId: 323838787
2020-07-29 12:10:16 -07:00
Jan Philipp Sachse
3002e9a73f Add UIMenu support to MDCButtonBar.
This will keep the primary action and menu properties of the UIBarButtonItem and apply them to the button.
If no primary action is set, the menu will be used as primary action automatically.

PiperOrigin-RevId: 321320327
2020-07-15 02:03:57 -07:00
Jeff Verkoeyen
b9e978c6e5 [ButtonBar] Remove excess iPad insets from the button bar buttons.
PiperOrigin-RevId: 314924625
2020-06-05 07:31:50 -07:00
Bryan Oltman
e95d65a96c [ButtonBar] Set inkOffset when given asymmetric contentEdgeInsets.
PiperOrigin-RevId: 304397722
2020-04-02 07:40:55 -07:00
Bryan Oltman
57f98a60f2 [ButtonBar] Remove custom shape for MDCButtonBarButton highlight effect.
By default, UIPointerStyle uses the target view's frame for a highlight effect. Providing view.bounds caused the highlight effect to use a zero-origin frame.

PiperOrigin-RevId: 304177779
2020-04-01 07:07:19 -07:00
Bryan Oltman
b05945db18 [ButtonBar] Add highlight pointer effect to MDCButtonBarButtons
PiperOrigin-RevId: 303980616
2020-03-31 09:30:06 -07:00
Bryan Oltman
0da64e1315 [ButtonBar] Move protocol definitions into separate header files
PiperOrigin-RevId: 301653848
2020-03-18 13:25:19 -07:00
featherless
2897baaafb
[ButtonBar] Do not allow implicit downcasting of item views. (#9761)
Prior to this change, it was possible to implicitly downcast item views to UIButton or MDCButton, potentially causing crashes by treating custom views incorrectly as a button and invoking UIButton selectors on it.

This change removes the `__kindof` implicit casting for the _buttonViews ivar so that the buttonViews need to be explicitly casted to a button type.

Related to https://github.com/material-components/material-components-ios/issues/9760
2020-02-19 13:09:33 -05:00
featherless
e3df3459fc
[ButtonBar] Fix crash when assigning tint color, title, or image to bar button item with custom view. (#9759)
When a bar button item with a custom view is provided to the button bar, the custom view is used in place of an MDCButton instance.  6ec9f334f0e093e1d2bf04165895ca725455150e introduced a change that unconditionally called a UIButton API on the views when the tintColor was changed, resulting in a crash when a custom view was used.

This change adds a test that, prior to this fix in this change, crashed, but after the fix included in this change now passes.

Upon inspection of the culprit code, it was revealed that image and title similarly could result in crashes, so those crashes have been fixed as part of this change as well.

Closes https://github.com/material-components/material-components-ios/issues/9760
2020-02-19 09:30:19 -05:00
Jeff Verkoeyen
169cd386a6 [ButtonBar] Assign the UIBarButtonItem's tintColor to the button's text color.
Prior to this change, UIBarButtonItem's tintColor property would not change the title color of the corresponding button. This differs from the UIKit behavior, which does result in the title color being changed.

After this change, changing a UIBarButtonItem's tintColor will result in the corresponding button's title color being updated as well.

PiperOrigin-RevId: 293848033
2020-02-07 16:03:52 -05:00
Jeff Verkoeyen
b30d4c9162 [FlexibleHeader] Add missing self-> within a block.
Resolves the following error:
"Block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior"

PiperOrigin-RevId: 293801599
2020-02-07 06:24:51 -08:00
Jeff Verkoeyen
aca8bbd5e2 [ButtonBar] Rolling back "Assign the UIBarButtonItem's tintColor to the button's text color."
PiperOrigin-RevId: 293609216
2020-02-06 09:33:45 -08:00
Jeff Verkoeyen
eb528a9349 [ButtonBar] Assign the UIBarButtonItem's tintColor to the button's text color.
Prior to this change, UIBarButtonItem's tintColor property would not change the title color of the corresponding button. This differs from the UIKit behavior, which does result in the title color being changed.

After this change, changing a UIBarButtonItem's tintColor will result in the corresponding button's title color being updated as well.

PiperOrigin-RevId: 293583337
2020-02-06 06:56:22 -08:00
Jeff Verkoeyen
6ec9f334f0 [ButtonBar] Refactor title color logic to a single location.
The title color logic was previously being applied in three different places in slightly different ways each time. This change consolidates the logic into a single method and invokes this new method from each place where the title color can change; namely:

1. When initially creating the button.
2. When the button's tintColor context changes.
3. When the button item's tintColor property changes.

PiperOrigin-RevId: 293580183
2020-02-06 06:33:14 -08:00
Andrew Overton
8814a6f55c
Revert "Revert "Delete MDCButtonBarColorThemer (#9235)"" (#9272)
This PR brings back https://github.com/material-components/material-components-ios/pull/9235, which was reverted because [cl/285188391](http://cl/285188391) had not actually been submitted when #9235 was merged. It is now safe to merge.
2019-12-16 09:45:32 -05:00
Randall Li
798352bf09 Revert "Delete MDCButtonBarColorThemer (#9235)"
This reverts commit d0c581e993a7de09c95a2b6c067733fed0239c0b.
2019-12-12 07:21:10 -05:00
Andrew Overton
d0c581e993
Delete MDCButtonBarColorThemer (#9235)
Delete MDCButtonBarColorThemer. Closes #9137.
2019-12-10 14:52:17 -05:00
Andrew Overton
1e167e2376
[ButtonBar] Deprecate MDCButtonBarColorThemer (#9155)
Associated CL: [cl/284204381](http://cl/284204381)
Related to #9138
Related to #9137
2019-12-06 15:17:32 -05:00
Andrew Overton
7ece2c1187
delete-MDCButtonBarTypographyThemer (#9117)
Related to #9105.
2019-12-05 15:37:31 -05:00
featherless
fb36f304ba [ButtonBar] Delete the Theming extension. (#8696)
This target is deprecated and unused internally.

Part of #8429
2019-11-12 13:19:19 -08: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
featherless
0f7ee59f13 [ButtonBar] Deprecate Theming and TypographyThemer. (#8432)
Part of #8429

These targets have no internal usage.
2019-09-10 11:21:00 -04:00
Eric Lee
d389bcc346 [Beta] Fixes beta components CocoaPods build. (#8134)
I was seeing build errors when compiling the beta components after installing using CocoaPods.  This appeared to fix those issues.
2019-08-09 13:14:21 -04:00
Wenyu Zhang
1d03b28fb6
[ButtonBar] add traitCollectionDidChangeBlock support. (#7976)
closes #7979
2019-07-22 13:56:09 -04:00
Yarden Eitan
19ef3dd2c2
[ButtonBar] Adds the Ripple behavior to ButtonBar. (#7593)
## Related links
* Bug: Closes #7379 
* Ripple: [Ripple](https://github.com/material-components/material-components-ios/tree/develop/components/Ripple)

## Introduction
This PR allows enabling the Ripple Behavior for `MDCButtonBar` by enabling the ripple behavior of the internal `MDCButton`s. This behavior is an opt in flag property added to MDCButtonBar, `enableRippleBehavior`.  This improves the visual touch feedback for our users as MDCInkView didn't support our current motion guidelines. We are also marking any of the Ink APIs ToBeDeprecated as part of the [Deprecation Policy](cb6b8e9599/contributing/deprecation_policy.md (step-4-add-a-comment-to-the-api-indicating-that-it-will-be-deprecated)).

## Videos
| Before | After |
| - | - |
|![oldRipple](https://user-images.githubusercontent.com/4066863/59468585-707e9980-8e00-11e9-8eb4-f6709ea3af94.gif)|![newRipple](https://user-images.githubusercontent.com/4066863/59468588-72e0f380-8e00-11e9-992f-9fecc8383dd7.gif)|
2019-06-15 14:33:13 -04:00
featherless
0d8d010ed1 [ButtonBar] Fix a typo in the docs for rectForItem:inCoordinateSpace:. (#7496)
Part of #7248
2019-05-25 01:53:02 -04:00
featherless
631779545e
[ButtonBar] Expose a rectForItem:inCoordinateSpace: API. (#7438)
This API will allow clients to present overlay views that point to views in an MDCButtonBar.

Expected usage:

```swift
@objc func didTapButton(_ item: UIBarButtonItem) {
  let rect = buttonBar.rect(for: item, in: view)
  // Present an overlay pointing at `rect`
}
```

Closes https://github.com/material-components/material-components-ios/issues/7248
2019-05-22 14:00:19 -04:00
featherless
59e1577ca3
[ButtonBar] Annotate themer APIs with the recommended APIs. (#7217)
Part of https://github.com/material-components/material-components-ios/issues/7108
2019-04-22 19:56:00 +03:00
Robert Moore
800188a649
{clang-format} Format the components. (#6347)
This is a follow-up to https://github.com/material-components/material-components-ios/pull/6027

```
find components \( -name "*.h" -or -name "*.m" \) | xargs clang-format -i
```
2019-01-23 11:08:43 -05:00
Yarden Eitan
2803125b2c
ran clang-format (#6027) 2019-01-11 13:23:51 -05:00
Andrew Overton
056e4701f0
Make pod install work on Cocoapods 1.6.0.beta.2 (#5966)
# Original PR description:

On Cocoapods version 1.6.0 beta 2 we get an error on pod install because certain test targets don't have any sources to compile. This PR adds some skeleton unit test source files to get that working. Is everyone okay with these (for now) basically empty files?

Closes #5825

# FInal PR description:

The original aim of this PR was to get the project working with the Cocoapods 1.6 beta.

I initially didn't know where to begin getting it to work, so I used `pod lib lint` to get answers. `pod lib lint` had issues with the following things:

1. test_specs not having any sources to compile. This was due to our pattern of putting unit test test_specs inside of parent test_specs that didn't have anything else.

To address this I did two things. First, I moved away from the nested test_spec pattern. Now, instead of "Subspec/tests/unit_tests" it's "Subspec/UnitTests". This is more in line with the style Cocoapods uses [here](http://blog.cocoapods.org/CocoaPods-1.6.0-beta/). Secondly, I added some dummy files for things like UIMetrics and MaterialMath.

2. Importing headers across modules without using framework style imports.

I added framework style imports. This required some additional rewrite rules in the kokoro script.

3. Dependencies across subspecs being implicit.

I made them explicit by adding dependency statements to the podspecs where needed. 

`pod lib lint` didn't take issue with this, but I also saw that `MaterialComponents` was depending on `MaterialComponentsBeta` in various places. For example, all the theming extensions were in beta, but the tests for them weren't. I moved the tests to test_specs within the beta extensions. This required some directory structure changes. These changes then required some BUILD file changes. Making BUILD file changes made me realize that some swift unit tests weren't being accounted for by bazel. I took care of this too.

This PR also fixes some swift debugging stuff--"po" statements that weren't working before now do. I didn't rigorously verify this, but I also think this PR will lead to faster clean build times? It kinda seemed like it was while I was working on it.
2019-01-11 10:08:05 -05:00
Cody Weaver
1ca10a8669
[Theming] Update our theming extensions (#5945)
### Context
All of our theming targets should be `MDC<#Component>+Theming` but all files should be `MDC<#Component>+MaterialTheming.m/h`. We got out of sync and caught this early.

### The problem
Our targets and file names weren't correct in some cases

### The fix
Update our targets and files to be what we have decided as a team.
2018-12-10 14:16:37 -05:00
featherless
8806821243
[ButtonBar] Add a Theming extension. (#5843)
This change makes use of MDCContainerScheme to provide a single theming-related API for ButtonBar.

Includes example updates unit tests.

This change is the first in a series of changes that will be required to add Theming extension support to AppBar:

- [x] ButtonBar
- [ ] NavigationBar
- [ ] HeaderStackView
- [ ] FlexibleHeader
- [ ] AppBar
2018-12-04 09:40:12 -05: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
74a27253e8
Global replace of integral single-precision literals with integer literals. (#5709)
Global replace of integral single-precision literals with integer literals.

Regular expression used:
```perl
/[^\w]([0-9]+)\.[0]*[fF]/$1/
```
2018-11-08 14:02:04 -05:00
rami-a
4766299a56
[ButtonBar] Fix incorrect casts in ButtonBar (#5358)
This change updates a couple of improper casts in ButtonBar that had the potential to cause a crash.
Closes #4934
2018-10-08 14:22:15 -04:00
featherless
471936b842
[ButtonBar] Add a buttonBarDidInvalidateIntrinsicContentSize API to the delegate. (#4932)
This will allow the owner of a button bar to react to changes in the button bar's intrinsic size.

We need to add this delegate because I'm not aware of an equivalent UIKit mechanism that works with views that aren't using auto layout (the MDCNavigationBar uses manual layout).

In a follow-up change, MDCNavigationBar will implement this delegate and update the layout of its left/right button bars as a result.

Part of https://github.com/material-components/material-components-ios/issues/1717
2018-08-31 14:10:56 -04:00
featherless
2181084272
[automated] Standardize our open source license stanza to what Xcode generates. (#4985)
Removes the need to copy-paste stanzas from other files anymore as we'll rely on #4478 to generate the correct stanza for us instead.

This was an automated change generated by running a find-and-replace regular expression:

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at

 http://www\.apache\.org/licenses/LICENSE-2\.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
/\*
Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

Licensed under the Apache License, Version 2\.0 \(the "License"\);
you may not use this file except in compliance with the License\.
You may obtain a copy of the License at

http://www\.apache\.org/licenses/LICENSE-2\.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
See the License for the specific language governing permissions and
limitations under the License\.
\*/
```

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.
 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at
 http://www\.apache\.org/licenses/LICENSE-2\.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
// Copyright $1-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
```
2018-08-31 12:13:07 -04:00
Jeff Verkoeyen
9854044c96 Revert "[automated] Standardize our open source license stanza to what Xcode generates. (#4982)"
This reverts commit b45bc2fdd4dfe12fc76751a45c9cf7b0d6c1261f.
2018-08-31 12:01:24 -04:00
featherless
b45bc2fdd4
[automated] Standardize our open source license stanza to what Xcode generates. (#4982)
Removes the need to copy-paste stanzas from other files anymore as we'll rely on https://github.com/material-components/material-components-ios/pull/4478 to generate the correct stanza for us instead.

This was an automated change generated by running a find-and-replace regular expression:

### Find

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at

 http://www\.apache\.org/licenses/LICENSE-2\.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.
 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at
 http://www\.apache\.org/licenses/LICENSE-2\.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

### Replace

```
// Copyright $1-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
```
2018-08-31 11:49:00 -04:00
featherless
5d0e7ccfa8
[ButtonBar] Add uppercasesButtonTitles API for modifying title casing behavior. (#4935)
This change enables us to expose a similar API in MDCNavigationBar that will enable configuration of title casing behaviors for navigation bar button bars.

Step 1/2 for https://github.com/material-components/material-components-ios/issues/2968
2018-08-29 09:41:03 -04:00
featherless
aa2b2189d2
[ButtonBar] Annotate MDCButtonBarDelegate's only API as deprecated. (#4931)
This API is only used internally and is a layer of indirection that is not necessary.

The API has no internal usage or reasonable mechanism for use publicly, so we are marking it deprecated immediately.

Closes https://github.com/material-components/material-components-ios/issues/2943
2018-08-28 17:29:44 -04:00
featherless
bc6dfc007f
[ButtonBar] Add support for pure Swift class button invocations. (#4878)
Repro case:

Add the following code to a view controller with an App Bar:

```swift
class SomeObject {
  @objc func someEvent() {

  }
}

let object = SomeObject()

self.navigationItem.rightBarButtonItem =
  UIBarButtonItem(title: "Right", style: .done, target: object, action: #selector(SomeObject.someEvent))
```

Tap the button.

Expected behavior: the someEvent method is invoked.
Actual behavior: crash due to unrecognized selector `methodSignatureForSelector:`.

After this change the behavior works as expected, with the caveat being that we are not able to pass the button instance along as a third argument to pure Swift classes. The implication of this is that pure Swift classes will not be able to present popovers from the provided item instance. Supporting this case will require turning the pure Swift class into an Objective-C compatible class.

Closes https://github.com/material-components/material-components-ios/issues/2981
2018-08-24 10:51:40 -04:00
featherless
e89ece3bb8
[ButtonBar|NavigationBar] Remove custom iPad heights. (#4874)
Historically we had given navigation bars different heights on iPads. We no longer intent to make this distinction.

This change also fixes a bug related to this difference in behavior on iPads. The repro case for this bug is:

- Launch MDCDragons on an iPad Pro running 10.3.1.
- Open the App Bar typical use example.
- Scroll the content down somewhat.

Expected behavior: the navigation bar does not change its height or shift.
Actual behavior: the navigation bar shifts slightly as the scroll view is scrolled.

After this change, the navigation bar's height will always default to the same fixed height on all devices. This reflects the fact that Flexible Header's default minimumHeight and maximumHeight values are constant across all devices.

Closes https://github.com/material-components/material-components-ios/issues/4840
2018-08-23 09:48:10 -04:00
featherless
e14b90e829
[schemes/Color] Formally mark all to-be-deprecated APIs as "ToBeDeprecated". (#4738)
This change further formalizes our pattern of annotating APIs that will be or are deprecated using class categories. Moving an API into such a category has the benefit of being picked up by the API diff toolchain and elevated into our release notes as a result.
2018-08-09 16:39:56 -04:00