Skip to content

Commit

Permalink
Merge branch 'release-candidate' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Moore committed Aug 13, 2019
2 parents d8969a9 + 716845b commit c6d73fd
Show file tree
Hide file tree
Showing 28 changed files with 268 additions and 48 deletions.
79 changes: 79 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,82 @@
# 87.0.0

This major release improves the `traitCollectionDidChangeBlock` for
`MDCButton`.

## Breaking changes

`MDCButton.traitCollectionDidChangeBlock` now requires an `MDCButton *`
instance as its first parameter. This is to allow passing the button itself
into the block and eliminate the need for retaining the button in its own
block.

### Previous Releases

```objc
button.traitCollectionDidChangeBlock =
^(UITraitCollection *_Nullable previousTraitCollection) {
// Code
};
```

### In This Release
```objc
button.traitCollectionDidChangeBlock =
^(MDCButton *_Nonnull buttonInBlock, UITraitCollection *_Nullable previousTraitCollection) {
// Code
};
```

## API changes

### Buttons

#### MDCButton

*modified* property: `traitCollectionDidChangeBlock` in `MDCButton`

| Type of change: | Swift declaration |
|---|---|
| From: | `var traitCollectionDidChangeBlock: ((UITraitCollection?) -> Void)? { get set }` |
| To: | `var traitCollectionDidChangeBlock: ((MDCButton, UITraitCollection?) -> Void)? { get set }` |

*modified* property: `traitCollectionDidChangeBlock` in `MDCButton`

| Type of change: | Declaration |
|---|---|
| From: | `@property (readwrite, copy, nonatomic, nullable) void (^) (UITraitCollection *_Nullable) traitCollectionDidChangeBlock;` |
| To: | `@property (readwrite, copy, nonatomic, nullable) void (^) (MDCButton *_Nonnull, UITraitCollection *_Nullable) traitCollectionDidChangeBlock;` |

## Changes

### ActionSheet

* [Add dark mode support to theming extension (#8245)](https://github.com/material-components/material-components-ios/commit/d73d498d7ef78b2f728e88f3e45ec6d32ac81283) (Cody Weaver)
* [Stop running swift tests on Autobot. (#8274)](https://github.com/material-components/material-components-ios/commit/ef362e851bdda50d9d0d5ec5526cbc8c700173d1) (Wenyu Zhang)

### ButtonBar

* [Stop running swift tests on Autobot. (#8267)](https://github.com/material-components/material-components-ios/commit/f837b914073a27f72d131dcb7dc1a7108e334321) (Wenyu Zhang)

### Buttons

* [Add missing self to traitCollectionDidChangeBlock (#8276)](https://github.com/material-components/material-components-ios/commit/f4352d73e6cddcb6b8573215788693ab6f6bacc8) (Yarden Eitan)

### FlexibleHeader

* [Stop running swift tests on Autobot. (#8269)](https://github.com/material-components/material-components-ios/commit/aa4478e423fc71d49494959a8ed5b153a690ec4f) (Wenyu Zhang)

### NavigationBar

* [Stop running swift tests on Autobot. (#8272)](https://github.com/material-components/material-components-ios/commit/5f0fadc504fe329f78ac013437777e181e597713) (Wenyu Zhang)

### TextFields

* [Add non-experimental MDCBaseTextField example (#8287)](https://github.com/material-components/material-components-ios/commit/59f5551313f0d465e0196414aeab0b441a801c4c) (Andrew Overton)
* [Stop running swift tests on Autobot. (#8275)](https://github.com/material-components/material-components-ios/commit/65b142ab751dce68ffd8839257b2b853f6509e92) (Wenyu Zhang)

---

# 86.1.0

This minor release introduces new theming APIs for `MDCActionSheetAction` and
Expand Down
5 changes: 3 additions & 2 deletions MaterialComponents.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load 'scripts/generated/icons.rb'

Pod::Spec.new do |mdc|
mdc.name = "MaterialComponents"
mdc.version = "86.1.0"
mdc.version = "87.0.0"
mdc.authors = "The Material Components authors."
mdc.summary = "A collection of stand-alone production-ready UI libraries focused on design details."
mdc.homepage = "https://github.com/material-components/material-components-ios"
Expand Down Expand Up @@ -82,6 +82,8 @@ Pod::Spec.new do |mdc|
extension.public_header_files = "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h"
extension.source_files = "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.{h,m}", "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/private/*.{h,m}"
extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}"
extension.dependency "MaterialComponents/Elevation"
extension.dependency "MaterialComponents/private/Color"
extension.dependency "MaterialComponents/schemes/Container"

extension.test_spec 'UnitTests' do |unit_tests|
Expand Down Expand Up @@ -1859,7 +1861,6 @@ Pod::Spec.new do |mdc|
component.dependency "MaterialComponents/AnimationTiming"
component.dependency "MaterialComponents/Palettes"
component.dependency "MaterialComponents/Typography"
component.dependency "MDFInternationalization"
component.dependency "MaterialComponents/private/Math"
component.dependency "MDFInternationalization"

Expand Down
2 changes: 1 addition & 1 deletion MaterialComponentsBeta.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |mdc|
mdc.name = "MaterialComponentsBeta"
mdc.version = "86.1.0"
mdc.version = "87.0.0"
mdc.authors = "The Material Components authors."
mdc.summary = "A collection of stand-alone alpha UI libraries that are not yet guaranteed to be ready for general production use. Use with caution."
mdc.homepage = "https://github.com/material-components/material-components-ios"
Expand Down
2 changes: 1 addition & 1 deletion MaterialComponentsEarlGreyTests.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MaterialComponentsEarlGreyTests"
s.version = "86.1.0"
s.version = "87.0.0"
s.authors = "The Material Components authors."
s.summary = "This spec is an aggregate of all the Material Components EarlGrey tests."
s.description = "This spec is made for use in the MDC Catalog."
Expand Down
2 changes: 1 addition & 1 deletion MaterialComponentsExamples.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ experimental_resources = [

Pod::Spec.new do |s|
s.name = "MaterialComponentsExamples"
s.version = "86.1.0"
s.version = "87.0.0"
s.authors = "The Material Components authors."
s.summary = "This spec is an aggregate of all the Material Components examples."
s.description = "This spec is made for use in the MDC Catalog. Used in conjunction with CatalogByConvention we create our Material Catalog."
Expand Down
2 changes: 1 addition & 1 deletion MaterialComponentsSnapshotTests.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end

Pod::Spec.new do |s|
s.name = "MaterialComponentsSnapshotTests"
s.version = "86.1.0"
s.version = "87.0.0"
s.authors = "The Material Components authors."
s.summary = "This spec is an aggregate of all the Material Components snapshot tests."
s.homepage = "https://github.com/material-components/material-components-ios"
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
86.1.0
87.0.0
14 changes: 3 additions & 11 deletions catalog/MDCCatalog/AppTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,9 @@ final class AppTheme {
func DefaultContainerScheme() -> MDCContainerScheme {
let containerScheme = MDCContainerScheme()

let colorScheme = MDCSemanticColorScheme(defaults: .material201907)
containerScheme.colorScheme = colorScheme

let typographyScheme = MDCTypographyScheme()
typographyScheme.headline1 = UIFont.systemFont(ofSize: 20)
typographyScheme.headline2 = UIFont.systemFont(ofSize: 18)
typographyScheme.headline3 = UIFont.systemFont(ofSize: 15)
containerScheme.typographyScheme = typographyScheme

let shapeScheme = MDCShapeScheme()
containerScheme.shapeScheme = shapeScheme
containerScheme.colorScheme = MDCSemanticColorScheme(defaults: .material201907)
containerScheme.typographyScheme = MDCTypographyScheme(defaults: .material201902)
containerScheme.shapeScheme = MDCShapeScheme()

return containerScheme
}
4 changes: 2 additions & 2 deletions catalog/MDCCatalog/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>86.1.0</string>
<string>87.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>86.1.0</string>
<string>87.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
Expand Down
2 changes: 1 addition & 1 deletion catalog/MDCCatalog/MDCCatalogComponentsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class MDCCatalogComponentsController: UICollectionViewController, UICollectionVi
titleLabel.text = title!
titleLabel.textColor = AppTheme.containerScheme.colorScheme.onPrimaryColor
titleLabel.textAlignment = .center
titleLabel.font = AppTheme.containerScheme.typographyScheme.headline1
titleLabel.font = AppTheme.containerScheme.typographyScheme.headline6
titleLabel.sizeToFit()

let titleInsets = UIEdgeInsets(top: 0,
Expand Down
4 changes: 2 additions & 2 deletions catalog/MDCDragons/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>86.1.0</string>
<string>87.0.0</string>
<key>CFBundleVersion</key>
<string>86.1.0</string>
<string>87.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
2 changes: 1 addition & 1 deletion catalog/MaterialCatalog/MaterialCatalog.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MaterialCatalog"
s.version = "86.1.0"
s.version = "87.0.0"
s.summary = "Helper Objective-C classes for the MDC catalog."
s.description = "This spec is made for use in the MDC Catalog."
s.homepage = "https://github.com/material-components/material-components-ios"
Expand Down
4 changes: 4 additions & 0 deletions components/ActionSheet/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ mdc_extension_objc_library(
name = "Theming",
deps = [
":ActionSheet",
"//components/Elevation",
"//components/private/Color",
"//components/schemes/Container",
],
)
Expand Down Expand Up @@ -144,6 +146,8 @@ mdc_unit_test_suite(
":unit_test_sources",
":unit_test_swift_sources",
],
# TODO (https://github.com/material-components/material-components-ios/issues/8249): Re-enable autobot environment.
use_autobot_environment_runner = False,
)

mdc_snapshot_objc_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ + (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs" : @[ @"Action Sheet", @"Action Sheet" ],
@"primaryDemo" : @YES,
@"presentable" : @NO
@"presentable" : @YES,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#import "MDCActionSheetController+MaterialTheming.h"
#import "MaterialColor.h"

static const CGFloat kHighAlpha = (CGFloat)0.87;
static const CGFloat kMediumAlpha = (CGFloat)0.6;
Expand All @@ -36,8 +37,13 @@ - (void)applyThemeWithScheme:(id<MDCContainerScheming>)scheme {
[self applyThemeWithTypographyScheme:typographyScheme];
}

- (UIColor *)dynamicColorWithColor:(UIColor *)color elevation:(CGFloat)elevation {
UIColor *darkModeColor = [color mdc_resolvedColorWithElevation:elevation];
return [UIColor colorWithUserInterfaceStyleDarkColor:darkModeColor defaultColor:color];
}

- (void)applyThemeWithColorScheme:(id<MDCColorScheming>)colorScheme {
self.backgroundColor = colorScheme.surfaceColor;
[self applyBackgroundColorToActionSheet:self withColorScheme:colorScheme];
if (self.message && ![self.message isEqualToString:@""]) {
// If there is a message then this can be high opacity and won't clash with actions.
self.titleTextColor = [colorScheme.onSurfaceColor colorWithAlphaComponent:kHighAlpha];
Expand All @@ -51,6 +57,35 @@ - (void)applyThemeWithColorScheme:(id<MDCColorScheming>)colorScheme {
UIColor *rippleColor = [colorScheme.onSurfaceColor colorWithAlphaComponent:kInkAlpha];
self.inkColor = rippleColor;
self.rippleColor = rippleColor;
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
if (@available(iOS 13.0, *)) {
self.traitCollectionDidChangeBlock = ^(MDCActionSheetController *_Nonnull actionSheet,
UITraitCollection *_Nullable previousTraitCollection) {
if ([actionSheet.traitCollection
hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection]) {
[actionSheet applyBackgroundColorToActionSheet:actionSheet withColorScheme:colorScheme];
}
};
self.mdc_elevationDidChangeBlock =
^(id<MDCElevatable> _Nonnull object, CGFloat absoluteElevation) {
if ([object isKindOfClass:[MDCActionSheetController class]]) {
MDCActionSheetController *actionSheet = (MDCActionSheetController *)object;
[actionSheet applyBackgroundColorToActionSheet:actionSheet withColorScheme:colorScheme];
}
};
}
#endif
}

- (void)applyBackgroundColorToActionSheet:(MDCActionSheetController *)actionSheet
withColorScheme:(id<MDCColorScheming>)colorScheme {
if (colorScheme.elevationOverlayEnabledForDarkMode) {
actionSheet.backgroundColor =
[self dynamicColorWithColor:colorScheme.surfaceColor
elevation:actionSheet.view.mdc_absoluteElevation];
} else {
actionSheet.backgroundColor = colorScheme.surfaceColor;
}
}

- (void)applyThemeWithTypographyScheme:(id<MDCTypographyScheming>)typographyScheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ - (void)testActionSheetThemingTest {
XCTAssertEqualObjects(actionSheetCell.inkTouchController.defaultInkView.inkColor,
[self.colorScheme.onSurfaceColor colorWithAlphaComponent:kInkAlpha]);
XCTAssertEqualObjects(actionSheetCell.actionLabel.font, typographyScheme.subtitle1);
[self assertTraitCollectionBlockAndElevationBlockForActionSheet:self.actionSheet];
}

- (void)testActionSheetThemingTestWithHeaderOnly {
Expand All @@ -108,6 +109,7 @@ - (void)testActionSheetThemingTestWithHeaderOnly {
// Then
XCTAssertEqualObjects(self.actionSheet.header.titleLabel.textColor,
[self.colorScheme.onSurfaceColor colorWithAlphaComponent:kMediumAlpha]);
[self assertTraitCollectionBlockAndElevationBlockForActionSheet:self.actionSheet];
}

- (void)testActionSheetThemingTestWithMessageOnly {
Expand All @@ -120,6 +122,7 @@ - (void)testActionSheetThemingTestWithMessageOnly {
// Then
XCTAssertEqualObjects(self.actionSheet.header.messageLabel.textColor,
[self.colorScheme.onSurfaceColor colorWithAlphaComponent:kMediumAlpha]);
[self assertTraitCollectionBlockAndElevationBlockForActionSheet:self.actionSheet];
}

- (void)testActionSheetThemingTestWithHeaderAndMessage {
Expand All @@ -135,6 +138,23 @@ - (void)testActionSheetThemingTestWithHeaderAndMessage {
[self.colorScheme.onSurfaceColor colorWithAlphaComponent:kHighAlpha]);
XCTAssertEqualObjects(self.actionSheet.header.messageLabel.textColor,
[self.colorScheme.onSurfaceColor colorWithAlphaComponent:kMediumAlpha]);
[self assertTraitCollectionBlockAndElevationBlockForActionSheet:self.actionSheet];
}

- (void)assertTraitCollectionBlockAndElevationBlockForActionSheet:
(MDCActionSheetController *)actionSheet {
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
if (@available(iOS 13.0, *)) {
XCTAssertNotNil(self.actionSheet.mdc_elevationDidChangeBlock);
XCTAssertNotNil(self.actionSheet.traitCollectionDidChangeBlock);
} else {
XCTAssertNil(self.actionSheet.mdc_elevationDidChangeBlock);
XCTAssertNil(self.actionSheet.traitCollectionDidChangeBlock);
}
#else
XCTAssertNil(self.actionSheet.mdc_elevationDidChangeBlock);
XCTAssertNil(self.actionSheet.traitCollectionDidChangeBlock);
#endif
}

@end
2 changes: 2 additions & 0 deletions components/ButtonBar/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ mdc_unit_test_suite(
":unit_test_sources",
":unit_test_swift_sources",
],
# TODO (https://github.com/material-components/material-components-ios/issues/8249): Re-enable autobot environment.
use_autobot_environment_runner = False,
)

mdc_snapshot_objc_library(
Expand Down
2 changes: 1 addition & 1 deletion components/Buttons/src/MDCButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
traitCollectionDidChange:. The block is called after the call to the superclass.
*/
@property(nonatomic, copy, nullable) void (^traitCollectionDidChangeBlock)
(UITraitCollection *_Nullable previousTraitCollection);
(MDCButton *_Nonnull button, UITraitCollection *_Nullable previousTraitCollection);

/**
A color used as the button's @c backgroundColor for @c state.
Expand Down
2 changes: 1 addition & 1 deletion components/Buttons/src/MDCButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];

if (self.traitCollectionDidChangeBlock) {
self.traitCollectionDidChangeBlock(previousTraitCollection);
self.traitCollectionDidChangeBlock(self, previousTraitCollection);
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/Buttons/tests/unit/MDCButtonTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1340,15 +1340,20 @@ - (void)testTraitCollectionDidChangeBlockCalledWhenTraitCollectionChanges {
MDCButton *button = [[MDCButton alloc] init];
XCTestExpectation *expectation =
[self expectationWithDescription:@"Called traitCollectionDidChange"];
button.traitCollectionDidChangeBlock = ^(UITraitCollection *_Nullable previousTraitCollection) {
[expectation fulfill];
};

__block MDCButton *passedButton;
button.traitCollectionDidChangeBlock =
^(MDCButton *_Nonnull buttonInBlock, UITraitCollection *_Nullable previousTraitCollection) {
passedButton = buttonInBlock;
[expectation fulfill];
};

// When
[button traitCollectionDidChange:nil];

// Then
[self waitForExpectations:@[ expectation ] timeout:1];
XCTAssertEqual(passedButton, button);
}

#pragma mark - MaterialElevation
Expand Down
Loading

0 comments on commit c6d73fd

Please sign in to comment.