17 Commits

Author SHA1 Message Date
Jeff Verkoeyen
2719769efb Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 401246074
2021-10-06 08:09:04 -07:00
featherless
f758365a6e [FlexibleHeader] Move all supplemental code into the examples. (#8690)
Standardized the property annotations. Otherwise, this PR is just a move operation and deletion of now unnecessary files.

Polish as part of #8644
2019-10-31 07:14:35 -07: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
Robert Moore
74a27253e8
Global replace of integral single-precision literals with integer literals. (#5709)
Global replace of integral single-precision literals with integer literals.

Regular expression used:
```perl
/[^\w]([0-9]+)\.[0]*[fF]/$1/
```
2018-11-08 14:02:04 -05: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
bbe4a23fe0
Remove all __IPHONE_11_0 checks now that we no longer support Xcode 8. (#4915)
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
2018-08-28 09:57:30 -04:00
featherless
bb245597d8
[FlexibleHeader] Add behavior for enabling contextual safe area insets (#4596)
This is the first part of a two-part change that addresses the behavior outlined in https://github.com/material-components/material-components-ios/issues/4104. The second part will expose a similar behavior in the AppBar component.

---

This PR introduces a new top safe area inset behavior to the flexible header view, gated behind the runtime flag `inferTopSafeAreaInsetFromViewController`.

When this behavior is enabled, the flexible header will no longer attempt to infer the top safe area inset from the device's insets using `MDCDeviceTopSafeAreaInset`. Instead, it will infer the top safe area inset from the view controller ancestry of the flexible header view controller.

This new behavior addresses a number of issues related to safe area insets, namely:

- https://github.com/material-components/material-components-ios/issues/4104 (incorrect insets when shown in a popover or modal dialog on iPad).
- Flexible headers can now be used in app extensions.
- The flexible header now properly reacts to status bar visibility changes.

### New feature: top safe area guide

This change introduces a new layout guide that can be used to position content within the flexible header view while respecting the top safe area insets. The `topSafeAreaGuide` API is available on the MDCHeaderView instance of the flexible header view controller and supports iOS 8 and up. An example of its usage to align a view to the bottom of the flexible header's top safe area guide:

```
[NSLayoutConstraint constraintWithItem:self.titleLabel
                                  attribute:NSLayoutAttributeTop
                                  relatedBy:NSLayoutRelationEqual
                                     toItem:self.fhvc.headerView.topSafeAreaGuide
                                  attribute:NSLayoutAttributeBottom
                                 multiplier:1.0
                                   constant:0]
```

The new layout guide works whether `inferTopSafeAreaInsetFromViewController` is enabled or disabled.

### Additional information

If using `MDCFlexibleHeaderContainerViewController`, this new behavior is now enabled by default.

The new behavior (and all of the other "new" behaviors) have been enabled on every FlexibleHeader example.

### Results

A screenshot of the result of this API once enabled on the App Bar:

![simulator screen shot - ipad air - 2018-07-20 at 00 32 36](https://user-images.githubusercontent.com/45670/42983391-747cb1ce-8bb4-11e8-99da-1a70721441ba.png)

### Architecture

This change builds off of the foundation introduced in 80fd217f766e0f5be6a3bc6bef5923f231721f9d. As part of that change, we made it possible to modify a given view controller's top layout guide such that it equalled the top safe area insets + the flexible header height. Unfortunately, that change was still limited by the fact that the flexible header always assumed that it was placed as a full-screen view.

With the new `inferTopSafeAreaInsetFromViewController` behavior, we are able to extract the top safe area inset from our view controller ancestry instead. We can then combine this extracted value with our flexible header's height before ultimately writing that to the target top layout guide. This flow is roughly shown in the following diagram:

![fhv](https://user-images.githubusercontent.com/45670/42982943-df40b38c-8bb1-11e8-9c05-d69959252af1.png)

In order to implement this flow we needed to implement two things:

1. A mechanism by which we could infer the root-most ancestral view controller from which we could extract safe area insets.
2. A mechanism by which we could be notified every time that root view controller's safe area insets changed.

The first mechanism is implemented by `fhv_inferTopSafeAreaSourceViewController` as a simple ancestral traversal. We walk up the view controller tree from the flexible header's parent until we run out of ancestors. There is some nuance to this algorithm, in that we need to ensure that our ancestor isn't our `topLayoutGuideViewController` or we risk creating an infinite loop. If we encounter such a situation we attempt to break the loop by walking up the topLayoutGuideViewController's ancestry instead, but at this point it's very likely we won't have a viable ancestor and we'll throw an assertion if/when we can't find a viable ancester.

With an ancestor in hand, we then determine whether to KVO observe `topLayoutGuide` or `safeAreaInsets` based on whether we're running pre-iOS 11 or iOS 11+, respectively.

KVO then informs us of any changes to the top safe area insets, which we can then propagate through the flexible header view and eventually on to the top layout guide (if `topLayoutGuideAdjustmentEnabled` is also enabled).
2018-07-25 09:39:51 -04:00
featherless
ca4e619287
[FlexibleHeader] Improved height consistency when horizontally paging. (#4601)
This change only affects flexible headers that are being used in a horizontally-paging setting.

Repro steps:
- Open MDCDragons.
- Open the Flexible Header horizontal paging example.
- Scroll the first page down until the header is collapsed.
- Swipe to the next page.

Prior to this changew, the flexible header's height would increase after moving to the new page.
After this change, the flexible header's height will stay collapsed after moving to the new page.

Related to https://github.com/material-components/material-components-ios/issues/3130
2018-07-23 13:34:27 -04:00
Randall Li
b1ec22207f
Fixed float conversion build errors (#2602)
* Fixed float conversion build errors
Implicit conversion loses floating-point precision: 'double' to 'CGFloat' (aka 'float')

Found by turning on warnings via: https://github.com/material-components/material-components-ios/pull/2480

* More Fixed float conversion build errors
Implicit conversion loses floating-point precision: 'double' to 'CGFloat' (aka 'float')

Found by turning on warnings via: https://github.com/material-components/material-components-ios/pull/2480
2017-12-06 15:57:04 -05:00
Yurii Samsoniuk
2a96682230 Replace unnecessary imports with forward declarations (#2429)
* [Themes] Remove unnecessary imports.

* [TextFields] Remove unnecessary imports.

* [Typography] Do not use an umbrella header inside of a component.

* [Snackbar] Do not use self umbrella header.

* [ActivityIndicator] Do not use self umbrella header.

* [AppBar] Use umbrella headers.

* [AppBar] Remove self import header.

* [ButtonBar] Removed self umbrella header imports.

* [Buttons] Removed self umbrella header imports.

* [Collections] Update imports.

* [Dialogs] Moved import into an m file.

* [Collections] Fixed imports.

* [FeatureHighlight] Removed self umbrealla imports.

* [HeaderStackView] Reordered imports.

* [Ink] Replaced imports with forward declarations.

* [Slider] Replaced self umbrella import use.

* [Snackbar] Removed self umbrella header import.

* [Tabs] Changed math import. Replaced self umbrella header import.

* [Icons] Removed unnecessary imports.

* [Overlay] Replaced umbrella header import.

* [ShapeLibrary] Replace Shapes imports with an umbrella header.

* [Shapes] Replaced imports with forward declarations.

* [AppBar] Replace import with a forward declaration.

* [Examples] Updated imports.

* Fixed conflicting imports

* Added space between different import categories
2017-11-16 18:25:06 -05:00
featherless
b0b2a96ce4 [FlexibleHeader] Disable content inset adjustments in the horizontal pager scroll view example's horizontal scroll view. (#2264)
If UIKit insets the horizontal paging scroll view then it will allow vertical scrolling on the horizontal view, which is not desired because vertical scrolling is meant to be managed by each scrollview page.
2017-10-24 15:02:30 -04:00
Andrés
80d054e3a5 [FlexibleHeader] Fixes to support scroll views with Safe Area insets. (#2063)
* [FlexibleHeader] Fixes to support scroll views with Safe Area insets.

* Fix typo

* [FlexibleHeader] Update header height when safe area changes.

* [FlexibleHeader] Only adjust sizes and margins on iOS11+.

* [FlexibleHeader] Bring back hardocded status bar const.

* [Catalog] Fix unintended hidden status bar when in landscape.

* Code reviews

* [Podspec] Add MaterialApplication as a dependency on MDCAppBar

* [FlexibleHeader] Make Xcode 8 stop complaining about unused parameter.

* [FlexibleHeader] Fix typo.

* [UnitTest] Remove hardcoded status bar height.
2017-09-29 10:49:57 -04:00
Alastair Tse
4a46c8c19e Monochromatic sweep of all catalog components (#1370)
* Replace MDC all icons

* Update border

* Replace MDCActionExtension icon with new logo

* Update all headers to be white on black

* Make Catalog greyscale to match Material’s style.

* Fix collection tile

* Update all headers to be white on black

* Make Catalog greyscale to match Material’s style.

* Fix collection tile

* WIP: Updating TabBar example to use black/green theme.

* WIP: Monochoroming all examples.

* Switch MDC Catalog to a black and white theme (#1355)

* Replace MDC all icons

* Update border

* Replace MDCActionExtension icon with new logo

* Update all headers to be white on black

* Make Catalog greyscale to match Material’s style.

* Fix collection tile

* Update all headers to be white on black

* Make Catalog greyscale to match Material’s style.

* Fix collection tile

* Fix floats

* Make Catalog greyscale to match Material’s style.

* More black and whiting

* WIP: Snackbar and global style

* Simplify snack bar examples.

* Page control
2017-05-05 16:16:47 -04:00
Justin Shephard
5c01be1f35 MDC_#391_Copy_Change - Made modifications to copy on limited number of controllers without a back button
Summary: Merge branch 'develop' into MDC_#391_Copy_Change

Reviewers: O1 Material components iOS, ajsecord

Reviewed By: O1 Material components iOS, ajsecord

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1374
2016-08-23 12:25:31 -04:00
Adrian Secord
8c3af252be Adding AUTHORS and removing CONTRIBUTORS.txt.
We can credit any contributor who would like to be credited this way, by adding them on request to the AUTHORS file. The copyright statement changes are required for this to work. Note that this has...

Summary:

We can credit any contributor who would like to be credited this way, by adding them on request to the AUTHORS file. The copyright statement changes are required for this to work. Note that this has no legal change, since the contributors always retained their copyright despite the copyright notice, but it's a nice acknowledgement.

Changed copyright statement to include non-Google authors.

Command run:

find * \( -name '*\.m' -or -name '*\.h' -or -name '*\.swift' \) -and -not \( -path 'scripts/external*' -name Pods  \) -print0 | xargs -0 sed -i '' 's/Copyright \(.*\) Google Inc/Copyright \1 the Material Components for iOS authors/'

Added non-source files.

Command run:

grep -Rl 'Copyright .* Google Inc' * --exclude-dir scripts/external --null | xargs -0 sed -i '' 's/Copyright \(.*\) Google Inc/Copyright \1 the Material Components for iOS authors/'

Reviewers: featherless, O1 Material components iOS, randallli

Reviewed By: O1 Material components iOS, randallli

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1415
2016-08-08 08:16:37 -07:00
Adrian Secord
3aedace959 Re-enabled 100-character line limit.
Reviewers: randallli, O1 Material components iOS

Reviewed By: randallli, O1 Material components iOS

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D965
2016-06-13 13:34:57 -04:00
Jeff Verkoeyen
bf2c12bd7c [FlexibleHeader] Add horizontal paging example.
Summary: This demonstrates the use of a Flexible Header with a horizontal paging scroll view composed of many vertical scroll views.

Reviewers: #mdc_ios_owners, ajsecord

Reviewed By: #mdc_ios_owners, ajsecord

Projects: #material_components_ios

Differential Revision: http://codereview.cc/D697
2016-04-21 10:24:35 -04:00