79 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
Alyssa Weiss
ef9fd05593 Remove all checks for iOS 10 availability now that components support iOS 10+
PiperOrigin-RevId: 331076636
2020-09-10 21:02:06 -07:00
Yarden Eitan
5d3662f0a2 [BottomNavigation] Provide an API to set the bar's height.
PiperOrigin-RevId: 330937608
2020-09-10 08:05:49 -07:00
Alyssa Weiss
01b1cbaa66 Remove pre-iOS 10 handling for voiceover now that components support iOS 10+
PiperOrigin-RevId: 329963061
2020-09-03 11:54:09 -07:00
Wenyu Zhang
f854548b97 [BottomNavigation] Delete deprecated sizeThatFitsIncludesSafeArea property.
PiperOrigin-RevId: 328623723
2020-08-26 15:44:01 -07:00
Alyssa Weiss
fb9eec8ba0 Set default horizontal item padding to 0
PiperOrigin-RevId: 328352160
2020-08-25 10:09:48 -07:00
Andrew Overton
b22eef526f [BottomNavigation] Move MDCBottomNavigationBarController to main podspec
PiperOrigin-RevId: 326698570
2020-08-14 11:48:35 -07:00
Alyssa Weiss
4a3058d591 [BottomNavigation] modify layouts with division to use floor(), as not using this was causing some non integer pixel values, which then resulted in a blurry layout
PiperOrigin-RevId: 326527243
2020-08-13 14:45:00 -07:00
Bryan Oltman
ef1cc6dfd7 [BottomNavigation] Shrink UIPointerEffect frame size to fit content of navigation item views.
This brings BottomNavigation more in-line with UITabBar - see the Photos app for reference.

PiperOrigin-RevId: 305129590
2020-04-06 15:23:49 -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
Andrew Overton
c068063cad
[BottomNavigation] Add horizontal padding property to MDCBottomNavigationBar (#9765)
This PR makes what was a hard coded horizontal padding value a configurable property on MDCBottomNavigationBar.

Closes #9307
2020-02-21 14:46:43 -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
770095c612 Adds availability macro for conditionally compiling OS sensitive code.
PiperOrigin-RevId: 293067907
2020-02-03 20:55:35 -08:00
Eric Lee
69d39caeb9 [BottomNavigation] Adds large content viewer support (#9451)
Introduces support for `UILargeContentViewer` and its associated classes and protocols on iOS 13 and later. 

*   On iOS 13 and later, `MDCBottomNavigationBar` will present a large content view when the platform's requirements are met.
    *   Larger Text is enabled with an `Accessibility...` size selected.
    *   User long-presses on a Bar Item.
*   On iOS 9-12, this behavior will remain associated with the `MDCBottomNavigationBarController` only, and the view will not have this behavior built-in.

Closes #8343
2020-01-25 22:26:36 -05:00
Robert Moore
e51a83afeb
[BottomNavigation] Fix bug in delegate method call (#9489)
[BottomNavigation] Fix bug in delegate method call

The MDCBottomNavigationBarController checks the wrong delegate method before calling `-bottomNavigationBarController:shouldSelectViewController:`. This can lead to crashes in clients that do not implement this method, but implement `-bottomNavigationBarController:didSelectViewController:`.

Fixes #9483
2020-01-24 15:01:19 -05:00
Wenyu Zhang
ab901f7654
Revert "[ColorScheme] deprecate init method and update documentation to reflect its purpose. (#9391)" (#9396)
This reverts commit 5fc6ec2f96e69f1e4c579ca69344557ad83329f2.
2020-01-09 13:54:20 -05:00
Wenyu Zhang
5fc6ec2f96
[ColorScheme] deprecate init method and update documentation to reflect its purpose. (#9391)
closes https://github.com/material-components/material-components-ios/issues/9390
2020-01-08 18:07:01 -05:00
Andrew Overton
d89eb249aa
delete-MDCBottomNavigationBarTypographyThemer (#9234)
delete MDCBottomNavigationBarTypographyThemer. Closes #9158.
2019-12-11 10:52:08 -05:00
Bryan Oltman
1ae1e4cbbb
[BottomNavigation] Delete MDCBottomNavigationBarColorThemer (#9198)
Deletes MDCBottomNavigationBarColorThemer. MDCBottomNavigationBarColorThemer has been deprecated and has no internal usage.

Fixes #9130
Fixes #9161
2019-12-09 14:17:42 -05:00
Robert Moore
d19d388292
[BottomNavigation] Add support for custom badge and text colors. (#8518)
Allows clients to set a custom badge background and text colors for all
badges. On iOS 10+, the `UITabBarItem badgeColor` API allows customizing
individual items' badge background colors as well. Setting the badge
background and text color will allow clients using badges on Bottom Navigation
to better-support Dark Mode.

Closes #2833
2019-09-27 22:04:57 -04:00
Eric Lee
815d3745eb [BottomNavigation] Adds state restoration support to the bottom navigation bar controller. (#8117)
Enables clients to opt-in to state restoration by providing `restorationIdentifier` values for the Bottom Navigation controller's child view controllers.

Closes #8265
2019-08-09 12:36:19 -04:00
Robert Moore
30de3a8756
[BottomNavigation] Propagate accessibilityHint to the accessibility element. (#8241)
The UIButton subview of the Bottom Navigation bar should be the
one receiving the `accessibilityHint` value from the UITabBarItem. There's no
ill effect if the itemView also receives the hint, and preserving that
behavior is less likely to break clients.
    
In the long term, it's reasonable to remove the `accessibilityHint` from the
item view directly, since it's not an accessibility element and doesn't need
the hint to be set.
    
Closes #7290
2019-08-08 11:51:36 -04:00
Robert Moore
e50b9be8bc
[BottomNavigation] Don't assign accessibilityIdentifier to the item view (#8240)
Creates an explicit assignment of `UITabBarItem`'s `accessibilityIdentifier`
to the actual accessibility element of the item view.

The item views should not have accessibility identifiers because they are not
accessibility elements. Reusing the same identifier for both the button and
the view makes it harder to perform automated UI tests.

Closes #8137
2019-08-08 09:58:10 -04:00
Eric Lee
3b54f2c6ea [BottomNavigation] Renames functions and fixes comments. (#8133) 2019-08-03 07:48:12 -04:00
Robert Moore
3c03bd05d6
[BottomNavigation] Use Starlark macros. (#8159)
Adds more Starlark marcro use and drops the need for `includes` in the private
headers target. Reusing these macros makes it easier for weekly releases.

Part of #8150
2019-08-01 15:30:02 -04:00
Robert Moore
9e936bfb62
[BottomNavigation] Test for additionalSafeAreaInsets behavior. (#8113)
This test ensures that the `additionalSafeAreaInsets` property of child VCs is
correctly set to account for the bottom navigation bar.

Confirmation of #8112
2019-07-31 08:30:53 -04:00
Robert Moore
bce0f4937b
[BottomNavigation] Test for mdc_overrideBaseElevation (#8075)
Adds a test for the default value.

Part of #8026
2019-07-25 09:23:57 -04:00
Robert Moore
eed4679d88
[BottomNavigation] Make KVO safe for nil. (#8083)
For most of the `UITabBarItem` `NSString` properties, setting them to `nil` after assigning the item to the Bottom Navigation bar resulted in a raised exception that can crash an app. The KVO code is being updated to match the style in MDCButtonBar to make it safe for `nil` values.

Closes #8082
2019-07-25 06:52:55 -04:00
Robert Moore
9ed52651c4
[BottomNavigation] Store child VCs in childViewControllers. (#7992)
The `MDCBottomNavigationBarController` was incorrectly only adding its child
view controllers as "proper" child view controllers when they became the
selected view controller. This resulted in difficulties when attempting to
perform state restoration within apps with the controller as the root view
controller.

Closes #7984
2019-07-24 13:30:49 -04:00
Robert Moore
4768e610a8
[BottomNavigation] Add MDCElevation support. (#8038)
Adds support for the `MDCElevatable` and `MDCElevationOverriding` protocols.

Closes #8026
2019-07-24 13:30:21 -04:00
Cody Weaver
3d62ea7a29
[BottomNavigation] Add shadowColor API. (#7910)
This change adds a shadowColor API so that clients can customize the color of their shadow within bottom navigation. Unit test have been added for a custom shadow color and the default shadow color as well as iOS 13 test to make sure it responds to dynamic colors.

Closes #7882
2019-07-15 08:21:15 -07:00
Robert Moore
fcf9b24138
[BottomNavigation] Add traitCollectionDidChangeBlock API. (#7893)
Provides a new API to allow a block of code to be executed when the Bottom
Navigation bar receives a `-traitCollectionDidChange:` call.

Closes #7892
2019-07-11 21:16:24 -04:00
Cody Weaver
f7ac1dbbbb
[BottomNavigation] Add theming extension (#7691)
Adds a theming extension to the bottom navigation component. This follows the guidelines outlined in the design doc.

Design doc: go/mdc-ios-theming-extensions.

Closes #7565
2019-06-24 13:21:38 -04:00
Yarden Eitan
9246b77e5e
[BottomNavigation] Adds the Ripple behavior to BottomNavigation. (#7589)
## Related links
* Bug: Closes #7377  
* Ripple: [MDCRippleTouchController](https://github.com/material-components/material-components-ios/tree/develop/components/Ripple)

## Introduction
This PR integrates [`MDCRippleTouchController`](https://github.com/material-components/material-components-ios/blob/develop/components/Ripple/src/MDCRippleTouchController.h) into [`MDCBottomNavigationBar`](https://github.com/material-components/material-components-ios/tree/develop/components/BottomNavigation). This behavior is an opt in flag property added to MDCBottomNavigationBar, `enableRippleBehavior`.  This improves the visual touch feedback for our users as MDCInkView didn't support our current motion guidelines.

## Videos
| Before | After |
| - | - |
|![oldRipple](https://user-images.githubusercontent.com/4066863/59464465-81c2a880-8df6-11e9-82a1-be6b2e4b3840.gif)|![newRipple](https://user-images.githubusercontent.com/4066863/59464470-82f3d580-8df6-11e9-8df3-9fcd9d36d1f6.gif)|
2019-06-15 18:10:32 -04:00
Robert Moore
3d6549c941
[BottomNavigation] Default sizeThatFitsIncludesSafeArea to NO. (#7554)
Flipping the default value of the flag to `NO` as part of the
migration/deprecation process. Internal clients were migrated
previously, but a few new instances might have appeared.

Part of #6716

## Release note

This should have no impact on the release. All client teams were migrated previously. Any breakage in the release could be mitigated by:

```
self.bottomNavigationBar.sizeThatFitsIncludesSafeArea = YES;
```
2019-06-11 08:43:11 -04:00
Robert Moore
c360a7db77
[BottomNavigation] Log accessibility string failure values in tests. (#7326)
Unit tests for some accessibility value strings were not logging the values
during failures. Using the recommended XCTest APIs provides automatic logging
and is preferable to manual equality checking.

Fixes #7325
2019-05-06 12:57:32 -04:00
Eric Lee
b8d1456ec6 [BottomNavigation] Adds private method to retrieve tab bar item for point (#7086)
This is part of a larger effort to implement the dynamic type long press accessibility feature. 

Closes #7123
2019-04-16 08:51:03 -04:00
Robert Moore
1e5f957ed7
[BottomNavigation] Add multi-line title support. (#6999)
Adding support for multi-line titles when the icon and text are vertically stacked.

Closes #6955
2019-04-01 09:59:34 -04:00
Robert Moore
5d699448d1
[BottomNavigation] Fix image updates in ItemView (#6847)
When the `selectedImage` or `image` values were changed on
MDCBottomNavigationItemView, it was accidentally updating the view's
UIImageView regardless of its current selection state. By checking the
current state and only updating as-needed, changes to the icons don't
show up incorrectly.

Fixes #6846
2019-03-13 08:46:24 -04:00
Eric Lee
d049bc882a [BottomNavigation] Prevents the client from setting the navigation items directly when using the bottom navigation bar controller. (#6773)
Observes the navigation bar's items property and if at anytime the new items do not equal the view controllers' tab bar items an exception will be thrown.

Closes #6785
2019-03-11 15:51:28 -04:00
Robert Moore
3447c7b719
{Tests} Fix font comparison in Objective-C. (#6789)
Several unit tests were using identity comparison operations
(`XCTAssertEqual`) instead of equality comparison (`XCTAssertEqualObjects`).
Because UIFont supports `NSCopying`, assigning a UIFont to a `copy` property
can result in a copied object.

Unit tests seemed to flake sometimes, most recently in a Pull Request for
Dynamic Type (#6733).

QA=Unit tests pass
2019-03-07 10:04:40 -05:00
Robert Moore
5ca3f34742
[BottomNavigationBar] Add autolayout support (#6612)
Adds support to BottomNavigationBar to more easily work with Autolayout.  

* `intrinsicContentSize` returns the correct size of the bar items as content.
* `barItemsBottomAnchor` allows anchoring the Bottom Navigation bar to the safe area layout guide.

Updates the `MDCBottomNavigationBarController` to use the new layout anchor and eliminates the need to respond to safe area changes in the view controller.

Fixes #4520
2019-03-01 12:56:59 -05:00
Robert Moore
d58c49c7ec
[BottomNavigation] sizeThatFits: ignores safe area (#6717)
The BottomNavigationBar's `sizeThatFits:` method should ignore its
current safe area. The superview or view controller should be
responsible for setting the bar's bounds and positioning it. The bar
itself should focus its sizing methods on its internal contents.

This change includes a migration flag that clients can use to enable the new behavior. This allows the change to be landed internally without making breaking changes to client code. Clients can then update their layout code to correctly account for the safe area.

Affects #6716
2019-02-27 22:15:59 -05:00
Robert Moore
10f39dab22
[BottomNavigation] Fix Item View layout. (#6603)
Uses the [layout specifications from the Material Guidelines
article](https://material.io/design/components/bottom-navigation.html#specs)
to correctly lay out the item view. Of notable import, the label will
now be clipped if it would otherwise extend outside of the view's frame.
This allows the inter-item spacing to be preserved in
MDCBottomNavigationBar.

The previous layout of the Item View was incorrect. Rather than using
the entire view bounds efficiently, it was placing the icon at 20% from
the leading edge of the view, then placing the bounds (potentially)
outside the frame of the view.

Part of #6520
2019-02-12 13:54:34 -05:00
Robert Moore
3f7477d847
[BottomNavigation] Fix badge position and font. (#6602)
The item badge font was too large based on the mocks provided on the
Material.io guidelines article.

It was also incorrectly positioned when the number of characters increased.
The position of the badge is determined by its top-leading corner and it
grows with the label toward its trailing edge. The previous alignment
accidentally positioned the label's center at an offset from the icon
frame.

|State|Screenshot|
|---|---|
|Before|![bn-catalog-develop](https://user-images.githubusercontent.com/1753199/52609607-d60b4b00-2e4b-11e9-87d9-e78233b23307.png)|
|After|![bn-catalog-after](https://user-images.githubusercontent.com/1753199/52609614-dacfff00-2e4b-11e9-9d66-31b1d781696d.png)|



## Animation comparing this change with Material Guidelines
![bn-badge-compare-guidelines](https://user-images.githubusercontent.com/1753199/52609487-7b71ef00-2e4b-11e9-812c-a0475f9781d0.gif)


Part of #6520
2019-02-12 08:35:49 -05:00
Robert Moore
0c2b2ea61b
[BottomNavigation] Delete itemsContentInsets API (#6584)
The `itemsContentInsets` API behaves unintuitively and is not used by
any internal clients. Since the Material Guidelines article for Bottom
Navigation does not allow customization of the positioning of the item
views within a Bottom Navigation, it's simply extra maintenance effort
without any clear value.

Resolves #6556
2019-02-11 12:57:22 -05:00
Robert Moore
cd2a67896e
[BottomNavigation] Add support for blur effect. (#6587)
Add support for blurring the view behind the BottomAppBar if the `barTintColor` of the MDCBottomNavigationBar is transparent.  A dragons catalog example is added in #6589

## Example using Material baseline theming and 85% alpha

|Before|After|
|---|---|
|![bn-noblur-baseline](https://user-images.githubusercontent.com/1753199/52528917-93186e80-2cb7-11e9-9c72-4589add39c23.gif)|![bn-blur-baseline](https://user-images.githubusercontent.com/1753199/52528924-9d3a6d00-2cb7-11e9-97c4-9e24ce68752b.gif)|

## Notes
This renames `inkClippingView` to `barView`.  Since `blurEffectView` is a sibling of `barView`, the new name seems more related to the view's presentation.

Closes #5217
2019-02-11 11:21:49 -05:00
Robert Moore
24ec11d91f
[BottomNavigation] Add sizeThatFits: to Item View (#6559)
The MDCBottomNavigationItemView did not implement sizeThatFits: and so it was
not possible for the MDCBottomNavigationBar to interrogate the view for its
appropriate size during layout.

Part of #6520
2019-02-05 15:13:20 -05:00
Robert Moore
b1e9182aaf
[BottomNavigation] Simplify and improve badge view. (#6544)
## Visual Improvements
Improves the badge view to better match the [Material.io guidelines article for Bottom Navigation](https://material.io/design/components/bottom-navigation.html#behavior).  It decreases the horizontal margins on either side of the text to provide a more circular shape when few numerals are present. It also adds support for a dedicated empty badge where no text is provided instead of relying on a string of spaces. 

<img width="728" alt="material-bottomnav-badge-example" src="https://user-images.githubusercontent.com/1753199/52158868-bc5b4e00-266a-11e9-8bad-a5d7bc7567d4.png">

Here is the typical use example bar in the Dragons catalog as it appears after this change:

|State|Image|
|---|---|
|Before|![badge-layout-develop](https://user-images.githubusercontent.com/1753199/52159942-6b068b00-2679-11e9-974a-e813aa211d09.png)|
|After|![badge-layout-trig](https://user-images.githubusercontent.com/1753199/52160891-41565f80-268b-11e9-9d4d-94cad201cb4a.png)|

And an overlay of the Material guidelines version and this PR for an empty badge:
<img width="530" alt="material-mdcios-comparison" src="https://user-images.githubusercontent.com/1753199/52159041-0fce9b80-266d-11e9-8458-80487a90672c.png">

Test rendering using Japanese kanji indicates that the new margin values are sufficient for characters extending to the corners of the label. (The text was chosen because the characters use much of the glyph space.)

|Before|After|
|---|---|
|![badge-layout-japanese-double-develop](https://user-images.githubusercontent.com/1753199/52160215-2ed62900-267f-11e9-80f9-4ec014c663b8.png)|![badge-layout-trig-japanese-double](https://user-images.githubusercontent.com/1753199/52160890-38fe2480-268b-11e9-862b-27d17bb688f8.png)|

Calculating the horizontal padding needs careful consideration because some scripts can place glyphs right at the edge of the UILabel's bounds. For example, the RTL/Arabic tests in #6543 use a *lorem ipsum* in Arabic script that includes glyphs bumping right up against the edge of the badge.
<img width="60" alt="badge-layout-arabic-script" src="https://user-images.githubusercontent.com/1753199/52160919-af9b2200-268b-11e9-9d99-0ee7df2de054.png">


A follow-up PR for MDCBottomNavigationItemView will improve the positioning of the badge.

## Technical refactoring and simplification
As part of the visual improvement the badge will respect its bounds during layout and no longer changes its own frame. The addition of `sizeToFit` and `sizeThatFits:` makes layout in the Bottom Navigation bar simpler. The badge no longer requires a layout pass to determine its size.  Several superfluous properties were removed and internal constants were adjusted to improve the design.

Part of #6520 

Internal tests performed in cl/232081379
2019-02-04 09:18:14 -05:00
Robert Moore
1b98e1ea21
[BottomNavigation] Move controller out of /beta. (#6501)
Instead of having separate `/beta` file paths for beta code, the beta files
can be excluded from CocoaPods. Also adding targets to bazel since it was trying to compile all of the source files (and failing).

Part of #4160
2019-01-29 11:33:51 -05:00