63 Commits

Author SHA1 Message Date
Nobody
a5fd8319a9 Fixed up imports and nullability for ButtonBar
PiperOrigin-RevId: 490068172
2022-11-21 14:14:42 -08:00
Nobody
7b8b54a3cf [MDCButton] titleFontForState: return value is never null, mark as nonnull.
PiperOrigin-RevId: 425549752
2022-02-01 00:14:07 -08:00
Randall Li
502bc5d910 Ran a Swift formatter
PiperOrigin-RevId: 395947664
2021-09-10 09:48:14 -07:00
Yarden Eitan
40453fe9d2 [ButtonBar] Fix use of wrong enum values (using FloatingBar rather than ButtonBar)
PiperOrigin-RevId: 366253794
2021-04-01 08:18:50 -07:00
Jeff Verkoeyen
1abdf16760 Optimizing imports
PiperOrigin-RevId: 357185990
2021-02-12 07:36:41 -08: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
e95d65a96c [ButtonBar] Set inkOffset when given asymmetric contentEdgeInsets.
PiperOrigin-RevId: 304397722
2020-04-02 07:40:55 -07: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
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
e91b5bfb9f [ButtonBar] Use CGSizeZero instead of CGSizeMake(0, 0).
CGSizeZero is more idiomatic when referring to an empty size.

PiperOrigin-RevId: 293222031
2020-02-04 13:57:22 -08:00
Jeff Verkoeyen
45b435c70c [ButtonBar] Add snapshot tests for title color behavior.
These snapshot tests will be used to verify changes in behavior to the title color of buttons.

PiperOrigin-RevId: 293219347
2020-02-04 13:46:20 -08: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
Robert Moore
cab960098b
[ButtonBar] Use Starlark macros. (#8161)
Adds more Starlark macro usage in the BUILD file. This makes releasing easier.

Part of #8150
2019-08-01 15:46:42 -04:00
Robert Moore
8dcf1e4a56
[*] Remove RTL snapshot method overrides. (#7996)
With #7986, most snapshot tests began overriding a method that had nearly the
same behavior.
2019-07-22 21:11:17 -07: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
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
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
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
Andrew Overton
b38372192f
Update to Swift 4.2 (#7166)
This PR updates the Swift version to 4.2.

Partially resolves #6874.
2019-04-17 16:59:02 -04:00
Yarden Eitan
fa7bc44bbf reverting 2019-02-26 11:57:14 -05:00
Yarden Eitan
72be04af6b Revert "[ButtonBar] Use test Typography scheme (#6693)"
This reverts commit 84916db4360bd9b3db0a7fd5312f1760c840019b.
2019-02-26 11:49:22 -05:00
Robert Moore
84916db436
[ButtonBar] Use test Typography scheme (#6693)
Using a test-specific Typography scheme to simplify custom scheme
creation.
2019-02-22 09:44:19 -05:00
Robert Moore
ef9e18ea7f
{Testing} Create mechanism for test fakes and test data (#6673)
Sets up MDC iOS to allow each component to export "Test fakes" and test data for use by other components when performing tests.  The initial commit includes "test data" for MDCTypographyScheme that uses non-default values for each UIFont.

Contributors writing tests, particularly those that use shared components like schemes, can do so more quickly by accessing test data and test fakes directly from the component rather than having to write custom objects for each test.

**Bonus**
The new typography data has already confirmed the Dialogs bug #6637, which would have been discovered sooner if we didn't rely on the typographic defaults that already matched component defaults.

## Typical Usage

### Build/dependency management systems

**bazel BUILD files:**
```
deps = [
        "//components/schemes/Typography:TestingSupport",
],
```

**CocoaPods Podspec files:**
```ruby
  component.dependency "MaterialComponentsTestingSupport/schemes/Typography"
```

### Source includes

**Swift**
```swift
import MaterialComponentsTestingSupport.MaterialTypographyScheme_TestingSupport
```

**Objective-C**
```objc
#import <MaterialComponentsTestingSupporrt/MaterialTypographyScheme+TestingSupport.h>
```
2019-02-21 13:50:29 -05:00
Robert Moore
5ee639cc91
[ButtonBar] Add basic snapshot tests. (#6662)
Add simple layout and theming snapshot tests.
2019-02-20 08:26:00 -05: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
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
featherless
73bdc03c2b
[automated] Rename MaterialComponentsAlpha to MaterialComponentsBeta. (#6018)
This is an automated change generated by replacing all instances of MaterialComponentsAlpha with MaterialComponentsBeta. This is not a breaking change because changes to Alpha/Beta components (including renaming them) are not considered breaking.

The MaterialComponentsAlpha podspec was mistakenly named Alpha, when what we meant was more close to Beta. The distinction is that Alpha components are not expected to be used by clients, while Beta components are.
2018-12-14 10:47:31 -05:00
Randall Li
371f3ac9a7 Add imports for MaterialContainerScheme 2018-12-05 14:35:59 -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
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
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
7f5f920493
[ButtonBar] Remove NSCoding support. (#4553)
Closes https://github.com/material-components/material-components-ios/issues/3947
2018-07-16 08:04:41 -04:00
featherless
c1b513ba9e
[ButtonBar] Add tintColor observation support. (#4380)
This allows button bar buttons to observe the following additional UIBarButtonItem properties:

 - accessibilityHint
 - accessibilityIdentifier
 - accessibilityLabel
 - accessibilityValue
- tag
- tintColor

Closes https://github.com/material-components/material-components-ios/issues/3692.
2018-06-07 16:23:34 -04:00
featherless
fc2671fe94
[ButtonBar] Add unit tests for KVO behavior. (#4379)
These tests verify that the following properties are observed:

- Title
- Image
- Enabled

This change is part of resolving https://github.com/material-components/material-components-ios/issues/3692
2018-06-07 11:23:09 -04:00
featherless
a448657a23
[ButtonBar] Add umbrella headers for all extension targets. (#3462)
Also updated all imports to make use of the umbrella headers.

Pivotal story: https://www.pivotaltracker.com/story/show/157045283
2018-04-24 17:21:12 -04:00
Ali Rabbani
3c112ae350 [ButtonBar] Make left/right insets for image and text buttons consistent (#3397)
Internal testing of this PR is done in cl/193415210. This is a behavior change for text button insets in MDCButtonBar.

NOTE: This doesn't *change* insets for text buttons that are the only button in the bar on iPad, since it still adds a 12pt inset on both sides for it. on iPhone, the additional inset for edge buttons is 4pt, which results in a 16pt inset on the edge side(s).

Before screenshots:
[Text buttons on both sides](https://user-images.githubusercontent.com/2232489/38957009-57ca20fa-4327-11e8-9f62-a92a61c7f20f.png)
[Text button on one side](https://user-images.githubusercontent.com/2232489/38957010-57d6b784-4327-11e8-8971-2c565833052d.png)

After screenshots:
[Text buttons on both sides](https://user-images.githubusercontent.com/2232489/38957016-5c719ee4-4327-11e8-886c-a7b6bdece4b5.png)
[Text button on one side](https://user-images.githubusercontent.com/2232489/38957017-5c7ebd36-4327-11e8-868b-5fde087eb382.png)

closes #3342
2018-04-23 14:40:25 -04:00
featherless
5a372de8fc
[ButtonBar] Add a stateful buttons title color API. (#3414)
This API allows a client to customize the title color for buttons for a given control state.

Related to https://www.pivotaltracker.com/story/show/156934328

Screenshot shows a button with a custom normal and highlighted state. The button on the left is highlighted.

![simulator screen shot - iphone se - 2018-04-19 at 19 51 59](https://user-images.githubusercontent.com/45670/39024065-786db638-440c-11e8-97e8-f6bf3e6c2af7.png)
2018-04-20 10:17:16 -04:00
featherless
a400ff0b30
[ButtonBar] Fix layout behavior when using custom button title font. (#3410)
Button frames need to be updated after the font changes because their frames are not dynamically updated in any layoutSubviews pass.

It may be sensible to update layoutSubviews to do the frame calculations in a follow-up change, but this has the potential to be a behaviorally-breaking change so I've filed a follow-up story: https://www.pivotaltracker.com/story/show/156930078
2018-04-20 10:08:03 -04:00
featherless
289223a5bb
[ButtonBar] Add a Typography Themer. (#3395)
Pivotal story: https://www.pivotaltracker.com/n/projects/2150420/stories/156769836

![simulator screen shot - iphone se - 2018-04-18 at 12 07 32](https://user-images.githubusercontent.com/45670/38957691-396cc5ca-4329-11e8-8a18-5d76cd50b736.png)
2018-04-19 19:55:44 -04:00
featherless
e11d24a110
[ButtonBar] Expose APIs for setting custom button fonts. (#3389)
This introduces a new API to MDCButtonBar that allows the title font to be customized for a given state. This is part of the work required to allow MDCNavigationBar to support custom button title fonts.

Pivotal story: https://www.pivotaltracker.com/story/show/156769836

Example of customization:

![simulator screen shot - iphone se - 2018-04-18 at 12 07 32](https://user-images.githubusercontent.com/45670/38945147-b7971dea-4303-11e8-86ca-31eaf45f416f.png)
2018-04-18 16:47:23 -04:00
Ali Rabbani
9947b8fa2b [ButtonBar] Fix insets for the trailing button bar (#3324)
Fix button insets used in MDCNavigationBar's trailing button bar. 

Internal testing of this PR is done in cl/192473549.

closes #2851
closes #3315
2018-04-12 14:53:57 -04:00
featherless
58afde19c7
Update bazel workspace and version to latest. (#3052) 2018-03-07 10:17:12 -05:00
Mohammad Cazi
cdea5d6836
[MDCButtonBar] add NSSecureCoding. (#2976)
* MDCButtonBar add NSSecureCoding.

* [MDCButton] NSSecureCoding

* Added tests for MDCButtonBar Coding, validation that items respond the given protocol.

* typo
2018-02-23 14:22:43 -05:00
Robert Moore
5879c18c26
[ButtonBar, NavigationBar] Add BUILD file for kokoro (#2598)
* [ButtonBar, NavigationBar] Add BUILD file for kokoro

ButtonBar ColorThemer depends on NavigationBar
NavigationBar depends on ButtonBar
2017-12-11 17:49:26 -05:00