20 Commits

Author SHA1 Message Date
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
andrewplai
388a057ad5 [BottomNavigation] Expose UIView for a given UITabBarItem. (#5061)
This will allow MDCBottomNavigationBar to work with popover / tooltip libraries which require an anchor view for positioning (i.e, if we want to display a tooltip over one of the tabs).

Closes [#4824](https://github.com/material-components/material-components-ios/issues/4824)
2018-09-10 08:11:29 -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
Robert Moore
057c72429f
[BottomNavigation] Fix accessibilityValue for badgeValue updates (#4734)
When the `badgeValue` property is updated, the `accessibilityValue` of the
item view should also be updated. However, recent changes to improve
accessibility resulted in the first badge value persisting forever as the
accessibilityValue (unless accessibilityValue was updated manually).

Fixes #4733
2018-08-08 11:38:29 -04:00
Andrew Overton
203160c80e
[BottomNavigation] Explicitly update label visibility after titleVisibility is set (#4635)
* Explicitly update label visibility after titleVisibility is set

* Add unit test for titleVisibility

* Make switch statement less explicit and fewer lines
2018-07-27 15:08:14 -04:00
Andrew Overton
87496292ff
[BottomNavigation] Give UITabBarItems' accessibilityIdentifiers to MDCBottomNavigationBa… (#4599)
* Give UITabBarItems' accessibilityIdentifiers to MDCBottomNavigationBar's items' buttons

* KVO tab bar item accessibilityIdentifier in MDCBottomNavigationItemView

* Add unit test for tracking UITabBarItem accessibilityIdentifier

* Fix KVO and associated spec

* Move accessibilityIdentifier spec
2018-07-25 10:55:40 -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
John Detloff
5c88af59d1
[BottomNavigation] Parameterize top padding and vertical margin (#4432)
Expose parameters for the top padding of the nav bar items and the vertical spacing between the icon and title. 

Before:
![simulator screen shot - iphone x - 2018-06-22 at 17 17 13](https://user-images.githubusercontent.com/1418389/41799614-269ce57a-7640-11e8-9f75-8c4c057101ed.png)

After:
![simulator screen shot - iphone x - 2018-06-22 at 17 16 33](https://user-images.githubusercontent.com/1418389/41799621-2b13c7ea-7640-11e8-88f1-30ae38220b05.png)

Closes #4042
2018-07-13 13:42:04 -04:00
Cody Weaver
c9fb2d91a4
[BottomNavigation] Test cases when we reset the bottom navigation items array (#4431)
Added an example to showcase when items are reset to an new array.

Fixed the bug when we reset items and they don't layout correctly.

After a reset, set the selected tab to Null to mirror UITabBar
https://developer.apple.com/documentation/uikit/uitabbar/1623453-selecteditem?language=objc

Added two test to check for selection being Null after a reset and frames not being zero after a reset.

Closes #4429
2018-06-26 09:40:21 -04:00
Cody Weaver
1d6444634a [BottomNavigation] Fix bug when setItems does not correctly set items (#4398)
* Fix setItems bug

* Clean up changes I didn't intend to include

* Add test to make sure when we add items they don't just continue to append to the array but reset it back to empty then add the items.

* Update the test so we set  twice.

* Add line.

* Update test to use same type in comparison.

* Use NSUInt instead of unsigned int.

* Undo whitespace changes.
2018-06-15 17:12:18 -04:00
featherless
683d2f5e74
[BottomNavigation] Add umbrella headers for all extension targets. (#3460)
Also updated all imports to make use of the umbrella headers.

Pivotal story: https://www.pivotaltracker.com/story/show/157045283
2018-04-24 16:20:43 -04:00
John Detloff
d2db639402
[BottomNavigation] Add separate property for selected title color (#3430)
Exposes a selected item title color. Does not implement the full title color image color for state pattern as MDCNavigationBar does not display a title in its unselected state, which made just this single property addition seem cleaner.

https://www.pivotaltracker.com/story/show/156742634
2018-04-20 16:17:49 -04:00
John Detloff
f31cd3010d
Update BottomNavigationBar color themer (#3316)
https://www.pivotaltracker.com/story/show/156171489

Before:

https://user-images.githubusercontent.com/1418389/38699258-8753b1b8-3e65-11e8-8681-6998b13b1307.png
https://user-images.githubusercontent.com/1418389/38699259-875ded04-3e65-11e8-81ff-1d75069d6b22.png
https://user-images.githubusercontent.com/1418389/38699260-8768d480-3e65-11e8-93d2-16ad46e816f5.png


After:

https://user-images.githubusercontent.com/1418389/38699244-7ca2f10c-3e65-11e8-8b58-ac385b89e658.png
https://user-images.githubusercontent.com/1418389/38699245-7cad2f46-3e65-11e8-94b6-e326d9ca6854.png
https://user-images.githubusercontent.com/1418389/38699246-7cb5fa86-3e65-11e8-88f2-7359d40a2490.png
2018-04-12 16:14:49 -04:00
Mohammad Cazi
fe10c83c5d
BottomNavigationBar Typography Implementation, (#3311)
Tests and example added.
2018-04-10 14:20:17 -04:00
Robert Moore
f0368d4383
[BottomNavigation] Simplify color themer (#3116)
The BottomNavigationBarColorThemer would not work for color schemes generated
from some named UIColors (like .red, .orange). It also generated a poor
contrast ratio when using the MDC Catalog color scheme (dark greys). Instead,
it should use the `primaryColor` for the selected item and leave the other
at the default.  This should generally create a simple, effective set of
colors.

Mitigates #3115
2018-03-29 14:22:07 -04:00
Robert Moore
a7ecc0b650
[BottomNavigation] Add barTintColor to replace backgroundColor (#3085)
Closes #2832
2018-03-21 15:49:55 -04:00
Robert Moore
86002fe84d
[BottomNavigation] Add NSCoding tests (#2740)
BottomNavigation needs to fully support NSCoding so that clients can use state
restoration if desired.

Closes #2737
2017-12-18 15:35:50 -05:00
Robert Moore
da57f335e8
[BottomNavigation] Correct itemTitleFont behavior (#2736)
The `itemTitleFont` property was not defaulted to a non-nil value, breaking
the API header contract. It was also not being applied when the set of items
in the bar were changed.

Closes #2734
Closes #2735
2017-12-18 15:35:30 -05:00
Robert Moore
c478173606 [BottomNavigation] Add BUILD file and no-op test (#2703) 2017-12-14 00:47:43 -05:00