142 Commits

Author SHA1 Message Date
Jeff Verkoeyen
72dcc44075 Internal change
PiperOrigin-RevId: 468184898
2022-08-17 06:51:30 -07:00
Jeff Verkoeyen
7ae4498a05 [FlexibleHeader] Delete the unused canAlwaysExpandToMaximumHeight API.
PiperOrigin-RevId: 457775121
2022-06-28 11:11:40 -07:00
Jeff Verkoeyen
08051b7bda Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 400798440
2021-10-04 13:20:55 -07:00
Jeff Verkoeyen
86a8c97dc7 Remove all pre-iOS 12 logic.
PiperOrigin-RevId: 400788645
2021-10-04 12:41:07 -07:00
Randall Li
502bc5d910 Ran a Swift formatter
PiperOrigin-RevId: 395947664
2021-09-10 09:48:14 -07:00
Jeff Verkoeyen
1437067081 Optimizing imports
PiperOrigin-RevId: 356851164
2021-02-10 16:18:20 -08:00
Jeff Verkoeyen
b78737be48 [AppBar] Inject AppBars after view controllers have been added to the navigation controller.
Before this change, it was never possible to interact with the navigationController property in a pushed view controller's viewDidLoad property when using MDCAppBarNavigationController. This behavior is surprising for folks using UINavigationController, which does allow you to access navigationController from within viewDidLoad.

This expectation is an anti-pattern (e.g. viewDidLoad is never guaranteed to be invoked after a view controller has been pushed onto a navigationController stack), but the goal of MDCAppBarNavigationController is to provide a drop-in replacement for UINavigationController so our intent is to align behaviors, even if they're not necessarily for the right reasons.

All that being said, the change introduced in this CL simply swaps the ordering of pushing the view controller and injecting the AppBar, such that the injection now happens after the super implementation of pushViewController has been invoked. This allows the viewDidLoad logic to be invoked after navigationController has been initialized on the view controller.

The reason we were doing it the other way before was so that the AppBar could intercept the relevant status bar appearance events. We work around that requirement in this change by invoking setNeedsStatusBarAppearanceUpdate and setNeedsUpdateOfHomeIndicatorAutoHidden immediately after injecting the AppBar.

PiperOrigin-RevId: 313410464
2020-05-27 10:06:04 -07:00
Galia Kaufman
09171d15c7 [AppBar] Fix a failing snapshot test
PiperOrigin-RevId: 312260009
2020-05-19 05:29:15 -07:00
Jeff Verkoeyen
e479b366e7 [AppBar] Roll-back "inject AppBars after view controllers have been added to the navigation controller."
PiperOrigin-RevId: 311550067
2020-05-14 09:47:14 -07:00
Jeff Verkoeyen
c0b4ff9cb3 [AppBar] Inject AppBars after view controllers have been added to the navigation controller.
Before this change, it was never possible to interact with the navigationController property in a pushed view controller's viewDidLoad property when using MDCAppBarNavigationController. This behavior is surprising for folks using UINavigationController, which does allow you to access navigationController from within viewDidLoad.

This expectation is an anti-pattern (e.g. viewDidLoad is never guaranteed to be invoked after a view controller has been pushed onto a navigationController stack), but the goal of MDCAppBarNavigationController is to provide a drop-in replacement for UINavigationController so our intent is to align behaviors, even if they're not necessarily for the right reasons.

All that being said, the change introduced in this CL simply swaps the ordering of pushing the view controller and injecting the AppBar, such that the injection now happens after the super implementation of pushViewController has been invoked. This allows the viewDidLoad logic to be invoked after navigationController has been initialized on the view controller.

The reason we were doing it the other way before was so that the AppBar could intercept the relevant status bar appearance events. We work around that requirement in this change by invoking setNeedsStatusBarAppearanceUpdate and setNeedsUpdateOfHomeIndicatorAutoHidden immediately after injecting the AppBar.

PiperOrigin-RevId: 311342757
2020-05-13 09:29:59 -07:00
Jeff Verkoeyen
dbb9ab1170 [AppBar] Add NavigationController example with AppBar initially hidden.
Note that this new example demonstrates a bug in which the AppBar is not, in fact, hidden when presented.

PiperOrigin-RevId: 311104930
2020-05-13 14:41:30 +00:00
Jeff Verkoeyen
a502ce66b9 [FlexibleHeader] Ensure that the FlexibleHeader's position reacts to safeAreaInsets changes when hidden.
## The bug

Repro steps:

1. Open MDCDragons on an iPhone with a notch.
2. Open App Bar -> Presented hidden.
3. Present the App Bar.
4. Observe.

Expected behavior:
- The AppBar is completely hidden.

Actual behavior:
- The AppBar is partially hidden.

## Root cause analysis

When the FlexibleHeader is hidden using shiftHeaderOffScreenAnimated:, the expectation is that the header will be shifted entirely off-screen. If this method is invoked before the FlexibleHeader is attached to a window hierarchy, then the offset applied to shift the header off-screen may not correctly include the necessary safe area insets to hide the header fully.

When flexibleHeaderSafeAreaTopSafeAreaInsetDidChange was being invoked after the safe area insets were made available to the FlexibleHeader, we were not taking into consideration whether the FlexibleHeader was supposed to be hidden which resulted in the FlexibleHeader getting stuck in a partially hidden state.

## The fix

In flexibleHeaderSafeAreaTopSafeAreaInsetDidChange, we now check whether the FlexibleHeader wants to be hidden and, if it does (and we're not already animating it), we immediately snap the FlexibleHeader to the new necessary offset.

PiperOrigin-RevId: 311104051
2020-05-13 14:40:20 +00:00
Jeff Verkoeyen
97702e8b0c [AppBar] Make the presented hidden example show a new view controller each time.
The example was reusing the same view controller instance after each presentation, which made it difficult to consistently test the same buggy behavior.

PiperOrigin-RevId: 310980123
2020-05-12 15:11:46 -04:00
Jeff Verkoeyen
3b99d09c69 [AppBar] Add a presented hidden example.
This example demonstrates a bug where the AppBar does not appear to respect shiftHeaderOffScreenAnimated: when the shiftBehavior is set to hideable.

PiperOrigin-RevId: 310898136
2020-05-11 06:18:08 -07:00
Jeff Verkoeyen
459066d00e [AppBar] Don't hide the navigation bar in AppBarNavigationControllerExample.
This example doesn't actually manage its own app bar; it only presents one. This fixes a bug where the example did not show a navigation bar at all.

PiperOrigin-RevId: 310870101
2020-05-11 02:13:39 -07:00
Jeff Verkoeyen
580a1ecbde [AppBar] Clarify the purpose of the example supplemental view controllers.
The prior names of composed vs inherited didn't meaningfully translate to the intended purpose of the two view controllers, which is to provide harnesses within which the flexible header can be placed either as a child or as a sibling to its tracking scroll view. This distinction is important because the flexible header behaves differently when it is a child of its tracking scroll view, as is the case when using UITableViewController.

PiperOrigin-RevId: 310869953
2020-05-11 02:11:26 -07:00
Jeff Verkoeyen
783c9de40e [AppBar] Extract a sample app bar view controller to supplemental.
This controller will be reused in other examples.

PiperOrigin-RevId: 310869906
2020-05-11 02:08:50 -07:00
Jeff Verkoeyen
25471afea0 Rename "flaky" to "skip_snapshots".
PiperOrigin-RevId: 308259307
2020-04-24 08:34:12 -07:00
Jeff Verkoeyen
776dacc084 [AppBar] Mark the webview examples as flaky.
PiperOrigin-RevId: 308252919
2020-04-24 07:51:05 -07:00
Jeff Verkoeyen
de34b1cbfd [AppBar] Implement catalogShouldHideNavigation in all examples.
Implementing this method ensures that the navigation bar is hidden when these examples are shown.

PiperOrigin-RevId: 308044966
2020-04-23 07:21:30 -07:00
Yarden Eitan
13b6382861 [AppBar] Fix AppBar from jumping when contentOffset updates when VoiceOver is on.
The problem occurs because the transform of the flexible header view's Y positioning based on the contentOffset is not done in coordination with the scroll view animation.

Similarly to the jumping effect in https://github.com/material-components/material-components-ios/pull/9872 , we coordinate the transform when VoiceOver is on with the scroll view content offset change.

This was tested with the Expandable Cells example and the glitch is fixed.

PiperOrigin-RevId: 304352119
2020-04-02 01:45:33 -07:00
Yarden Eitan
5e99873e05 [AppBar] Add example to dragons to demonstrate AppBar crash when VoiceOver is turned on and contentInset is set.
PiperOrigin-RevId: 303958379
2020-03-31 07:11:52 -07:00
featherless
027f240063
[AppBar] Add AppBarCustomButtonThemeExample. (#9883)
This example demonstrates the recommended way to create a custom-themed button in the AppBar.

![Simulator Screen Shot - iPhone 8 Plus - 2020-03-11 at 13 56 04](https://user-images.githubusercontent.com/45670/76448011-11a27c80-63a0-11ea-8d37-cbde277e4db0.png)

Closes https://github.com/material-components/material-components-ios/issues/9007
2020-03-12 13:34:59 -04:00
featherless
e6989ce5e3
[AppBar] Add AppBarWithExpandableCells example. (#9873)
This example demonstrates a bug where the AppBar will "jump" with the following repro steps:

1. Open the example.
2. Tap any cell.
3. Scroll the tapped cell until it is above the AppBar.
4. Tap any other cell.

Expected behavior: the AppBar stays in place while the cell heights change.

Actual behavior: the AppBar "jumps" up and then animates back into place.

This is pre-work for https://github.com/material-components/material-components-ios/issues/9853
2020-03-11 11:12:30 -04:00
Jeff Verkoeyen
5fc9ec512e [AppBar] Add an AppBar Theming example.
This example provides a toggle between Primary and Surface theming of the AppBar.

PiperOrigin-RevId: 292541295
2020-01-31 07:31:32 -08:00
Jeff Verkoeyen
d17144ee68 [AppBar] Minor clarification to example documentation.
PiperOrigin-RevId: 291942763
2020-01-28 08:57:06 -08:00
Robert Moore
8eb7296dab
[Catalog] Fix container scheme properties. (#9192)
Making remaining examples use protocol for container schemes to match the
project's expected convention.

Found while reviewing #9188
2019-12-09 10:48:25 -05:00
featherless
ae53242109 [AppBar] Add a shouldSetNavigationBarHiddenHideAppBar behavior flag. (#9001)
This new flag allows view controllers to control the visibility of their app bar via the standard UINavigationController setNavigationBarHidden: APIs. When enabled, calls to these APIs will result in the AppBar's visibility being adjusted.

Closes https://github.com/material-components/material-components-ios/issues/5185
2019-12-02 08:32:13 -05:00
Galia Kaufman
af583a5828
[MDC Dragons] AppBar example has low-contrast text (#8966)
Replacing old "Themers" in "Presented" AppBar example with new theming extensions - in order to improve contrast ratio.
2019-11-15 16:26:03 -05:00
Robert Moore
bd832a416c
[AppBar] Make example titles more accurate. (#8828)
Have the titles reflect their catalog breadcrumb names.

Found while auditing dragons.
2019-11-14 15:44:55 -05:00
featherless
5425884431
[examples] Annotate all catalogShouldHideNavigation invocations with @objc. (#8791)
Context:

Due to changes in the Swift runtime over the past years, methods that are considered "optional" in Objective-C need to have @objc annotations in order for Objective-C to be able to perform `respondsToSelector:` invocations.

Problem:
Many of our examples had not annotated their `catalogShouldHideNavigation` methods with the `@objc` annotation, causing the Catalog to wrap the examples in a container app bar view controller. The reason most of these examples would implement `catalogShouldHideNavigation` is because they are managing their own navigation (e.g. to demonstrate AppBar functionality), so this would often result in duplicate AppBars appearing in the example.

The fix:
All `catalogShouldHideNavigation` Swift methods have been annotated with `@objc`.

Fixes https://github.com/material-components/material-components-ios/issues/7576
Fixes https://github.com/material-components/material-components-ios/issues/7578
2019-11-12 16:54:55 -05:00
Cody Weaver
c8d9ab92ab
[AppBar] Update example to have accessibility elements (#7574)
This change adds text to the cell labels within this example so that there are other accessibility elements for VoiceOver to select in this example.
2019-06-13 13:55:16 -04:00
Cody Weaver
1df302cd48
[AppBar] Update swift examples to use theming extension (#7511)
As part of #7510 we need to remove our usage of the typography themer and color themer within our examples. This removes the usages of both for all swift examples.
2019-05-28 23:13:11 -04:00
Yarden Eitan
efe61588a6
update (#7246)
We need to add @objc annotations to colorScheme and typographyScheme instances in our Swift examples, because we moved to Swift 4.2, the respondsToSelector won't find `setColorScheme:` and `setTypographyScheme:` setters otherwise.
2019-04-23 10:21:14 -04:00
Andrew Overton
c56d5d76d3
Add @objc annotations to get examples to show up in Dragons (#7168)
This is a follow up PR for #7166 adds @objc annotations to Swift catalogMetadata() methods, because the Swift 4 compiler no longer attempts to infer what methods should be visible to Objective-C. As a result of this change in the compiler, no Swift examples were showing up in Dragons after #7166. See this article: https://useyourloaf.com/blog/objc-warnings-upgrading-to-swift-4/ for additional context.
2019-04-17 21:35:43 -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
Cody Weaver
048c259a85
[Docs] Minor docs polish (#7053)
While reviewing the release I noticed some extra white spaces within the docs and an extra character in documentation. This PR cleans that up.
2019-04-05 10:25:03 -04:00
Brian Moore
8b9dc9279d [AppBar] Add new Dragons example for incorrect insets during animation (#6971) 2019-03-27 02:14:06 +03:00
Brian Moore
b03820da60 [AppBar] Refactor AppBar example table views (#6974)
This refactors the "simple" example table view controllers used in a bunch of these examples into two types: a "composed" one which creates its own table view and an "inherited" one which subclasses UITableViewController. They behave differently, so this makes that explicit and also reduces some code duplication.
2019-03-22 09:44:29 -04:00
Wenyu Zhang
38f364b8e9
[MDC AppBar] update contentInset when tracked view's adjustedContentInset is changed. (#6868) 2019-03-13 13:09:39 -04:00
Brian Moore
b64e1af395 [AppBar] Add animated tab switching example (#6447)
Test case demonstrating issues with MDCFlexibleHeader and animated tab transitions in MDCAppBar.

Original issue:
https://github.com/material-components/material-components-ios/issues/6437
2019-02-04 09:00:45 -05:00
Robert Moore
800188a649
{clang-format} Format the components. (#6347)
This is a follow-up to https://github.com/material-components/material-components-ios/pull/6027

```
find components \( -name "*.h" -or -name "*.m" \) | xargs clang-format -i
```
2019-01-23 11:08:43 -05:00
Joe Aguilar
f1b96d4f81 [Catalog] Begun audit of swift forced unwrapping in catalog (#6117)
This work is related to #3984. I decided to break it up to make it easier for review.

This change audits the appbar swift examples force unwrapping.
2019-01-03 10:35:06 -05:00
Robert Moore
372d6b24f9
No longer using -init for Color Scheme. (#5734)
{MDC iOS} No longer using `-init` for Color Scheme.

Based on the discussions in go/mdc-ios-theming, we should not use the `-init` default initializer. Instead, we should use an explicit set of defaults.

Search regex: '\[\[MDCSemanticColorScheme alloc\] init\]'
2018-11-12 12:54:47 -05: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
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
rami-a
1ecf3e341a
Add dragons example for appbar that demonstrates issue #5412 (#5471)
This change is to help us fix a client-blocking bug by providing an example that reproduces the issue in #5412
2018-10-23 10:08:14 -04:00
rami-a
160f5b15c1
Fix status bar color appearing incorrect in some Catalog examples (#5363)
I did an audit of the Catalog app to track down screens with an incorrect status bar color and the ones that I found are:
* AppBar -> Presented (This example does not use the app theme so I was able to set the style directly)
* AppBar -> Wrapped
* BottomAppBar

Additionally, I found that changing the Catalog theme from black to another color (and vice-versa) resulted in the status bar being incorrect until the next page navigation. So I created a fix for this too.

Closes #3778
2018-10-08 16:12:51 -04:00
Randall Li
814deb95bc [appbar] Corrected import of example imports 2018-09-26 12:19:05 -04:00