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
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
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
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
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
Resolves the following error:
"Block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior"
PiperOrigin-RevId: 293801599
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
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
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
# 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.
### 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.
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
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
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
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.
```
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.
```
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
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
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.