32 Commits

Author SHA1 Message Date
Robert Moore
675235ed05
{Tests} Deallocate test objects at the end of tests. (#5397)
Deallocating many of the properties created for each unit test. Since all
XCTestCase instances survive until the end of the test suite, any properties
created for a test will be preserved as well. This frees up around 3.7 MB
(~6%) of memory from the entire test suite, as measured on my desktop.

|Before|After|
|----|----|
|![test-objcs-before](https://user-images.githubusercontent.com/1753199/46813473-c3b9bd00-cd44-11e8-990c-28dff4ab5ad2.png)|![test-objcs-after](https://user-images.githubusercontent.com/1753199/46813481-c7e5da80-cd44-11e8-90e4-2e6d532ebbfb.png)|

See also: https://qualitycoding.org/xctestcase-teardown/

Closes #5395
2018-10-12 08:33:58 -04:00
featherless
32fe4e191a
[NavigationBar] Update layout when button bar sizes change. (#4992)
Prior to this change, changing the title of a button would often result in the button's label being clipped because the navigation bar was not updating its button bar frames when needed.

After this change, the navigation bar makes use of 471936b842e7473e51b5dc02df619a7e67a0c5b2 to react to changes in the intrinsic content size of the button bar.

## Before

| Before changing title | After changing title |
|:----------|:------------|
| ![simulator screen shot - iphone x - 2018-08-31 at 16 20 30](https://user-images.githubusercontent.com/45670/44934442-d51dab80-ad3a-11e8-9313-056e135de150.png) | ![simulator screen shot - iphone x - 2018-09-07 at 09 29 39](https://user-images.githubusercontent.com/45670/45221807-9d55bd00-b280-11e8-92c4-07e0bc409d64.png) |

## After

| Before changing title | After changing title |
|:----------|:------------|
| ![simulator screen shot - iphone x - 2018-08-31 at 16 20 30](https://user-images.githubusercontent.com/45670/44934442-d51dab80-ad3a-11e8-9313-056e135de150.png) | ![simulator screen shot - iphone x - 2018-08-31 at 16 20 32](https://user-images.githubusercontent.com/45670/44934447-d64ed880-ad3a-11e8-9c67-67e50995fce0.png) |

Closes https://github.com/material-components/material-components-ios/issues/1717
2018-09-10 16:17:23 -04:00
Robert Moore
ed819a8304
[NavigationBar] Tint leading, trailing button bars. (#5064)
To prepare for tinting the leading and trailing button bar items in the
Bottom App Bar, the MDCNavigationBar should support an API that allows
separate tint colors for the leading and trailing button bar items.

**Extreme Example**

<img width="374" alt="screen shot 2018-09-07 at 11 23 02 pm" src="https://user-images.githubusercontent.com/1753199/45249812-024afa80-b2f5-11e8-920b-c32dccd8d3a5.png">

Part of #3928
2018-09-08 23:24:02 -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
featherless
059cbfaebb
[NavigationBar] Add uppercasesButtonTitles API for modifying title casing behavior. (#4936)
This allows an owner of a navigation bar to configure the title casing behavior for both the leading and trailing button bars.

Closes https://github.com/material-components/material-components-ios/issues/2968
2018-08-29 10:22:05 -04:00
featherless
56e8c4fd27
[NavigationBar] Add a flag that makes it possible to set any font size. (#4879)
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.
2018-08-24 13:36:28 -04:00
Randall Li
5df5229171 Revert "[NavigationBar] Remove restriction for 20pt fonts. (#4851)"
This reverts commit 2c3f97a98f20645d780aa1b3bccd78646f224059.
2018-08-22 12:45:25 -04:00
featherless
2c3f97a98f
[NavigationBar] Remove restriction for 20pt fonts. (#4851)
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.
2018-08-21 09:29:20 -04:00
featherless
de0d57e8e3
[NavigationBar] Remove NSCoding support. (#4560)
Closes https://github.com/material-components/material-components-ios/issues/3944
2018-07-16 08:33:49 -04:00
featherless
c7ee146de2
[NavigationBar] Add a titleViewLayoutBehavior API. (#4371)
This property allows a client to configure the title view layout behavior to be one of either "fill" or "center". The fill behavior is the default and existing behavior, which sets the title view's frame to fill the available navigation bar space. The center behavior will always attempt to center the title view within the navigation bar's bounds.

The center behavior is desired by teams in the simple cases of when they want their title view to be centered within the navigation bar as best as possible. This is also the default behavior of UINavigationBar.

Closes https://github.com/material-components/material-components-ios/issues/1650

### Screenshots

"Fill" behavior:

![simulator screen shot - iphone se - 2018-06-06 at 09 13 03](https://user-images.githubusercontent.com/45670/41040247-d71e762c-6969-11e8-8584-f86c0c6fe514.png)

"Center" behavior:

![simulator screen shot - iphone se - 2018-06-06 at 09 11 53](https://user-images.githubusercontent.com/45670/41040226-cb1bc244-6969-11e8-815b-145e2e40b98b.png)

"Center" behavior in RTL languages:

![simulator screen shot - iphone se - 2018-06-06 at 10 39 37](https://user-images.githubusercontent.com/45670/41045233-f9fc3948-6975-11e8-9e9d-48ca5ed7342c.png)
2018-06-06 13:32:57 -04:00
featherless
e5679888fe
[NavigationBar] Add umbrella headers for all extension targets. (#3471)
Also updated all imports to make use of the umbrella headers.

Pivotal story: https://www.pivotaltracker.com/story/show/157045283
2018-04-24 15:57:24 -04:00
featherless
bd05a69c88
[NavigationBar] Fix the surface variation themer's text/icon colors to match spec. (#3416)
For the variant themer, text is supposed to be onSurface @ 87% opacity, while icons are onSurface @ 54% opacity.

Closes pivotal story: https://www.pivotaltracker.com/story/show/156934328
Closes pivotal story: https://www.pivotaltracker.com/story/show/156934114

Before:

![simulator screen shot - iphone se - 2018-04-19 at 21 04 58](https://user-images.githubusercontent.com/45670/39065696-aa4df430-44a0-11e8-897f-3bc71b8b4c7e.png)

After:

![simulator screen shot - iphone se - 2018-04-19 at 21 04 03](https://user-images.githubusercontent.com/45670/39065699-ad47ffaa-44a0-11e8-9a40-e2d2cb92f908.png)
2018-04-20 15:15:23 -04:00
featherless
8d3f54246e
[NavigationBar] Add a stateful buttons title color API. (#3415)
This API allows a client to customize the title color for buttons for a given control state.

Related to https://www.pivotaltracker.com/story/show/156934328

Screenshot shows a button with a custom normal and highlighted state. The button on the left is highlighted.

![simulator screen shot - iphone se - 2018-04-19 at 19 51 59](https://user-images.githubusercontent.com/45670/39024065-786db638-440c-11e8-97e8-f6bf3e6c2af7.png)
2018-04-20 13:41:13 -04:00
featherless
610d1ab58a
[NavigationBar] Add an API for customizing button fonts. (#3412)
Pivotal story: https://www.pivotaltracker.com/story/show/156769836
2018-04-19 19:55:21 -04:00
featherless
6b2de0f3a3
[NavigationBar] Add surface variant theme. (#3376)
![simulator screen shot - iphone 8 plus - 2018-04-16 at 20 40 39](https://user-images.githubusercontent.com/45670/38842189-9ed9c6a2-41b6-11e8-9149-08f945c673d2.png)

Pivotal story: https://www.pivotaltracker.com/story/show/156826560
2018-04-17 08:02:09 -04:00
featherless
d259ebed7d
[NavigationBar] Fix bug where system font traits would be lost. (#3360)
### 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:
![lossy](https://user-images.githubusercontent.com/45670/38755649-8a172a22-3f34-11e8-9f53-15ca6789e351.png)

After this fix:
![notlossy](https://user-images.githubusercontent.com/45670/38755654-8d998fa0-3f34-11e8-8112-49e3d4b7d76e.png)

Visual delta:
![difference](https://user-images.githubusercontent.com/45670/38755656-91d02f5c-3f34-11e8-8032-36d3ffc8f52e.png)
2018-04-13 16:25:17 -04:00
Mohammad Cazi
8e83dcf343
[NavigationBar] typography implementation. (#3304)
* Navigation Bar Typography Themer implementation.
Tests and example added.

* fixing merge conflict mistake and tests.
2018-04-10 11:01:51 -04:00
Mohammad Cazi
bc3b4e871b
Forcing Font size now does save the right FontName for every case. (#3299)
* 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.
2018-04-09 16:37:05 -04:00
featherless
38595c6509
[NavigationBar] Implement a semantic color scheme color themer API. (#3267)
Also added unit tests and updated a couple examples to make use of the new themer APIs.

Pivotal story: https://www.pivotaltracker.com/story/show/156169509

[Delivers #156169509]

![simulator screen shot - iphone x - 2018-04-06 at 11 36 09](https://user-images.githubusercontent.com/45670/38430240-b810f8b4-398e-11e8-9583-e871a5e5542d.png)
2018-04-09 11:27:53 -04:00
Mohammad Cazi
b0aaa07cb2
[MDCNavigationBar] Exposing typography API. (#3217)
* Extracting Accessibility out of FeatureHighlightViewController to a mutator.
Tests added.
Example updated.

* Revert "Extracting Accessibility out of FeatureHighlightViewController to a mutator."

This reverts commit 0b5433ebf86366087b240c4dc4992a0603fa73e0.

* Expose title font as a property.

* Updating the documentation.

* Deprecating titleTextAttributes since we are using titleFont property now.

* Add tests for title font property.

* revert deprecation for this PR., update the doc to explain the behavior when using both titleFont and titleTextAttributes.

* Adding more documentation for the behavior of titleTextAttributes and titleFont together.

* Note for deprecation.

* documentation tweeks.
2018-04-04 15:35:10 -04:00
Robert Moore
8ea0d77f72
[NavigationBar] Add Accessibility method tests (#2721)
Extending test coverage to include accessibility tests
2017-12-14 19:58:54 -05:00
Robert Moore
8f1eb74490
[NavBar, ButtonBar] Add NavBar tests, fix ButtonBar KVO (#2713)
* [NavBar, ButtonBar] Add NavBar tests, fix ButtonBar KVO

ButtonBar was not correctly setting up KVO when it was created with an NSCoder (restored from an
archive). In that case, dealloc would generate an exception and crash.  Instead of writing to the
backing iVar during initWithCoder:, the ButtonBar should call through to its setter instead.  This
is less safe (because the subclass may not be initialized) but guarantees observing the objects it
is restoring.

Added a simple NavBar encoding test.
2017-12-14 06:49:05 -05:00
Robert Moore
5879c18c26
[ButtonBar, NavigationBar] Add BUILD file for kokoro (#2598)
* [ButtonBar, NavigationBar] Add BUILD file for kokoro

ButtonBar ColorThemer depends on NavigationBar
NavigationBar depends on ButtonBar
2017-12-11 17:49:26 -05:00
Will Larche
8c5350de31 [All] Formatting. (#1269) 2017-03-22 12:18:15 -04:00
Justin Shephard
95d71cfaac [Project] Clear warnings within project (#1205)
* [Project] - Clear warnings within project

* [Project] - Clean errant code
2017-02-14 18:53:02 -05:00
Justin Shephard
c3d3bd34af [NavigationBar] - Added Accessibility Mutator (#1109)
* [NavigationBar] - Added Accessibility Enforcer to Navigation Bar. Updated Podspec to include MDFTextAccessibility to MDCNavigationBar

* [NavigationBar] - Added unit tests and updated examples

* [NavigationBar] - Updated doc comment

* [NavigationBar] - Updated naming convention of mutator

* [NavigationBar] - Updated examples

* Update and rename NavigationBarAccessibilityEnforcerTestColorTest.swift to NavigationBarAccessibilityMutatorTestColorTest.swift
2017-02-10 15:07:04 -05:00
Randall Li
b2d95a86df [NavigationBar] changed default title alignment to center (#831) 2016-12-12 15:18:13 -05:00
Adrian Secord
4842a362f5 Convert component examples to Swift 3 (#1002)
* WIP

* WIP

* Simplified build script and fixed it to build all schemes.

* WIP

* Renamed script to build_all and added better output.

* Add scripts/list_xcode_workspaces.

* Filtered out the CocoaPods schemes.

* Use Xcode to update Swift to v3.

* Updated tracked touches map from NSNumber to Int.

* Fixed button sorting that was not actually sorting.

* targetContentOffset no longer allowed to be nil.

* "Fixed" failing test by reducing random number range?

* Swift 3 syntax change.

* Swift 3 syntax change.

* Removed invalid center-aligning tests.

Fixed default nav bar alignment test.
2016-12-12 09:55:36 -05:00
Junius Gunaratne
d4ec6ee060 [NavigationBar] Update title frame then apply RTL for title alignment. #831 (#991)
* [MDCInkView] cancelAllAnimationsAnimated should support disabling animation

* [MDCProgressView] Allow completion block to be modified if setHidden:animated:completion is called sequentially

* Call completion block immediately rather than storing as a property.

* Add nil check for completion block

* [Shrine] Update to Swift 3

* [AppBar] Add Objective C AppBar storyboard example

* Add right button bar item to AppBar swift demo

* Add plus shape icon to FAB

* Move plus symbol to example code

* Add plus icon asset, move to supplemental

* Remove unused methods

* Undo change to print.

* Move plus CAShapeLayer code into its own method

* Remove plus path method

* Use supplemental method to get plus symbol CAShapeLayer

* Update md shadow elevation description.

* Add API documentation links for activity indicator

* Update .md files with correct build site script file name

* Add animation timing to components main read me file

* Horizontally-centered layout should adjust frame and then apply RTL

* Remove debugging code.

* Remove unnecessary centering

* Formatting

* Added back deleted icon

* Use CGRectMake to create CGRect
2016-12-09 13:36:45 -05:00
randallli
fdf1ff083d [NavBar] Corrected mapping of NSTextAlignment to MDCNavigationBarTitleAligment
Summary: added unit test to check default

Reviewers: O1 Material components iOS, shepj, ajsecord

Reviewed By: O1 Material components iOS, shepj, ajsecord

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1703
2016-10-10 14:52:09 -04:00
randallli
531a53b72a [NavigationBar]! Switch to custom enum rather that reuse the NSTextAlignment so that we can strict our external API surface to the two options we want: Left and Center.
Summary: switched api to be titleAlignment rather than textAlignment

Test Plan: fixed unit tests

Reviewers: O1 Material components iOS, ajsecord

Reviewed By: O1 Material components iOS, ajsecord

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1679
2016-10-05 11:48:10 -04:00
randallli
2afee9916a [MDCNavigationBar] Add ability to center title based on iOS design guidelines
Summary: Changing this to avoid the title being confused for the back button text and to conform more closely with the iOS platform

Reviewers: junius, O1 Material components iOS, ajsecord

Reviewed By: O1 Material components iOS, ajsecord

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1473
2016-09-27 10:38:27 -04:00