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
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
[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
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
Enables clients to opt-in to state restoration by providing `restorationIdentifier` values for the Bottom Navigation controller's child view controllers.
Closes#8265
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
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
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
This test ensures that the `additionalSafeAreaInsets` property of child VCs is
correctly set to account for the bottom navigation bar.
Confirmation of #8112
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
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
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
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
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;
```
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
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
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
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
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
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
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
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
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
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