Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

[AppBar] Always apply the default shadow behavior when theming.#9529

Closed
jverkoey wants to merge 3 commits intomaterial-components:developfrom
jverkoey:theming
Closed

[AppBar] Always apply the default shadow behavior when theming.#9529
jverkoey wants to merge 3 commits intomaterial-components:developfrom
jverkoey:theming

Conversation

@jverkoey
Copy link
Contributor

@jverkoey jverkoey commented Jan 30, 2020

Both Primary and Surface theming are expected to have a shadow when scrolled. See https://material.io/components/app-bars-top/#theming for more details.

This fixes a bug where the AppBar's Primary theming implementation would set a shadow layer that would not react to scrolling.

Example before/after of a Surface-themed app bar (note the darker shadow in alignment with the expected behavior)

Before After
before after

Related to https://github.com/material-components/material-components-ios/issues/6332

@material-automation
Copy link

material-automation commented Jan 30, 2020

bazel detected changes to the following targets:

//components/AppBar:ObjcExamples
//components/AppBar:SwiftExamples
//components/AppBar:Theming
//components/AppBar:snapshot_test_lib
//components/AppBar:snapshot_tests
//components/AppBar:snapshot_tests.swift_runtime_linkopts
//components/AppBar:snapshot_tests_test_binary
//components/AppBar:snapshot_tests_test_bundle
//components/AppBar:unit_test_sources
//components/AppBar:unit_tests
//components/AppBar:unit_tests_IPAD_PRO_12_9_IN_9_3
//components/AppBar:unit_tests_IPAD_PRO_12_9_IN_9_3.swift_runtime_linkopts
//components/AppBar:unit_tests_IPAD_PRO_12_9_IN_9_3_test_binary
//components/AppBar:unit_tests_IPAD_PRO_12_9_IN_9_3_test_bundle
//components/AppBar:unit_tests_IPHONE_7_PLUS_IN_10_3
//components/AppBar:unit_tests_IPHONE_7_PLUS_IN_10_3.swift_runtime_linkopts
//components/AppBar:unit_tests_IPHONE_7_PLUS_IN_10_3_test_binary
//components/AppBar:unit_tests_IPHONE_7_PLUS_IN_10_3_test_bundle
//components/AppBar:unit_tests_environment
//components/AppBar:unit_tests_environment.swift_runtime_linkopts
//components/AppBar:unit_tests_environment_test_binary
//components/AppBar:unit_tests_environment_test_bundle
//components/Banner:ObjcExamples

CGFloat elevation = MDCShadowElevationAppBar * intensity;
weakSelf.headerView.elevation = elevation;
[(MDCShadowLayer *)shadowLayer setElevation:elevation];
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggested the following change:

-  ^(CALayer *_Nonnull shadowLayer, CGFloat intensity) {
-    CGFloat elevation = MDCShadowElevationAppBar * intensity;
-    weakSelf.headerView.elevation = elevation;
-    [(MDCShadowLayer *)shadowLayer setElevation:elevation];
-  };
+      ^(CALayer *_Nonnull shadowLayer, CGFloat intensity) {
+        CGFloat elevation = MDCShadowElevationAppBar * intensity;
+        weakSelf.headerView.elevation = elevation;
+        [(MDCShadowLayer *)shadowLayer setElevation:elevation];
+      };

@jverkoey jverkoey requested a review from a team as a code owner January 30, 2020 15:26
@jverkoey jverkoey requested review from bryanoltman, fluxminds, galiak11 and yarneo and removed request for a team January 30, 2020 15:26
@jverkoey jverkoey closed this Jan 30, 2020
copybara-service bot pushed a commit that referenced this pull request Jan 31, 2020
Both Primary and Surface theming are expected to have a shadow when scrolled. See https://material.io/components/app-bars-top/#theming for more details.

This fixes a bug where the AppBar's Primary theming implementation would set a shadow layer that would not react to scrolling.

Example before/after of a Surface-themed app bar (note the darker shadow in alignment with the expected behavior)

| Before | After |
|:--|:--|
| ![before](https://user-images.githubusercontent.com/45670/73462821-5e7b4800-434a-11ea-97e9-b6ed8a05696d.png) | ![after](https://user-images.githubusercontent.com/45670/73462834-61763880-434a-11ea-8114-6712e397fe3d.png) |

Related to https://github.com/material-components/material-components-ios/issues/6332

Closes #9529

COPYBARA_INTEGRATE_REVIEW=#9529 from jverkoey:theming 62ba0b8
PiperOrigin-RevId: 292526419
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants