After this change, the default behavior for MDCNavigationBar's titleInsets property will be dynamic. In leading mode, the default insets will be 0,0,0,0, while in centered mode the title insets will continue to be 0,16,0,16. If the titleInsets property is explicitly set then the explicitly set value will be preferred indefinitely.
PiperOrigin-RevId: 301632853
Root cause: The title label's size is calculated with the text and currently it does not recalculate upon the app entering the foreground
Solution: Force MDCAppNavigationBar to layout subviews on app entering foreground
PiperOrigin-RevId: 301604933
The navigation bar needs an API so clients can hook-in to trait collection changes. This additionally passes the navigation bar as a parameter so clients can modify the flexible header within the block.
Closes#7919
These two new APIs make it possible to get the frame of the leading and trailing item views in a navigation bar. These APIs are primarily intended for use when needing to present popover or contextual elements that point to the views for individual navigation bar items.
Closes https://github.com/material-components/material-components-ios/issues/7248
Closes https://github.com/material-components/material-components-ios/issues/7207
Context
-------
UINavigationBar will attempt to steal a navigationItem's titleView property for its own use, even if the navigation bar is not visible. Our own MDCNavigationBar also wants to show the titleView instance but we can't stop UINavigationBar from stealing the titleView.
To protect against this behavior, MDCNavigationBar implements a "sandbag swap" of the titleView when it's assigned. UINavigationBar ends up stealing the sandbag away, while our MDCNavigationBar keeps an internal reference to the desired titleView.
Before this fix
---------------
The sandbag view would be swapped the first time titleView is assigned. If the same titleView was assigned to the navigationItem again, however, we would not swap it with a sandbag. The result is that navigationItem.titleView would be pointing at the actual view (not the sandbag) when UINavigationBar comes around to steal the titleView. The result is that the titleView would disappear from MDCNavigationBar.
After this fix
--------------
We now assign the sandbag view on every assignment, regardless of whether the view is the same or not.
I wrote a test to simulate the theft behavior of UINavigationBar. I verified that the test failed before this patch and that it passes after this patch. I also verified the original bug with the internal client's code and example.
### Context
Currently navigation bar has the horizontal padding of 16 on both sides as a constant. A client may meed to have a spacing of 8 on both sides, 24 on both sides or 20 on one side and 0 on the other. Currently the docs say "_The title view's width will equal the navigation bar's width minus any space consumed by the leading and trailing buttons._" - MDCTitleViewLayoutBehaviorFill but if the titleBehavior is set to this value then it fills the navigation bar's width _minus 32_ minus any space consumed by the leading and trailing buttons.
### The problem
In MDCTitleViewLayoutBehaviorFill it doesn't _Fill_ the navigation bar and isn't customizable.
### The fix
Expose the UIEdgeInset value that is used to layout the titleView.
### Related bug
Closes#6133
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.
```
Removes the need to copy-paste stanzas from other files anymore as we'll rely on https://github.com/material-components/material-components-ios/pull/4478 to generate the correct stanza for us instead.
This was an automated change generated by running a find-and-replace regular expression:
### Find
```
/\*
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\.
\*/
```
### Replace
```
// 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.
```
We can now make use of @available throughout our codebase.
We support Xcode 9 and up, which includes the iOS 11 SDK. This means we can remove any guards for SDKs prior to iOS 11.
This was cleaned up by running a global find-and-replace with the following regular expression:
```
Find:#if defined\(__IPHONE_11_0\) && \(__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0\)\n(.+if \(@available\(iOS 11.0, \*\)\) \{(?:.|\n)*?)(?:#else(?:.|\n)*?)?\n#endif
Replace:$1
```
With some additional cleanup for stragglers that didn't match this pattern. Note that else clauses were intentionally dropped.
Closes https://github.com/material-components/material-components-ios/issues/4909
This new flag allows a client to remove the 20pt font size restriction on MDCNavigationBar. This restriction was somewhat arbitrary and could cause problems with accessibility for certain font families.
Prior to this change, any font set on MDCNavigationBar would be restricted to 20pt size.
After this change, if the allowAnyTitleFontSize property is enabled on an MDCNavigationBar instance, then the font will be used directly and no sizes will be enforced.
This is required to support internal needs to set a navigation bar title font size of 18.
Historically we had given navigation bars different heights on iPads. We no longer intent to make this distinction.
This change also fixes a bug related to this difference in behavior on iPads. The repro case for this bug is:
- Launch MDCDragons on an iPad Pro running 10.3.1.
- Open the App Bar typical use example.
- Scroll the content down somewhat.
Expected behavior: the navigation bar does not change its height or shift.
Actual behavior: the navigation bar shifts slightly as the scroll view is scrolled.
After this change, the navigation bar's height will always default to the same fixed height on all devices. This reflects the fact that Flexible Header's default minimumHeight and maximumHeight values are constant across all devices.
Closes https://github.com/material-components/material-components-ios/issues/4840
This restriction is somewhat arbitrary and could cause problems with accessibility for certain font families.
Prior to this change, any font set on MDCNavigationBar would be restricted to 20pt size.
After this change, the font will be used directly and no sizes will be enforced.
This is required to support internal needs to set a navigation bar title font size of 18.
This change further formalizes our pattern of annotating APIs that will be or are deprecated using class categories. Moving an API into such a category has the benefit of being picked up by the API diff toolchain and elevated into our release notes as a result.
We do not intend to actively support UIAppearance any further. This change removes any references to supporting UIAppearance from our public documentation.
Pivotal story: https://www.pivotaltracker.com/story/show/157048342
### Context
When setting a font on MDCNavigationBar, we force the font to have a size of 20.
### Prior to this change
We were enforcing the font size by using an older UIFont API - fontWithName:size:. This API does not preserve font descriptor attributes from the provided font, it only preserves the font name and size.
This was resulting in the loss of an important system font descriptor attribute, namely `NSCTFontUIFontDesignTrait` which was set to `NSCTFontUIFontDesignDefault`. This font attribute affects the kerning of fonts when displayed on screen.
### After this change
We are now using the iOS 7 API - fontWithDescriptor:size:. This API preserves all of the underlying font descriptor attributes.
The result of this change is an intentional visual change.
As part of this behavioral change, I've also updated the related unit tests to enforce this behavior in the future.
To see a visual depiction of the change in behavior, open the following two screenshots and flip between them:
Before this fix:

After this fix:

Visual delta:

Make inkColor for buttons in MDCButtonBar customizable. Also expose an API on MDCNavigationBar to allow using the custom inkColor in AppBar.
closes#1660
* Forcing Font size now does save the right FontName for every case.
* typo.
* can't expose a private header.
* mdc_weight should not be used.
* tests are up and running.
* fixing the tests. no support for weight on iOS 8.
* Document why we switched to fontWithName:size.
Internal clients have broken layouts when using custom titleViews after this
change. Reverting as a hotfix until a migration path can be developed.
This reverts commit 7172657a7b1cd04839eadc10e9d66e895a71bee7.
It looks like the internal changes were already approved by the client
team in (cl/189537437) but the link was missing in the GitHub PR.
Restoring the work originally done by @AlimoRabbani.
This reverts commit 890340e0bae74918afcfbf6a45fcbb3bbedda173.
An internal client has failing screenshot tests (iPad Air 2/iOS 10.2)
where the text has been shifted down as a result of this change. It's
not clear whether the new position is expected or a bug, so the change
is being reverted until the correct behavior (or fix) can be determined.
Reopens#2793Reopens#253
This reverts commit 7172657a7b1cd04839eadc10e9d66e895a71bee7.