24 Commits

Author SHA1 Message Date
Frank Wang
18bcdffdfc Test updates for bottom navigation.
PiperOrigin-RevId: 747445026
2025-04-14 09:13:52 -07:00
Nobody
71807fa2b4 Fixed up imports and nullability for BottomNavigation
PiperOrigin-RevId: 490263336
2022-11-22 09:36:01 -08:00
David Collazo
6ab378ddc4 Remove deprecated enableRippleBehavior property from BottomNavigation component
PiperOrigin-RevId: 441893309
2022-04-14 17:19:57 -07:00
Jeff Verkoeyen
e49a786767 [Badges] Rewrite badge appearance using Appearance objects.
This change consists of two related portions:

1. Extraction of badge and dot badge appearance-related APIs into corresponding Appearance objects and updating the MDC examples to reflect this new API format.
2. Updated bottom navigation to make use of the new appearance APIs.

Also added an example of using the appearance's "system tint" default behavior for nil, which is aligned with how UIKit handles similar APIs.

PiperOrigin-RevId: 417902876
2021-12-22 16:15:08 -08:00
Jeff Verkoeyen
6a94f54cc9 [BottomNavigation] Organize the item's badge-specific APIs to match their underlying storage.
The properties' declarations, documentation, and organizational structure now mirrors the underlying badge view that houses the data.

PiperOrigin-RevId: 415342823
2021-12-09 13:32:57 -08:00
Jeff Verkoeyen
9bb428332f [BottomNavigation] Store badge as an ivar.
Now that BottomNavigation restricts subclassing, this removes any need for the badge storage to be kept as a property and allows us to drop unnecessary method implementations, further reducing binary footprint.

PiperOrigin-RevId: 415331970
2021-12-09 12:48:45 -08:00
Jeff Verkoeyen
6e711120fb [BottomNavigation] Tighten the API surface area of the badge.
The badge view now exposes only the APIs that are needed to configure its behavior.

PiperOrigin-RevId: 415293891
2021-12-09 10:13:54 -08:00
Jeff Verkoeyen
c53f44398e Optimizing imports
PiperOrigin-RevId: 357185618
2021-02-12 07:29:28 -08: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
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
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
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
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
Bartholomew Furrow
a9c8fab43d [BottomNavigation] Lays out the bar when titleVisibility is changed (#6152)
Closes #6151.
2019-01-24 07:43:56 -05:00
Robert Moore
89b44314af
[BottomNavigation] Confirm (un)selected ink is same. (#6190)
When changing the value of `selectedItemTintColor`, we should confirm that
both selected and unselected items receive the same ink color.

Follow-up for #4937
2019-01-08 22:05:07 -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
Cody Weaver
5db5057aaf
[BottomNavigation] Change badge position (#5339)
<h4>

```diff
- Warning - This may break screenshot testing -
```
</h4>

### Context
Currently the badge is centered on the top of the `iconImageView`. The `iconImageView`'s  `origin.y` is at 8.883 in MDC because we vertically center the _content_ in the MDCBottomNavigationItemView. We get the _content_ height by:

_contentHeight_ = icon.height + label.height + contentVerticalMargin

_contentVerticalMargin_ is the spacing between the icon and label.

The **_badge_** is 14dp tall. Centering the badge on the `iconImageView`'s `origin.y` puts the badge at 1.883.
### The problem
The badge is too high in relation to the top of the bottom navigation bar and doesn't match internal guidance.
### The fix
Make the badge and iconImageView have the same origin y, giving users more separation between the top of the navigation bar and the top of the badge.
### Related PR
Closes #4731 
### Screenshots
| Before | After |
| - | - |
|![simulator screen shot - iphone x - 2018-10-06 at 11 10 04](https://user-images.githubusercontent.com/7131294/46572709-65fa2f00-c958-11e8-8f57-5c0d389ae7c0.png)|![simulator screen shot - iphone x - 2018-10-06 at 11 09 29](https://user-images.githubusercontent.com/7131294/46572711-698db600-c958-11e8-838e-ee6ec31c7c50.png)|
2018-10-09 16:09:15 -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
Robert Moore
09505ec920
[BottomNavigation] Update ripple color for unselected items. (#4950)
All items should share the same (ink) ripple color, based on the
`selectedItemTintColor`. For currently-unselected items, the ripple color
would only be updated if the `unselectedItemTintColor` property was set.

The problem was caused by earlier behavior where the ripple color would be
derived from the current state of the button. If an unselected item were
pressed, its ripple color would be based on the `unselectedItemTintColor`.
That behavior was changed so that the `selectedItemTintColor` was used for the
ripple color in all states, but the logic was not moved outside of the
state-based conditional logic.

||Animated Screenshot|
|--|--|
|Before | ![bn-ink-before](https://user-images.githubusercontent.com/1753199/44802070-bd9ec100-ab88-11e8-86c9-48658f8adcc0.gif)|
|After | ![bn-ink-after](https://user-images.githubusercontent.com/1753199/44802075-c2fc0b80-ab88-11e8-872f-ad586408b928.gif)|

Closes #4937
2018-08-30 23:50:27 -04:00
featherless
001fbfac55
[BottomNavigation]! Remove encoding/decoding behavior for custom properties (#4562)
Closes https://github.com/material-components/material-components-ios/issues/3939
2018-07-25 09:48:35 -04:00