Skip to content

Commit 020a956

Browse files
committed
Merge branch 'release-candidate' into stable
2 parents beea7e6 + 6b168e6 commit 020a956

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+741
-1878
lines changed

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
# 124.1.1
2+
3+
In this minor release we added a new Shadow Component and removed the Shrine demo.
4+
5+
## New features
6+
7+
A new Shadow Component.
8+
9+
## API changes
10+
11+
### Shadow
12+
13+
Use the new Shadow component to create a shadow adjusted to your elevation:
14+
15+
16+
```objc
17+
MDCShadow *lowElevationShadow = MDCShadowForElevation(2);
18+
MDCShadow *highElevationShadow = MDCShadowForElevation(24);
19+
```
20+
21+
```swift
22+
let lowElevation = MDCShadowForElevation(2)
23+
let highElevation = MDCShadowForElevation(24)
24+
```
25+
26+
## Component changes
27+
28+
### Shadow
29+
30+
* [New in-development Shadow component (not ready for public use).](https://github.com/material-components/material-components-ios/commit/ff33bab752cb518e46d2a2d4011045d081428b80) (Ben Hamilton)
31+
32+
---
33+
134
# 124.0.1
235

336
This patch release fixes a bug in BottomNavigation.

MaterialComponents.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load 'scripts/generated/icons.rb'
22

33
Pod::Spec.new do |mdc|
44
mdc.name = "MaterialComponents"
5-
mdc.version = "124.0.1"
5+
mdc.version = "124.1.1"
66
mdc.authors = "The Material Components authors."
77
mdc.summary = "A collection of stand-alone production-ready UI libraries focused on design details."
88
mdc.homepage = "https://github.com/material-components/material-components-ios"

MaterialComponentsEarlGreyTests.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "MaterialComponentsEarlGreyTests"
3-
s.version = "124.0.1"
3+
s.version = "124.1.1"
44
s.authors = "The Material Components authors."
55
s.summary = "This spec is an aggregate of all the Material Components EarlGrey tests."
66
s.description = "This spec is made for use in the MDC Catalog."

MaterialComponentsExamples.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "MaterialComponentsExamples"
3-
s.version = "124.0.1"
3+
s.version = "124.1.1"
44
s.authors = "The Material Components authors."
55
s.summary = "This spec is an aggregate of all the Material Components examples."
66
s.description = "This spec is made for use in the MDC Catalog. Used in conjunction with CatalogByConvention we create our Material Catalog."

MaterialComponentsSnapshotTests.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ end
5353

5454
Pod::Spec.new do |s|
5555
s.name = "MaterialComponentsSnapshotTests"
56-
s.version = "124.0.1"
56+
s.version = "124.1.1"
5757
s.authors = "The Material Components authors."
5858
s.summary = "This spec is an aggregate of all the Material Components snapshot tests."
5959
s.homepage = "https://github.com/material-components/material-components-ios"

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
124.0.1
1+
124.1.1

catalog/MDCCatalog/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>124.0.1</string>
18+
<string>124.1.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>124.0.1</string>
22+
<string>124.1.1</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UIAppFonts</key>

catalog/MDCDragons/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>124.0.1</string>
18+
<string>124.1.1</string>
1919
<key>CFBundleVersion</key>
20-
<string>124.0.1</string>
20+
<string>124.1.1</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>UILaunchStoryboardName</key>

catalog/MaterialCatalog/MaterialCatalog.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "MaterialCatalog"
3-
s.version = "124.0.1"
3+
s.version = "124.1.1"
44
s.summary = "Helper Objective-C classes for the MDC catalog."
55
s.description = "This spec is made for use in the MDC Catalog."
66
s.homepage = "https://github.com/material-components/material-components-ios"

components/LibraryInfo/src/MDCLibraryInfo.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// This string is updated automatically as a part of the release process and should not be edited
2020
// manually. Do not rename this constant or change the formatting without updating the release
2121
// scripts.
22-
static NSString* const kMDCLibraryInfoVersionString = @"124.0.1";
22+
static NSString* const kMDCLibraryInfoVersionString = @"124.1.1";
2323

2424
@implementation MDCLibraryInfo
2525

components/LibraryInfo/tests/unit/LibraryInfoTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ - (void)testVersionFormat {
2626
// Given
2727

2828
// This regex pattern does the following:
29-
// Accept: "124.0.1", etc.
29+
// Accept: "124.1.1", etc.
3030
// Reject: "0.0.0", "1.2", "1", "-1.2.3", "Hi, I'm a version 1.2.3", "1.2.3 is my version", etc.
3131
//
3232
// Note the major version must be >= 1 since "0.0.0" is used as the version when something goes

components/Shadow/src/MDCShadow.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2021-present the Material Components for iOS authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#import <UIKit/UIKit.h>
16+
17+
/**
18+
Immutable value type holding shadow metrics to apply to a view's layer. Use
19+
`MDCShadowForElevation()` or `MDCShadowBuilder` to create this object.
20+
*/
21+
__attribute__((objc_subclassing_restricted)) @interface MDCShadow : NSObject
22+
23+
/** CALayer.shadowOpacity */
24+
@property(nonatomic, readonly) CGFloat opacity;
25+
26+
/** CALayer.shadowRadius */
27+
@property(nonatomic, readonly) CGFloat radius;
28+
29+
/** CALayer.shadowOffset */
30+
@property(nonatomic, readonly) CGSize offset;
31+
32+
- (nonnull instancetype)init NS_UNAVAILABLE;
33+
34+
@end
35+
36+
/**
37+
Mutable builder to construct immutable `MDCShadow` objects.
38+
*/
39+
__attribute__((objc_subclassing_restricted)) @interface MDCShadowBuilder : NSObject
40+
41+
/** CALayer.shadowOpacity */
42+
@property(nonatomic) CGFloat opacity;
43+
44+
/** CALayer.shadowRadius */
45+
@property(nonatomic) CGFloat radius;
46+
47+
/** CALayer.shadowOffset */
48+
@property(nonatomic) CGSize offset;
49+
50+
/** Returns an immutable value type containing a snapshot of the values in this object. */
51+
- (nonnull MDCShadow *)build;
52+
53+
@end
54+
55+
/**
56+
Default color for a Material shadow. On iOS >= 13, this is a dynamic color.
57+
*/
58+
FOUNDATION_EXTERN UIColor *_Nonnull MDCShadowColor(void);
59+
60+
/**
61+
Returns an `MDCShadow` representing the Material shadow metrics for the given elevation (in
62+
points).
63+
*/
64+
FOUNDATION_EXTERN MDCShadow *_Nonnull MDCShadowForElevation(CGFloat elevation);

components/Shadow/src/MDCShadow.m

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// Copyright 2021-present the Material Components for iOS authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#import "MDCShadow.h"
16+
17+
#import "MaterialAvailability.h"
18+
#import "MDCShadow+Internal.h"
19+
20+
@implementation MDCShadow
21+
22+
- (instancetype)initWithOpacity:(CGFloat)opacity radius:(CGFloat)radius offset:(CGSize)offset {
23+
self = [super init];
24+
if (self) {
25+
_opacity = opacity;
26+
_radius = radius;
27+
_offset = offset;
28+
}
29+
return self;
30+
}
31+
32+
- (BOOL)isEqual:(id)other {
33+
if (self == other) {
34+
return YES;
35+
}
36+
if (![other isKindOfClass:[MDCShadow class]]) {
37+
return NO;
38+
}
39+
MDCShadow *otherShadow = other;
40+
return _opacity == otherShadow.opacity && _radius == otherShadow.radius &&
41+
CGSizeEqualToSize(_offset, otherShadow.offset);
42+
}
43+
44+
- (NSUInteger)hash {
45+
const NSUInteger kPrime = 31;
46+
NSUInteger result = 1;
47+
result = result * kPrime + (NSUInteger)_opacity;
48+
result = result * kPrime + (NSUInteger)_radius;
49+
result = result * kPrime + (NSUInteger)(_offset.width);
50+
result = result * kPrime + (NSUInteger)(_offset.height);
51+
return result;
52+
}
53+
54+
@end
55+
56+
@implementation MDCShadowBuilder
57+
58+
- (MDCShadow *)build {
59+
return [[MDCShadow alloc] initWithOpacity:self.opacity radius:self.radius offset:self.offset];
60+
}
61+
62+
@end
63+
64+
static UIColor *LightStyleShadowColor(void) {
65+
static UIColor *lightStyleShadowColor;
66+
static dispatch_once_t onceToken;
67+
dispatch_once(&onceToken, ^{
68+
lightStyleShadowColor = [UIColor colorWithRed:0.235 green:0.251 blue:0.263 alpha:1];
69+
});
70+
return lightStyleShadowColor;
71+
}
72+
73+
UIColor *MDCShadowColor(void) {
74+
#if MDC_AVAILABLE_SDK_IOS(13_0)
75+
if (@available(iOS 13.0, *)) {
76+
return [UIColor colorWithDynamicProvider:^(UITraitCollection *traitCollection) {
77+
switch (traitCollection.userInterfaceStyle) {
78+
case UIUserInterfaceStyleUnspecified:
79+
__attribute__((fallthrough));
80+
case UIUserInterfaceStyleLight:
81+
return LightStyleShadowColor();
82+
case UIUserInterfaceStyleDark:
83+
return UIColor.blackColor;
84+
}
85+
__builtin_unreachable();
86+
}];
87+
}
88+
#endif // MDC_AVAILABLE_SDK_IOS(13_0)
89+
return LightStyleShadowColor();
90+
}
91+
92+
static int ShadowElevationToLevel(CGFloat elevation) {
93+
if (elevation < 1) {
94+
return 0;
95+
}
96+
if (elevation < 3) {
97+
return 1;
98+
}
99+
if (elevation < 6) {
100+
return 2;
101+
}
102+
if (elevation < 8) {
103+
return 3;
104+
}
105+
if (elevation < 12) {
106+
return 4;
107+
}
108+
return 5;
109+
}
110+
111+
MDCShadow *MDCShadowForElevation(CGFloat elevation) {
112+
static NSArray *shadowLevels;
113+
static dispatch_once_t onceToken;
114+
dispatch_once(&onceToken, ^{
115+
shadowLevels = @[
116+
[[MDCShadow alloc] initWithOpacity:0 radius:0 offset:CGSizeMake(0, 0)],
117+
[[MDCShadow alloc] initWithOpacity:0.43 radius:2.5 offset:CGSizeMake(0, 1)],
118+
[[MDCShadow alloc] initWithOpacity:0.4 radius:3.25 offset:CGSizeMake(0, 1.25)],
119+
[[MDCShadow alloc] initWithOpacity:0.34 radius:4.75 offset:CGSizeMake(0, 2.25)],
120+
[[MDCShadow alloc] initWithOpacity:0.42 radius:6 offset:CGSizeMake(0, 3)],
121+
[[MDCShadow alloc] initWithOpacity:0.4 radius:7.25 offset:CGSizeMake(0, 5)],
122+
];
123+
});
124+
int shadowLevel = ShadowElevationToLevel(elevation);
125+
return shadowLevels[shadowLevel];
126+
}

0 commit comments

Comments
 (0)