91 Commits

Author SHA1 Message Date
Cody Weaver
eb212f39b5 Internal change
PiperOrigin-RevId: 747980927
2025-04-15 12:38:41 -07:00
Cody Weaver
8b1de7d929 #FlexibleHeader Delete failing tests
PiperOrigin-RevId: 555553638
2023-08-10 10:34:26 -07:00
Nobody
319c5fe79b Fixed up imports for FlexibleHeader
PiperOrigin-RevId: 483506215
2022-10-24 15:52:56 -07:00
Jeff Verkoeyen
dc067749f1 Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 400786978
2021-10-04 12:36:05 -07:00
Randall Li
502bc5d910 Ran a Swift formatter
PiperOrigin-RevId: 395947664
2021-09-10 09:48:14 -07:00
Jeff Verkoeyen
a8e4831fd0 Flattening all unit tests into single directories as per convention.
PiperOrigin-RevId: 367426300
2021-04-08 07:33:29 -07:00
Jeff Verkoeyen
9a49fd96f9 Internal change.
PiperOrigin-RevId: 366342462
2021-04-01 15:26:22 -07:00
Jeff Verkoeyen
29803522c6 Optimizing imports
PiperOrigin-RevId: 357185525
2021-02-12 07:27:05 -08:00
Jeff Verkoeyen
9f9b452b3a Optimizing imports
PiperOrigin-RevId: 356850973
2021-02-10 16:15:17 -08:00
Bryan Oltman
da4b8f7c7f Fix mdc_elevationDidChangeBlock block parameter types for Xcode 12
PiperOrigin-RevId: 331843566
2020-09-15 13:39:15 -07:00
Jeff Verkoeyen
b5aa93e81c Internal change
PiperOrigin-RevId: 312773402
2020-05-21 17:44:22 -07:00
Jeff Verkoeyen
9fde103ea5 [FlexibleHeader] Extract hidesStatusBarWhenShiftedOffscreen to the shifter.
Also adds unit tests for the API.

PiperOrigin-RevId: 312531709
2020-05-20 12:26:58 -07:00
Jeff Verkoeyen
3fc4f0cb47 [FlexibleHeader] Move ShiftBehaviorForCurrentAppContext into the MDCFlexibleHeaderShifter.
This is a step towards moving more of the shift behavior-related logic into a smaller, better tested logical unit.

PiperOrigin-RevId: 312260829
2020-05-19 05:34:39 -07:00
Jeff Verkoeyen
bebb73f5e5 [FlexibleHeader] Extract a shifter logical unit.
This logical unit will house all logic related to the shift behavior. It is being extracted as a distinct logical unit so that it can be better unit tested and validated in terms of behavior. This change introduces an initial test for the basic skeletal object accordingly.

In subsequent changes, we will move logic from MDCFlexibleHeaderView into this new object.

PiperOrigin-RevId: 311203197
2020-05-13 14:46:12 +00:00
featherless
3ca65ab2a8
[FlexibleHeader] Fix bug where hairline configuration would not persist. (#9881)
Prior to this change, the FlexibleHeader's hairline APIs were not backed by storage until the FlexibleHeader's view was loaded. This meant that settings on these properties would effectively get lost.

After this change, the FlexibleHeader initializes the hairline storage immediately on initialization so that the public hairline properties are consistently backed by storage.

Closes https://github.com/material-components/material-components-ios/issues/9863
2020-03-11 12:44:45 -04:00
featherless
1116209825
[FlexibleHeader] Add unit test to reproduce https://github.com/material-components/material-components-ios/issues/9863. (#9880)
The flexible header view controller's hairline object should not be nil after initialization of the controller, but it is.

Pre-work for resolving https://github.com/material-components/material-components-ios/issues/9863.
2020-03-11 11:24:48 -04:00
shingzhao
9f57fd4534
[FlexibleHeader] Subtract minimumHeaderViewHeight from fhv_accumulatorMax.
Problem statement: Attached banner on MDCFlexibleHeaderView are not intractable. Gestures on attached banner are not received, but rather goes through to view underneath the MDCFlexibleHeaderView.
Cause and Fix: MDCFlexibleHeaderView, after shifted to the top, with minimumHeaderViewHeight enabled, is shorter than intended. This was because fhv_accumulatorMax did not take minimumHeaderViewHeight into calculation. This corrects header view height after shifting.
2020-02-28 13:45:19 -05:00
Bryan Oltman
d962e50cf2
[Material][Availability] Migrates Flexible Header to MDCAvailability. (#9744)
[Material][Availability] Migrates Flexible Header to MDCAvailability.
2020-02-14 13:20:12 -05:00
Jeff Verkoeyen
e1f6550638 [FlexibleHeader] Add hairline support.
This change introduces two new APIs on MDCFlexibleHeaderViewController: `showsHairline` and `hairlineColor`. Enabling `showsHairline` will show a view fully colored with `hairlineColor` at the bottom of the flexible header view.

This hairline view can be hidden and shown at will, enabling behaviors such as hiding the hairline when the header view's elevation changes (via the setShadowLayer:intensityDidChangeBlock: API on MDCFlexibleHeaderView).

PiperOrigin-RevId: 293140791
2020-02-04 07:23:00 -08:00
Bryan Oltman
a2eb1dcdbd
[FlexibleHeader] Delete MDCFlexibleHeaderColorThemer (#9351)
Deletes the deprecated `MDCFlexibleHeaderColorThemer`.

Fixes #9286
Fixes #9284
Fixes #9287
Fixes #9285
2019-12-30 10:39:19 -05:00
featherless
194d08f305
[FlexibleHeader] Add new flag to allow use of inferTopSafeAreaInsetFromViewController with topLayoutGuideAdjustmentEnabled (#9323)
Add new flag to allow use of inferTopSafeAreaInsetFromViewController with topLayoutGuideAdjustmentEnabled

Without this change, using both of these properties will sometimes crash.
2019-12-27 13:53:07 -05:00
featherless
a24c11f7fc
[FlexibleHeader] Add MDCFlexibleHeaderShiftBehaviorHideable. (#9026)
This new shift behavior mode enables the flexible header to mimic the behavior of UINavigationController's setNavigationBarHidden:. When the shift behavior is set to this new value, the flexible header can be hidden or shown using the shiftHeaderOnScreenAnimated: and shiftHeaderOffScreenAnimated: APIs, but user interactions will not affect the header's visibility.

Added an example to the configurator to demonstrate the behavior.

Part of https://github.com/material-components/material-components-ios/issues/5185
2019-11-27 16:16:30 -05:00
featherless
337af58b06
[FlexibleHeader] Add test that validates all defaults. (#9036)
Part of https://github.com/material-components/material-components-ios/issues/5185
2019-11-27 15:18:26 -05:00
featherless
91803e3516
[FlexibleHeader] Add FlexibleHeaderShiftedOffscreenWithShiftBehaviorDisabledTests. (#9023)
These tests validate the behavior of the flexible header when the shift behavior is disabled.

Notably, these tests reveal a bug in the implementation of isShiftedOffscreen which can occur with the following repro steps:

1. Set the flexible header's shift behavior to disabled and that it has a tracking scroll view with a content size greater than its bounds by at least the height of the header (in order to allow the scroll view to be dragged).
2. Hide the flexible header with shiftHeaderOffScreenAnimated:
3. Drag the flexible header's tracking scroll view up and then down, revealing the flexible header.
4. Inspect the state of isShiftedOffscreen.

Expected value: false
Actual value: true

This is due to the fact that shiftHeaderOffScreenAnimated: sets an internal bit that indicates that the flexible header *wants* to be hidden, and this bit is not reset once the user starts interacting with the flexible header. The likely fix is to clear the "wants to be hidden" flag when the user starts interacting with the flexible header again. I've filed https://github.com/material-components/material-components-ios/issues/9022 to track this bug.

Discovered as part of https://github.com/material-components/material-components-ios/issues/5185
2019-11-25 11:45:53 -05:00
featherless
61458cca02
[FlexibleHeader] Expose a shiftedOffscreen property. (#9014)
This property makes it possible to evaluate whether the flexible header has been intentionally hidden or not. This property will be used in a subsequent PR to implement navigationBarHidden in MDCAppBarNavigationController.

Pre-work for https://github.com/material-components/material-components-ios/issues/5185
2019-11-22 08:32:01 -05:00
featherless
e3aa7eace2
[FlexibleHeader] Add a flexibleHeaderView:didChangeTrackingScrollViewAnimated: event to MDCFlexibleHeaderViewAnimationDelegate. (#8757)
This change also makes all of the methods on MDCFlexibleHeaderViewAnimationDelegate optional so that APIs can be conditionally implemented as needed.

Closes https://github.com/material-components/material-components-ios/issues/8644
2019-11-08 13:02:46 -05:00
featherless
1bcdfc77ca
[FlexibleHeader] Add an animateWithAnimations:completion: API. (#8739)
This API can be used to animate changes to the flexible header.

Part of https://github.com/material-components/material-components-ios/issues/8644

Originally authored by @jpsachse and ported to this PR by @jverkoey.
2019-11-08 11:17:36 -05:00
featherless
06f9328350
[FlexibleHeader] Add behavioral flag for animating shadow layer frames when tracking scroll view is changed (#8715)
This is a roll-forward of https://github.com/material-components/material-components-ios/pull/8679.

This PR introduces a new behavioral flag that, if enabled, allows the flexible header to implicitly animate the frames of its shadow layers during layoutSubviews.

Part of https://github.com/material-components/material-components-ios/issues/8644
2019-11-01 13:19:48 -04:00
featherless
bd39f8483b
[FlexibleHeader] Expose an animation delegate on MDCFlexibleHeaderView. (#8712)
This delegate allows clients to react to animations of the flexible header's height when switching tabs.

Part of https://github.com/material-components/material-components-ios/issues/8644
2019-11-01 10:11:57 -04:00
Yarden Eitan
9b656a906a Revert "[FlexibleHeader] Fix bug where shadowPath did not animate when using MDCShadowLayer. (#8679)"
This reverts commit df5d5ebf8819bb49870cec239b8ca0c3c9f8501c.
2019-10-30 11:43:54 -04:00
featherless
df5d5ebf88
[FlexibleHeader] Fix bug where shadowPath did not animate when using MDCShadowLayer. (#8679)
This change relies on https://github.com/material-components/material-components-ios/pull/8666.

Prior to this change, `setTrackingScrollView:`'s tab-change collapse animation would not animate the shadow if using an MDCShadowLayer.

After this change, the animation will animate the shadow.

The added test fails without the src/ changes and passes with them.

Closes https://github.com/material-components/material-components-ios/issues/8644
2019-10-29 11:09:48 -04:00
Robert Moore
f52abf7a87
[FlexibleHeader] Update inferred status bar style on light backgrounds for iOS 13 (#8380)
[FlexibleHeader] Update inferred status bar style on light backgrounds for iOS 13

Original: cl/266147912
Closes #8379
2019-09-04 10:40:08 -04:00
Bryan Oltman
657483ea40
[FlexibleHeader] Conform to MDCElevatable, MDCElevationOverriding (#8099)
Add elevation property and elevationDidChange block to `MDCFlexibleHeaderView`. Elevation will be set in an upcoming PR by `MDCAppBarViewController`. 

Closes #8018
2019-07-26 16:48:03 -04:00
Wenyu Zhang
ba222be80d
[FlexibleHeader] Add a snapshot for shadow pre iOS 13. (#7941)
A snapshot test has been added to test flexibleHeader's shadow appearance for pre-iOS13 runtimes.
2019-07-16 18:47:48 -04:00
Cody Weaver
ac6fda5d8d
[FlexibleHeader] Add traitCollectionDidChangeBlock (#7922)
The Flexible needs an API so clients can hook-in to trait collection changes. This additionally passes the flexibleHeader as a parameter so clients can modify the flexible header within the block.

Closes #7849
2019-07-15 18:58:34 -07:00
Cody Weaver
1161a9db98
[FlexibleHeader] Add traitCollectionDidChange block (#7917)
The Flexible needs an API so clients can hook-in to trait collection changes. This additionally passes the flexibleHeader as a parameter so clients can modify the flexible header within the block.
2019-07-15 15:41:22 -07:00
Cody Weaver
238be99969
[FlexibleHeader] Add traitCollectionDidChangeBlock (#7915)
The Flexible needs an API so clients can hook-in to trait collection changes. This additionally passes the flexibleHeader as a parameter so clients can modify the flexible header within the block.
2019-07-15 12:44:21 -07:00
Cody Weaver
9f2f025fc0
[FlexibleHeader] Add dynamic color support to flexible header (#7904)
This changes exposes an API for shadowColor to MDCFlexibleHeader so that if clients set their shadowLayer to a custom class then can also set the shadowColor to a dynamic color that will be applied in layoutSubviews.

Closes #7916
2019-07-15 09:05:55 -07:00
Cody Weaver
b0b04a2adf
[FlexibleHeader] Add unit test for the shadow layer (#7909)
MDCFlexibleHeader currently doesn't have any tests related to the shadow layer. This adds tests for that property. Since there are no general flexible header tests I added this within it's own file as all other test files seem specific to other tests.
2019-07-14 08:50:55 -04:00
Andrew Overton
b38372192f
Update to Swift 4.2 (#7166)
This PR updates the Swift version to 4.2.

Partially resolves #6874.
2019-04-17 16:59:02 -04:00
Andrew Overton
bb323d9904 [FlexibleHeader] FlexibleHeader changes (#6748)
Changes shepherded from [cl/234843277](http://cl/234843277). From CL:

Add a configuration to allow safe areas to be calculated based on parent.

Prior to this CL, inferTopSafeAreaInsetFromViewController set to YES assumed
the header was embedded into a VC heirarchy at the top, so the most
ancestor VC is the only one that would know the safe areas.  That's fine
if the header is always at the top of the screen, but breaks when the
header has something above it.

parentIsAncestorForTopSafeAreaInset instead sets the parent's safe area
as the safe area the header should respect.
2019-03-04 11:58:23 -05:00
featherless
c15c78c8ad
[FlexibleHeader] Refactor min/max height behavior to a separate object. (#5896)
This is the second attempt at https://github.com/material-components/material-components-ios/pull/5594

This second attempt reduces the amount of change in behavior by replacing some invocations of the min/max height setters with ivar assignment to more closely match the original code.

The original change description is below:

---

This work is part of https://github.com/material-components/material-components-ios/issues/5060

This change pulls the minimumHeight and maximumHeight logic out to a separate, private class within the FlexibleHeader component. All of the associated state and APIs have been moved as well, and the existing MDCFlexibleHeaderView public APIs now pass-through to this internal object.

The intent of this change, like b8090cb before it, is to break the MDCFlexibleHeaderView implementation into smaller, more testable units of code.

The new MDCFlexibleHeaderMinMaxHeight object implements two paths of logic: the legacy, pre-iPhone X behavior, and the modern aware-of-safe-areas behavior. minMaxHeightIncludesSafeArea is the flag that governs which path of logic we'll use and we intend to deprecate it as part of https://github.com/material-components/material-components-ios/issues/4764. There are now two separate unit test class for each of the possible states of minMaxHeightIncludesSafeArea.
2018-12-14 13:36:05 -05:00
featherless
b3afc1eae9
[FlexibleHeader] Add basic minimumHeight/maximumHeight behavior tests. (#5908)
These tests validate the default and setter side-effect behavior of the minimumHeight and maximumHeight properties.

These tests are intended to increase confidence that https://github.com/material-components/material-components-ios/pull/5896 is not regressing in functionality.
2018-12-05 10:58:20 -05:00
Jeff Verkoeyen
f511c6e495 Revert "[FlexibleHeader] Refactor min/max height behavior to a separate object. (#5594)"
This reverts commit e53a44274751266f1a5b3343e76eaa923598b951.
2018-11-14 13:39:57 -05:00
featherless
e53a442747
[FlexibleHeader] Refactor min/max height behavior to a separate object. (#5594)
This work is part of https://github.com/material-components/material-components-ios/issues/5060

This change pulls the minimumHeight and maximumHeight logic out to a separate, private class within the FlexibleHeader component. All of the associated state and APIs have been moved as well, and the existing MDCFlexibleHeaderView public APIs now pass-through to this internal object.

The intent of this change, like b8090cb before it, is to break the MDCFlexibleHeaderView implementation into smaller, more testable units of code.

The new MDCFlexibleHeaderMinMaxHeight object implements two paths of logic: the legacy, pre-iPhone X behavior, and the modern aware-of-safe-areas behavior. minMaxHeightIncludesSafeArea is the flag that governs which path of logic we'll use and we intend to deprecate it as part of https://github.com/material-components/material-components-ios/issues/4764. There are now two separate unit test class for each of the possible states of minMaxHeightIncludesSafeArea.
2018-11-07 13:20:32 -05:00
Robert Moore
c1b1d25eec
[MDC Swift] Add guards for Swift 4.2+ (#5634)
[MDC Swift] Add guards for Swift 4.2+

On Xcode 10, using Tulsi, the unit test target cannot be built because much of the Swift code does
not have the correct syntax for Swift 4.2+. Adding pragmas to allow continued support for Xcode
9.4.2 and Xcode 10.

PiperOrigin-RevId: 220399935
2018-11-07 08:54:40 -05:00
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
d238c86d47
[CocoaPods] Remove our tests podspec in favor of official test_spec targets. (#5204)
See docs for test_spec here: https://blog.cocoapods.org/CocoaPods-1.3.0/

test_spec is an official CocoaPods mechanism for associating tests with a component. tests_spec has several advantages over our prior "tests as a podspec" hack:

- We can finally run individual tests from Xcode's inline green "test" button that shows up alongside each test in the editor.
- Tests can import private header files from components from .h files in the test target (because tests are no longer treated as frameworks). We were not previously able to do this, making it impossible to create .h/.m files that were shared across multiple test .m files.
- We no longer need MDCUnitTests - everything lives in the MDCCatalog target.
- The tests/ folder now appears as a sub-group for each component in the MaterialComponents development pod group. This will have a big impact on day-to-day workflow. Previously our tests lived in a sibling group to our components, making it somewhat difficult to navigate back-and-forth in Xcode.
- pod lib lint is now able to run our unit tests.
- Our tests can now explicitly declare their dependencies.

Some caveats:

- Each component now needs a test_spec subspec definition. This is a minor detail and one that doesn't add much extra work when creating a new component (we continue to just copy the existing templates).
- When adding a new test_spec, we also need to add the test_spec to our MDCCatalog Podfile under the `:testspecs` list. This is a bit annoying, but only happens when new components are created (very infrequent). This is a good case of the cost here being outweighed by the benefits above (which affect our daily workflow).

## Screenshot

<img width="405" alt="screen shot 2018-09-22 at 9 40 17 pm" src="https://user-images.githubusercontent.com/45670/45920647-33f4c180-beb0-11e8-94bc-88f3450c9e0a.png">
2018-09-24 21:54:54 +03:00
featherless
b8090cb638
[FlexibleHeader] Extract safe area logic to a separate object. (#4987)
There is a new private `MDCFlexibleHeaderTopSafeArea` object. This object contains all of the logic related to top safe area insets. As part of this extraction, many of the internal ivars from MDCFlexibleHeaderView have been moved to the new object.

This change does not intentionally introduce any functional or behavioral changes.

This change includes tests for this new object, along with updating the MDCFlexibleHeaderView.m logic to use the new object.

Part of https://github.com/material-components/material-components-ios/issues/5060
2018-09-11 16:57:20 -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