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
andrewoverton committed Nov 8, 2019
2 parents 63ca061 + a131422 commit 9a82b0c
Show file tree
Hide file tree
Showing 72 changed files with 281 additions and 79 deletions.
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
# 94.0.0

This major release adds a new configuration block to MDCSnackBarMessage and moves the currently in development MDCTextControl based TextFields from the TextFields component directory to their own TextControls directory. While there are no API changes associated with this move, it does have the potential to break anyone importing these textfields from their old location, hence the major version bump.

## New features

MDCSnackBarMessage now provides a block that is called before the message is presented. This allows clients to perform last minute configurations.

**Objective-C**

```objc
MDCSnackbarMessage *message = [[MDCSnackbarMessage alloc] init];
message.snackbarMessageWillPresentBlock =
^(MDCSnackbarMessage *snackbarMessage, MDCSnackbarMessageView *messageView) {
// Configure snackbar message.
};
[MDCSnackbarManager showMessage:message];
```

**Swift**

```swift
let message = MDCSnackbarMessage()
message.snackbarMessageWillPresentBlock = { snackbarMessage, messageView in
// Configure snackbar message.
}
MDCSnackbarManager.showMessage(message)
```

## Component changes

### TextControls

* [Move new TextFields into TextControls directory. (#8726)](https://github.com/material-components/material-components-ios/commit/02f9c9f01d049305a8f79eb2afd16bff5caf71d2) (Andrew Overton)

### Snackbar

* [Fix MDCSnackbarMessage convenience class methods (#8746)](https://github.com/material-components/material-components-ios/commit/f2821ce66ae3cb7360dd14f9dfdd8d80e01b2613) (Yarden Eitan)

* [Fix MDCSnackbarMessage convenience class methods (#8751)](https://github.com/material-components/material-components-ios/commit/e5a94aea1fe5c7f5d96ae11984c36416c641e1d5) (Yarden Eitan)

---

# 93.5.0

This minor release introduces new APIs for Slider. The track height and the
Expand Down
28 changes: 14 additions & 14 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 = "93.5.0"
mdc.version = "94.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 @@ -1885,24 +1885,24 @@ Pod::Spec.new do |mdc|
end
end

mdc.subspec "TextFields+ContainedInputView" do |extension|
extension.ios.deployment_target = '9.0'
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}"
mdc.subspec "TextControls" do |component|
component.ios.deployment_target = '9.0'
component.public_header_files = "components/#{component.base_name}/src/*.h"
component.source_files = [
"components/#{component.base_name}/src/*.{h,m}",
"components/#{component.base_name}/src/private/*.{h,m}"
]

extension.dependency "MaterialComponents/AnimationTiming"
extension.dependency "MaterialComponents/private/Math"
extension.dependency "MDFInternationalization"
component.dependency "MaterialComponents/AnimationTiming"
component.dependency "MaterialComponents/private/Math"
component.dependency "MDFInternationalization"

extension.test_spec 'UnitTests' do |unit_tests|
component.test_spec 'UnitTests' do |unit_tests|
unit_tests.source_files = [
"components/#{extension.base_name.split('+')[0]}/tests/unit/#{extension.base_name.split('+')[1]}/*.{h,m,swift}",
"components/#{extension.base_name.split('+')[0]}/tests/unit/#{extension.base_name.split('+')[1]}/supplemental/*.{h,m,swift}"
"components/#{component.base_name}/tests/unit/*.{h,m,swift}",
"components/#{component.base_name}/tests/unit/supplemental/*.{h,m,swift}"
]
unit_tests.resources = "components/#{extension.base_name.split('+')[0]}/tests/unit/#{extension.base_name.split('+')[1]}/resources/*"
unit_tests.resources = "components/#{component.base_name.split('+')[0]}/tests/unit/#{component.base_name.split('+')[1]}/resources/*"
end
end

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 = "93.5.0"
mdc.version = "94.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 = "93.5.0"
s.version = "94.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
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "MaterialComponentsExamples"
s.version = "93.5.0"
s.version = "94.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 = "93.5.0"
s.version = "94.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 @@
93.5.0
94.0.0
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>93.5.0</string>
<string>94.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>93.5.0</string>
<string>94.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
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>93.5.0</string>
<string>94.0.0</string>
<key>CFBundleVersion</key>
<string>93.5.0</string>
<string>94.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 = "93.5.0"
s.version = "94.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
2 changes: 1 addition & 1 deletion catalog/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ target "MDCCatalog" do
'Tabs/UnitTests',
'Tabs+Theming/UnitTests',
'TextFields/UnitTests',
'TextFields+ContainedInputView/UnitTests',
'TextControls/UnitTests',
'TextFields+Theming/UnitTests',
'Themes/UnitTests',
'Typography/UnitTests',
Expand Down
2 changes: 1 addition & 1 deletion components/LibraryInfo/src/MDCLibraryInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// This string is updated automatically as a part of the release process and should not be edited
// manually. Do not rename this constant or change the formatting without updating the release
// scripts.
static NSString const *MDCLibraryInfoVersionString = @"93.5.0";
static NSString const *MDCLibraryInfoVersionString = @"94.0.0";

@implementation MDCLibraryInfo

Expand Down
2 changes: 1 addition & 1 deletion components/LibraryInfo/tests/unit/LibraryInfoTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ - (void)testVersionFormat {
// Given

// This regex pattern does the following:
// Accept: "93.5.0", etc.
// Accept: "94.0.0", etc.
// 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.
//
// Note the major version must be >= 1 since "0.0.0" is used as the version when something goes
Expand Down
24 changes: 23 additions & 1 deletion components/Snackbar/examples/SnackbarSimpleExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (void)viewDidLoad {
[self setupExampleViews:@[
@"Simple Snackbar", @"Snackbar with Action Button", @"Snackbar with Long Text",
@"Attributed Text Example", @"Color Themed Snackbar", @"Customize Font Example",
@"De-Customize Example"
@"De-Customize Example", @"Customized Message Using Block"
]];
self.title = @"Snackbar";
_legacyMode = YES;
Expand Down Expand Up @@ -80,6 +80,7 @@ - (void)toggleDynamicType {
- (void)showSimpleSnackbar:(id)sender {
MDCSnackbarMessage *message = [[MDCSnackbarMessage alloc] init];
message.text = @"Snackbar Message";
message.focusOnShow = YES;
[MDCSnackbarManager showMessage:message];
}

Expand Down Expand Up @@ -170,6 +171,25 @@ - (void)showDecustomizedSnackbar:(id)sender {
[MDCSnackbarManager showMessage:message];
}

- (void)showCustomizedSnackbarWithActionUsingBlock:(id)sender {
MDCSnackbarMessage *message = [[MDCSnackbarMessage alloc] init];
message.text = @"Snackbar Message";
MDCSnackbarMessageAction *action = [[MDCSnackbarMessageAction alloc] init];
action.title = @"Tap Me";
message.action = action;
message.enableRippleBehavior = YES;
message.snackbarMessageWillPresentBlock =
^(MDCSnackbarMessage *snackbarMessage, MDCSnackbarMessageView *messageView) {
messageView.backgroundColor = UIColor.blueColor;
messageView.messageTextColor = UIColor.whiteColor;
for (MDCButton *button in messageView.actionButtons) {
[button setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
[button setTitleColor:UIColor.whiteColor forState:UIControlStateHighlighted];
}
};
[MDCSnackbarManager showMessage:message];
}

#pragma mark - UICollectionView

- (void)collectionView:(UICollectionView *)collectionView
Expand Down Expand Up @@ -197,6 +217,8 @@ - (void)collectionView:(UICollectionView *)collectionView
case 6:
[self showDecustomizedSnackbar:nil];
break;
case 7:
[self showCustomizedSnackbarWithActionUsingBlock:nil];
default:
break;
}
Expand Down
5 changes: 4 additions & 1 deletion components/Snackbar/src/MDCSnackbarManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ - (void)displaySnackbarViewForMessage:(MDCSnackbarMessage *)message {
snackbarView.accessibilityViewIsModal =
self.manager.shouldEnableAccessibilityViewIsModal && ![self isSnackbarTransient:snackbarView];
[self.delegate willPresentSnackbarWithMessageView:snackbarView];
if (message.snackbarMessageWillPresentBlock) {
message.snackbarMessageWillPresentBlock(message, snackbarView);
}
self.currentSnackbar = snackbarView;
self.overlayView.accessibilityViewIsModal = snackbarView.accessibilityViewIsModal;
self.overlayView.hidden = NO;
Expand All @@ -241,7 +244,7 @@ - (void)displaySnackbarViewForMessage:(MDCSnackbarMessage *)message {
showSnackbarView:snackbarView
animated:YES
completion:^{
if (snackbarView.accessibilityViewIsModal ||
if (snackbarView.accessibilityViewIsModal || message.focusOnShow ||
![self isSnackbarTransient:snackbarView]) {
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification,
snackbarView);
Expand Down
20 changes: 20 additions & 0 deletions components/Snackbar/src/MDCSnackbarMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import <UIKit/UIKit.h>

@class MDCSnackbarMessageAction;
@class MDCSnackbarMessageView;

/**
Called when a message is finished displaying, regardless of whether or not buttons were tapped.
Expand Down Expand Up @@ -158,6 +159,25 @@ extern NSString *__nonnull const MDCSnackbarMessageBoldAttributeName;
*/
@property(nonatomic, assign) BOOL enableRippleBehavior;

/**
Whether to focus on the Snackbar message when VoiceOver is enabled.
The message is announced but not focused when set to NO.
Note: Setting this to YES will ensure the entire snackbar message is read during VoiceOver, and
that the message persists until an action is made on the message.
Defaults to NO.
*/
@property(nonatomic) BOOL focusOnShow;

/**
A block that is invoked when the corresponding @c MDCSnackbarMessageView of the @c
MDCSnackbarMessage instance will be presented. Use this to customize @c MDCSnackbarMessageView
before presentation.
*/
@property(nonatomic, copy, nullable) void (^snackbarMessageWillPresentBlock)
(MDCSnackbarMessage *_Nonnull message, MDCSnackbarMessageView *_Nonnull messageView);

@end

/**
Expand Down
2 changes: 2 additions & 0 deletions components/Snackbar/src/MDCSnackbarMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ - (instancetype)copyWithZone:(__unused NSZone *)zone {
copy.buttonTextColor = self.buttonTextColor;
#pragma clang diagnostic pop
copy.enableRippleBehavior = self.enableRippleBehavior;
copy.focusOnShow = self.focusOnShow;

// Unfortunately there's not really a concept of 'copying' a block (in the same way you would copy
// a string, for example). A block's pointer is immutable once it is created and copied to the
// heap, so we're pretty safe just using the same block.
copy.completionHandler = self.completionHandler;
copy.action = self.action;
copy.snackbarMessageWillPresentBlock = self.snackbarMessageWillPresentBlock;

return copy;
}
Expand Down
40 changes: 40 additions & 0 deletions components/Snackbar/tests/unit/MDCSnackbarMessageViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -467,4 +467,44 @@ - (void)testMessageViewAdjustsFontForContentSizeCategoryWhenScaledFontIsUnavaila
XCTAssertTrue(messageView.adjustsFontForContentSizeCategoryWhenScaledFontIsUnavailable);
}

- (void)testMessageStaysWhenFocusOnShowIsEnabled {
// Given
self.manager.internalManager.isVoiceOverRunningOverride = YES;
self.message.focusOnShow = YES;
self.message.duration = 0.1;

// When
[self.manager showMessage:self.message];
XCTestExpectation *expectation = [self expectationWithDescription:@"completed"];
dispatch_time_t popTime =
dispatch_time(DISPATCH_TIME_NOW, (int64_t)((CGFloat)0.2 * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^{
[expectation fulfill];
});
[self waitForExpectationsWithTimeout:3 handler:nil];

// Then
XCTAssertFalse(self.manager.internalManager.currentSnackbar.accessibilityElementsHidden);
}

- (void)testMessageCustomizationUsingWillPresentBlock {
// Given
__block BOOL blockCalled = NO;
self.message.snackbarMessageWillPresentBlock =
^(MDCSnackbarMessage *snackbarMessage, MDCSnackbarMessageView *messageView) {
blockCalled = YES;
};

// When
[self.manager showMessage:self.message];
XCTestExpectation *expectation = [self expectationWithDescription:@"completed"];
dispatch_async(dispatch_get_main_queue(), ^{
[expectation fulfill];
});
[self waitForExpectationsWithTimeout:3 handler:nil];

// Then
XCTAssertTrue(blockCalled);
}

@end
Loading

0 comments on commit 9a82b0c

Please sign in to comment.