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
randallli committed Jan 27, 2021
2 parents 9f98163 + d6d3cbe commit 672a406
Show file tree
Hide file tree
Showing 34 changed files with 474 additions and 74 deletions.
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
# 121.0.0

In this major release, we added a `scrollViewBounce` property and a `adjustHeightForSafeAreaInsets` property to BottomSheets, added a `shouldAutorotateOverride` property, a `preferredInterfaceOrientationForPresentationOverride` property, a `supportedInterfaceOrientationsOverride` property, and a `modalTransitionStyleOverride` property to MDCAlertController, and converted `progressTintColors` property on MDCProgressView to use light weight generics.

## Breaking changes

### ProgressView

MDCProgressView's property `progressTintColors` started using light weight generics so values pass in need to be typed correctly.

## New features

### BottomSheet

Bottom sheets have new propertie that turn off the overscroll and safe area insets.

### Dialogs

Added a `shouldAutorotateOverride` property, a `preferredInterfaceOrientationForPresentationOverride` property, a `supportedInterfaceOrientationsOverride` property, and a `modalTransitionStyleOverride` property to MDCAlertController.

### ProgressView

Converted `progressTintColors` property on MDCProgressView to use light weight generics.

## Component changes

### BottomSheet

* [Add BOOL property for whether or not the height of the bottom sheet should adjust for safe area insets.](https://github.com/material-components/material-components-ios/commit/1fefeaf03268b9126dfaea00907a9bb5362560e5) (Alyssa Weiss)
* [Add flag that turns off simulated bouncing when there isn't a tracking scroll view](https://github.com/material-components/material-components-ios/commit/1b985100ec89ed142981bd8f3d51b247f88e6f0c) (Andrew Overton)

### Buttons

* [Add documentation for Enums.](https://github.com/material-components/material-components-ios/commit/c727b890df3c0766706ad8000649f7733cdef997) (Cody Weaver)

### Chips

* [Add docs for MDCChipField](https://github.com/material-components/material-components-ios/commit/3f7cc9f51cf9ea9287b3e817bc730eaac31bd87e) (Andrew Overton)

### Dialogs

* [Adding customized interface orientations and transition style support to the alert dialog.](https://github.com/material-components/material-components-ios/commit/a9b6ca12b5cba778176b7cb129e866b8669ac8bc) (Nobody)

### List

* [Use isKindOfClass to ensure there is support for all MDCShadowLayer's subclasses.](https://github.com/material-components/material-components-ios/commit/d5bba14e9a51405ee2ed868fd630d852c49d0c6e) (Yarden Eitan)

### ProgressView

* [Add Objective-C generics to MDCProgressView](https://github.com/material-components/material-components-ios/commit/1b70fd6ad949c143d7225e3719c912fce8181719) (Andrew Overton)

---

# 120.0.0

In this major release, we deleted the `elevationOverlayColor` property from MDCSemanticColorScheme, added a `placeholderColor` property to MDCTextControls, added a `shapedBorderColor` property and a `shapedBorderWidth` property to MDCShapedView, and made multiple bug fixes.
Expand Down
2 changes: 1 addition & 1 deletion 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 = "120.0.0"
mdc.version = "121.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
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 = "120.0.0"
s.version = "121.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 = "120.0.0"
s.version = "121.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 = "120.0.0"
s.version = "121.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 @@
120.0.0
121.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>120.0.0</string>
<string>121.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>120.0.0</string>
<string>121.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>120.0.0</string>
<string>121.0.0</string>
<key>CFBundleVersion</key>
<string>120.0.0</string>
<string>121.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 = "120.0.0"
s.version = "121.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
10 changes: 10 additions & 0 deletions components/BottomSheet/src/MDCBottomSheetController.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@
*/
@property(nonatomic, assign) MDCShadowElevation elevation;

/**
Whether or not the height of the bottom sheet should adjust to include extra height for any bottom
safe area insets. If, for example, this is set to @c YES, and the preferred content size height is
100 and the screen has a bottom safe area inset of 10, the total height of the displayed bottom
sheet height would be 110. If set to @c NO, the height would be 100.
Defaults to @c YES.
*/
@property(nonatomic, assign) BOOL adjustHeightForSafeAreaInsets;

/**
Bottom sheet controllers must be created with @c initWithContentViewController:.
*/
Expand Down
13 changes: 13 additions & 0 deletions components/BottomSheet/src/MDCBottomSheetController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
#import "MDCBottomSheetPresentationController.h"
#import "MDCBottomSheetPresentationControllerDelegate.h"
#import "MDCBottomSheetTransitionController.h"
#import "MDCSheetState.h"
#import "UIViewController+MaterialBottomSheet.h"
#import "MaterialElevation.h"
#import "MaterialShadowElevations.h"
#import "MaterialShapes.h"
#import "MaterialMath.h"

static const CGFloat kElevationSpreadMaskAffordance = 50.0f;
Expand Down Expand Up @@ -48,6 +52,7 @@ - (nonnull instancetype)initWithContentViewController:
_transitionController = [[MDCBottomSheetTransitionController alloc] init];
_transitionController.dismissOnBackgroundTap = YES;
_transitionController.dismissOnDraggingDownSheet = YES;
_transitionController.adjustHeightForSafeAreaInsets = YES;
super.transitioningDelegate = _transitionController;
super.modalPresentationStyle = UIModalPresentationCustom;
_shapeGenerators = [NSMutableDictionary dictionary];
Expand Down Expand Up @@ -269,6 +274,14 @@ - (UIColor *)scrimColor {
return _transitionController.scrimColor;
}

- (void)setAdjustHeightForSafeAreaInsets:(BOOL)adjustHeightForSafeAreaInsets {
_transitionController.adjustHeightForSafeAreaInsets = adjustHeightForSafeAreaInsets;
}

- (BOOL)adjustHeightForSafeAreaInsets {
return _transitionController.adjustHeightForSafeAreaInsets;
}

- (void)setIsScrimAccessibilityElement:(BOOL)isScrimAccessibilityElement {
_transitionController.isScrimAccessibilityElement = isScrimAccessibilityElement;
}
Expand Down
20 changes: 20 additions & 0 deletions components/BottomSheet/src/MDCBottomSheetPresentationController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
*/
@property(nonatomic, weak, nullable) UIScrollView *trackingScrollView;

/**
When @c trackingScrollView is @c nil and this property is @ YES, the bottom sheet simulates the @c
UIScrollView bouncing effect. When @c trackingScrollView is @c nil and this property is set to @c
NO, the simulated bouncing effect is turned off. When @c trackingScrollView is NOT @c nil, this
property doesn't do anything.
Defaults to @c YES.
*/
@property(nonatomic, assign) BOOL simulateScrollViewBounce;

/**
When set to false, the bottom sheet controller can't be dismissed by tapping outside of sheet area.
*/
Expand Down Expand Up @@ -68,6 +78,16 @@
*/
@property(nonatomic, assign) CGFloat preferredSheetHeight;

/**
Whether or not the height of the bottom sheet should adjust to include extra height for any bottom
safe area insets. If, for example, this is set to @c YES, and the preferredSheetHeight is
100 and the screen has a bottom safe area inset of 10, the total height of the displayed bottom
sheet height would be 110. If set to @c NO, the height would be 100.
Defaults to @c YES.
*/
@property(nonatomic, assign) BOOL adjustHeightForSafeAreaInsets;

/**
Customize the color of the background scrim.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ @implementation MDCBottomSheetPresentationController {

@synthesize delegate;

- (instancetype)initWithPresentedViewController:(UIViewController *)presentedViewController
presentingViewController:(UIViewController *)presentingViewController {
self = [super initWithPresentedViewController:presentedViewController
presentingViewController:presentingViewController];
if (self) {
_adjustHeightForSafeAreaInsets = YES;
_simulateScrollViewBounce = YES;
}
return self;
}

- (UIView *)presentedView {
return self.sheetView;
}
Expand Down Expand Up @@ -122,10 +133,12 @@ - (void)presentationTransitionWillBegin {
}
self.sheetView = [[MDCSheetContainerView alloc] initWithFrame:sheetFrame
contentView:self.presentedViewController.view
scrollView:scrollView];
scrollView:scrollView
simulateScrollViewBounce:self.simulateScrollViewBounce];
self.sheetView.delegate = self;
self.sheetView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
self.sheetView.dismissOnDraggingDownSheet = self.dismissOnDraggingDownSheet;
self.sheetView.adjustHeightForSafeAreaInsets = self.adjustHeightForSafeAreaInsets;

[containerView addSubview:_dimmingView];
[containerView addSubview:self.sheetView];
Expand Down Expand Up @@ -301,6 +314,13 @@ - (void)setPreferredSheetHeight:(CGFloat)preferredSheetHeight {
[self updatePreferredSheetHeight];
}

- (void)setAdjustHeightForSafeAreaInsets:(BOOL)adjustHeightForSafeAreaInsets {
_adjustHeightForSafeAreaInsets = adjustHeightForSafeAreaInsets;
if (_sheetView) {
_sheetView.adjustHeightForSafeAreaInsets = adjustHeightForSafeAreaInsets;
}
}

- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];

Expand Down
10 changes: 10 additions & 0 deletions components/BottomSheet/src/MDCBottomSheetTransitionController.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
*/
@property(nonatomic, assign) CGFloat preferredSheetHeight;

/**
Whether or not the height of the bottom sheet should adjust to include extra height for any bottom
safe area insets. If, for example, this is set to @c YES, and the preferred content size height is
100 and the screen has a bottom safe area inset of 10, the total height of the displayed bottom
sheet height would be 110. If set to @c NO, the height would be 100.
Defaults to @c YES.
*/
@property(nonatomic, assign) BOOL adjustHeightForSafeAreaInsets;

@end

@interface MDCBottomSheetTransitionController (ScrimAccessibility)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ - (instancetype)init {
self = [super init];
if (self) {
_scrimAccessibilityTraits = UIAccessibilityTraitButton;
_adjustHeightForSafeAreaInsets = YES;
}
return self;
}
Expand All @@ -62,6 +63,7 @@ - (instancetype)init {
presentationController.scrimAccessibilityHint = _scrimAccessibilityHint;
presentationController.scrimAccessibilityLabel = _scrimAccessibilityLabel;
presentationController.preferredSheetHeight = _preferredSheetHeight;
presentationController.adjustHeightForSafeAreaInsets = _adjustHeightForSafeAreaInsets;
_currentPresentationController = presentationController;
return presentationController;
}
Expand Down Expand Up @@ -170,6 +172,11 @@ - (UIColor *)scrimColor {
return _scrimColor;
}

- (void)setAdjustHeightForSafeAreaInsets:(BOOL)adjustHeightForSafeAreaInsets {
_adjustHeightForSafeAreaInsets = adjustHeightForSafeAreaInsets;
_currentPresentationController.adjustHeightForSafeAreaInsets = adjustHeightForSafeAreaInsets;
}

- (void)setIsScrimAccessibilityElement:(BOOL)isScrimAccessibilityElement {
_isScrimAccessibilityElement = isScrimAccessibilityElement;
_currentPresentationController.isScrimAccessibilityElement = isScrimAccessibilityElement;
Expand Down
7 changes: 7 additions & 0 deletions components/BottomSheet/src/private/MDCDraggableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
*/
@property(nonatomic, strong, readonly, nullable) UIScrollView *scrollView;

/**
When @c scrollView is @c nil , the draggable view simulates the @c UIScrollView bouncing effect.
When this property is set to @c NO, the simulated bouncing effect is turned off. When @c
scrollView is not @c nil, this property doesn't do anything.
*/
@property(nonatomic, assign) BOOL simulateScrollViewBounce;

/**
* Delegate for handling drag events.
*/
Expand Down
43 changes: 27 additions & 16 deletions components/BottomSheet/src/private/MDCDraggableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "MDCDraggableView.h"

#import "MDCDraggableViewDelegate.h"
#import "MDCKeyboardWatcher.h"

static void CancelGestureRecognizer(UIGestureRecognizer *gesture) {
if (gesture.enabled) {
Expand All @@ -28,6 +29,7 @@ static void CancelGestureRecognizer(UIGestureRecognizer *gesture) {
@interface MDCDraggableView () <UIGestureRecognizerDelegate>
@property(nonatomic) UIPanGestureRecognizer *dragRecognizer;
@property(nonatomic, strong) UIScrollView *scrollView;
@property(nonatomic, assign) CGFloat mostRecentMinY;
@end

@implementation MDCDraggableView
Expand All @@ -50,30 +52,39 @@ - (instancetype)initWithFrame:(CGRect)frame scrollView:(UIScrollView *)scrollVie
#pragma mark - Gesture handling

- (void)didPan:(UIPanGestureRecognizer *)recognizer {
CGPoint point = [recognizer translationInView:self.superview];

// Ensure that dragging the sheet past the maximum height results in an exponential decay on the
// translation. This gives the same effect as when you overscroll a scrollview.
CGFloat newHeight = CGRectGetMaxY(self.superview.bounds) - CGRectGetMinY(self.frame);
if (newHeight > [self.delegate maximumHeightForDraggableView:self]) {
point.y -= point.y / (CGFloat)1.2;
if (recognizer.state == UIGestureRecognizerStateBegan) {
self.mostRecentMinY = CGRectGetMinY(self.frame);
[self.delegate draggableViewBeganDragging:self];
return;
}

self.center = CGPointMake(self.center.x, self.center.y + point.y);
[recognizer setTranslation:CGPointZero inView:self.superview];

CGPoint velocity = [recognizer velocityInView:self.superview];
velocity.x = 0;
CGPoint translation = [recognizer translationInView:self.superview];
CGFloat maxHeight = [self.delegate maximumHeightForDraggableView:self];
CGFloat minimumStableMinY = CGRectGetHeight(self.superview.bounds) - maxHeight -
[MDCKeyboardWatcher sharedKeyboardWatcher].visibleKeyboardHeight;
CGFloat newMinY = self.mostRecentMinY + translation.y;

if (newMinY < minimumStableMinY) {
if ((self.scrollView == nil) && !self.simulateScrollViewBounce) {
velocity = CGPointZero;
newMinY = minimumStableMinY;
} else {
// Ensure that dragging the sheet past the maximum height results in an exponential decay on
// the translation. This gives the same effect as when you overscroll a scrollview.
newMinY = minimumStableMinY + (translation.y - (translation.y / 1.2f));
}
}
CGRect newFrame = CGRectMake(CGRectGetMinX(self.frame), newMinY, CGRectGetWidth(self.frame),
CGRectGetHeight(self.frame));

if (recognizer.state == UIGestureRecognizerStateBegan) {
[self.delegate draggableViewBeganDragging:self];
if (recognizer.state == UIGestureRecognizerStateChanged) {
self.frame = newFrame;
[self.delegate draggableView:self didPanToOffset:CGRectGetMinY(self.frame)];
} else if (recognizer.state == UIGestureRecognizerStateEnded) {
[self.delegate draggableView:self draggingEndedWithVelocity:velocity];
}
if (recognizer.state == UIGestureRecognizerStateBegan ||
recognizer.state == UIGestureRecognizerStateChanged) {
[self.delegate draggableView:self didPanToOffset:CGRectGetMinY(self.frame)];
}
}

#pragma mark - UIGestureRecognizerDelegate
Expand Down
Loading

0 comments on commit 672a406

Please sign in to comment.