message: [Cards] Implement stroke variant themer

diff:
@@ -264,6 +264,13 @@ Pod::Spec.new do |mdc|
extension.dependency "MaterialComponents/Cards"
extension.dependency "MaterialComponents/schemes/Color"
end
+ component.subspec "CardThemer" do |extension|
+ extension.ios.deployment_target = '8.0'
+ extension.public_header_files = "components/Cards/src/#{extension.base_name}/*.h"
+ extension.source_files = "components/Cards/src/#{extension.base_name}/*.{h,m}", "components/Slider/src/#{extension.base_name}/private/*.{h,m}"
+ extension.dependency "MaterialComponents/Cards"
+ extension.dependency "MaterialComponents/Cards+Extensions/ColorThemer"
+ end
end
mdc.subspec "Chips" do |component|

old_path: components/Cards/BUILD

new_path: components/Cards/BUILD

diff:
@@ -37,6 +37,18 @@ mdc_public_objc_library(
],
)
+mdc_objc_library(
+ name = "CardThemer",
+ srcs = native.glob(["src/CardThemer/*.m"]),
+ hdrs = native.glob(["src/CardThemer/*.h"]),
+ includes = ["src/CardThemer"],
+ deps = [
+ ":Cards",
+ ":ColorThemer",
+ ],
+ visibility = ["//visibility:public"],
+)
+
mdc_objc_library(
name = "ColorThemer",
srcs = native.glob(["src/ColorThemer/*.m"]),

diff:
@@ -41,7 +41,9 @@ class CardExampleViewController: UIViewController {
shapeLayer.path = bezierPath.cgPath
imageView.layer.mask = shapeLayer
- MDCCardsColorThemer.applySemanticColorScheme(colorScheme, to: card)
+ let cardScheme = MDCCardScheme();
+ cardScheme.colorScheme = MDCSemanticColorScheme()
+ MDCCardThemer.applyScheme(cardScheme, to: card)
}
override func didReceiveMemoryWarning() {

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MaterialCards.h"
+#import "MaterialColorScheme.h"
+
+#import <Foundation/Foundation.h>
+
+/** Defines a readonly immutable interface for cards style data to be applied by a themer. */
+@protocol MDCCardScheming
+
+/** The color scheme to apply to cards. */
+@property(nonnull, readonly, nonatomic) id <MDCColorScheming> colorScheme;
+
+@end
+
+/** Defines the cards style data that will be applied to a card by a themer. */
+@interface MDCCardScheme : NSObject <MDCCardScheming>
+
+// Redeclare protocol properties as readwrite
+@property(nonnull, readwrite, nonatomic) MDCSemanticColorScheme *colorScheme;
+
+@end
+

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MDCCardScheme.h"
+
+@implementation MDCCardScheme
+
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ _colorScheme = [[MDCSemanticColorScheme alloc] init];
+ }
+ return self;
+}
+@end
+

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MDCCardScheme.h"
+
+#import "MaterialCards.h"
+
+#import <Foundation/Foundation.h>
+
+/** Applies material style to MDCCard objects. */
+@interface MDCCardThemer : NSObject
+
+/**
+ Applies the material card style using the card scheme data.
+
+ @param scheme The card style data that should be used to change the @c card.
+ @param card A MDCCard instance to apply the @c scheme
+ */
++ (void)applyScheme:(nonnull id<MDCCardScheming>)scheme
+ toCard:(nonnull MDCCard *)card;
+
+/**
+ Applies the material card style using the card scheme data.
+
+ @param scheme The card style data that should be used to change the @c card.
+ @param cardCell A MDCCardCollectionCell instance to apply the @c scheme
+ */
++ (void)applyScheme:(nonnull id<MDCCardScheming>)scheme
+ toCardCell:(nonnull MDCCardCollectionCell *)cardCell;
+
+/**
+ Applies the material outlined card style using the card scheme data.
+
+ @param scheme The card style data that should be used to change the @c card.
+ @param card A MDCCard instance to apply the @c scheme
+ */
++ (void)applyOutlinedVariantWithScheme:(nonnull id<MDCCardScheming>)scheme
+ toCard:(nonnull MDCCard *)card;
+
+/**
+ Applies the material outlined card style using the card scheme data.
+
+ @param scheme The card style data that should be used to change the @c card.
+ @param cardCell A MDCCardCollectionCell instance to apply the @c scheme
+ */
++ (void)applyOutlinedVariantWithScheme:(nonnull id<MDCCardScheming>)scheme
+ toCardCell:(nonnull MDCCardCollectionCell *)cardCell;
+
+@end
+

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MDCCardThemer.h"
+
+#import "MaterialCards+ColorThemer.h"
+
+static const MDCShadowElevation kElevation = 0.f;
+static const MDCShadowElevation kSelectedElevation = 4.f;
+static const MDCShadowElevation kHighlightedElevation = 8.f;
+static const CGFloat kBorderWidth = 1.f;
+
+@implementation MDCCardThemer
+
++ (void)applyScheme:(nonnull id<MDCCardScheming>)scheme
+ toCard:(nonnull MDCCard *)card {
+ [MDCCardsColorThemer applySemanticColorScheme:scheme.colorScheme toCard:card];
+}
+
++ (void)applyScheme:(nonnull id<MDCCardScheming>)scheme
+ toCardCell:(nonnull MDCCardCollectionCell *)cardCell {
+ [MDCCardsColorThemer applySemanticColorScheme:scheme.colorScheme toCardCell:cardCell];
+}
+
++ (void)applyOutlinedVariantWithScheme:(nonnull id<MDCCardScheming>)scheme
+ toCard:(nonnull MDCCard *)card {
+ NSUInteger maximumStateValue =
+ UIControlStateNormal | UIControlStateSelected | UIControlStateHighlighted |
+ UIControlStateDisabled;
+ for (NSUInteger state = 0; state <= maximumStateValue; ++state) {
+ [card setShadowElevation:kElevation forState:state];
+ [card setBorderWidth:kBorderWidth forState:state];
+ }
+ [card setShadowElevation:kHighlightedElevation forState:UIControlStateHighlighted];
+ [MDCCardsColorThemer applyOutlinedVariantWithColorScheme:scheme.colorScheme toCard:card];
+}
+
++ (void)applyOutlinedVariantWithScheme:(nonnull id<MDCCardScheming>)scheme
+ toCardCell:(nonnull MDCCardCollectionCell *)cardCell {
+ [cardCell setShadowElevation:kElevation forState:MDCCardCellStateNormal];
+ [cardCell setShadowElevation:kSelectedElevation forState:MDCCardCellStateSelected];
+ [cardCell setShadowElevation:kHighlightedElevation forState:MDCCardCellStateHighlighted];
+ [cardCell setBorderWidth:kBorderWidth forState:MDCCardCellStateNormal];
+ [cardCell setBorderWidth:kBorderWidth forState:MDCCardCellStateSelected];
+ [cardCell setBorderWidth:kBorderWidth forState:MDCCardCellStateHighlighted];
+ [MDCCardsColorThemer applyOutlinedVariantWithColorScheme:scheme.colorScheme toCardCell:cardCell];
+}
+
+@end
+

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MDCCardScheme.h"
+#import "MDCCardThemer.h"
+
+

diff:
#import "MDCCardsColorThemer.h"
+static const CGFloat kStrokeVariantBorderOpacity = 0.37f;
+
@implementation MDCCardsColorThemer
+ (void)applySemanticColorScheme:(nonnull id<MDCColorScheming>)colorScheme
cardCell.backgroundColor = colorScheme.surfaceColor;
}
++ (void)applyOutlinedVariantWithColorScheme:(nonnull id<MDCColorScheming>)colorScheme
+ toCard:(nonnull MDCCard *)card {
+ NSUInteger maximumStateValue =
+ UIControlStateNormal | UIControlStateSelected | UIControlStateHighlighted |
+ UIControlStateDisabled;
+ for (NSUInteger state = 0; state <= maximumStateValue; ++state) {
+ [card setBorderColor:nil forState:state];
+ }
+
+ card.backgroundColor = colorScheme.surfaceColor;
+ UIColor *borderColor =
+ [colorScheme.onSurfaceColor colorWithAlphaComponent:kStrokeVariantBorderOpacity];
+ [card setBorderColor:borderColor forState:UIControlStateNormal];
+}
+
++ (void)applyOutlinedVariantWithColorScheme:(id<MDCColorScheming>)colorScheme
+ toCardCell:(MDCCardCollectionCell *)cardCell {
+ NSUInteger maximumStateValue =
+ UIControlStateNormal | UIControlStateSelected | UIControlStateHighlighted |
+ UIControlStateDisabled;
+ for (NSUInteger state = 0; state <= maximumStateValue; ++state) {
+ [cardCell setBorderColor:nil forState:state];
+ }
+
+ cardCell.backgroundColor = colorScheme.surfaceColor;
+ UIColor *borderColor =
+ [colorScheme.onSurfaceColor colorWithAlphaComponent:kStrokeVariantBorderOpacity];
+ [cardCell setBorderColor:borderColor forState:MDCCardCellStateNormal];
+}
+
@end

original_message: [Cards] Implement stroke variant themer (#3485)


change_type: MODIFY

diff:
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
[_appBar.headerViewController updateTopLayoutGuide];
+ self.contentViewController.view.frame = self.view.bounds;
}
- (BOOL)prefersStatusBarHidden {

license: Apache License 2.0

original_message: Make MDCAppBarContainerViewController set bounds of child view controller (#3450)


message:
Update TextField Themer Section README.md
* Update TextField Themer Section README.md
* Update README.md
minor fixes
* Update README.md
minor fixes

diff:
@@ -142,6 +142,91 @@ import MaterialComponents.MaterialTextFields
```
<!--</div>-->
+### Theming
+
+You can theme textFields components with your app's color scheme and typography scheme using the ColorThemer and TypographyThemer extensions.
+
+You must first add the Themer extensions to your project:
+
+``` bash
+pod 'MaterialComponents/TextFields+Extensions/ColorThemer'
+pod 'MaterialComponents/TextFields+Extensions/TypographyThemer'
+```
+
+You can then import the theming APIs:
+
+<!--<div class="material-code-render" markdown="1">-->
+#### Swift
+``` swift
+import MaterialComponents.MaterialTextFields_ColorThemer
+import MaterialComponents.MaterialTextFields_FontThemer
+```
+
+#### Objective-C
+
+``` objc
+#import "MaterialTextFields+ColorThemer.h"
+#import "MaterialTextFields+TypographyThemer.h"
+```
+<!--</div>-->
+
+MDCTextFieldColorThemer allows you to theme an MDCTextInput or an MDCInputController with your app's color scheme.
+
+MDCTextFieldTypographyThemer allows you to theme an MDCTextInput or an MDCInputController with your app's typography scheme.
+
+<!--<div class="material-code-render" markdown="1">-->
+#### Swift
+``` swift
+let colorScheme = MDCSemanticColorScheme()
+let typographyScheme = MDCTypographyScheme()
+
+// Applying theme to a text input
+let textField = MDCTextField()
+MDCTextFieldColorThemer.apply(colorScheme, to: textField)
+MDCTextFieldTypographyThemer.apply(typographyScheme, to: textField)
+
+// Applying theme to an input controller
+let textField = MDCTextField()
+let inputController = MDCTextInputControllerUnderline(textInput: inputController)
+MDCTextFieldColorThemer.apply(colorScheme, to: inputController)
+MDCTextFieldTypographyThemer.apply(typographyScheme, to: inputController)
+
+// Applying theme to an specific class type of inputController
+MDCTextFieldColorThemer.apply(colorScheme,
+ toAllControllersOfClass: MDCTextInputControllerUnderline.self)
+MDCTextFieldTypographyThemer.apply(typographyScheme,
+ toAllControllersOfClass: MDCTextInputControllerUnderline.self)
+
+```
+
+#### Objective-C
+
+``` objc
+id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
+id<MDCTypographyScheming> typographyScheme = [[MDCTypographyScheme alloc] init];
+
+// Applying theme to a text input
+id<MDCTextInput> textField = [[MDCTextField alloc] init];
+[MDCTextFieldColorThemer applySemanticColorScheme:colorScheme toTextInput:textField];
+[MDCTextFieldTypographyThemer applyTypographyScheme:typographyScheme toTextInput:textField];
+
+// Applying theme to an input controller
+id<MDCTextInput> textField = [[MDCTextField alloc] init];
+MDCTextInputControllerUnderline *inputController =
+ [[MDCTextInputControllerUnderline alloc] initWithTextInput:textField];
+[MDCTextFieldColorThemer applySemanticColorScheme:colorScheme toTextInputController:inputController];
+[MDCTextFieldTypographyThemer applyTypographyScheme:typographyScheme
+ toTextInputController:inputController];
+
+// Applying theme to an specific class type of inputController
+[MDCTextFieldColorThemer applySemanticColorScheme:colorScheme
+ toAllTextInputControllersOfClass:[MDCTextInputControllerUnderline class]];
+[MDCTextFieldTypographyThemer applyTypographyScheme:typographyScheme
+ toAllTextInputControllersOfClass:[MDCTextInputControllerUnderline class]];
+
+```
+<!--</div>-->
+
## Examples - Single-line
### Text Field with Floating Placeholder

original_message:
Update TextField Themer Section README.md (#3523)

* Update TextField Themer Section README.md

* Update README.md

minor fixes

* Update README.md

minor fixes

https://github.com/material-components/material-components-ios/pull/3523


message:
[Tabs] Update Tabs Theme Section README.md
* Update Tabs Theme Section README.md
* Update README.md
minor changes.
* Update README.md
minor fixes.

diff:
@@ -116,6 +116,76 @@ navigation bar. The bar will automatically update with the appropriate styling.
- - -
+### Theming
+
+You can theme a TabBar with your app's color scheme and typography scheme using the ColorThemer and TypographyThemer extensions.
+
+You must first add the Themer extensions to your project:
+
+``` bash
+pod 'MaterialComponents/Tabs+Extensions/ColorThemer'
+pod 'MaterialComponents/Tabs+Extensions/TypographyThemer'
+```
+
+You can then import the theming APIs:
+
+
+#### Swift
+``` swift
+import MaterialComponents.MaterialTabs_ColorThemer
+import MaterialComponents.MaterialTabs_TypographyThemer
+```
+
+#### Objective-C
+
+``` objc
+#import "MaterialTabs+ColorThemer.h"
+#import "MaterialTabs+TypographyThemer.h"
+```
+
+
+MDCTabBarColorThemer allows you to theme a tab bar with your app's color scheme.
+
+MDCTabBarTypographyThemer allows you to theme a tab bar with your app's typography scheme.
+
+
+#### Swift
+``` swift
+let colorScheme = MDCSemanticColorScheme()
+let typographyScheme = MDCTypographyScheme()
+
+let tabBar = MDCTabBar()
+
+// Apply regular style
+MDCTabBarColorThemer.apply(colorScheme, toTabs: tabBar)
+
+// Or Surface Variant
+MDCTabBarColorThemer.applySurfaceVariant(withColorScheme: colorScheme, toTabs: tabBar)
+
+
+MDCTabBarTypographyThemer.apply(typographyScheme, to: tabBar)
+```
+
+#### Objective-C
+
+``` objc
+id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
+id<MDCTypographyScheming> typographyScheme = [[MDCTypographyScheme alloc] init];
+
+MDCTabBar *tabBar = [[MDCTabBar alloc] init];
+
+// Apply regular style
+[MDCTabBarColorThemer applySemanticColorScheme:colorScheme toTabs:tabBar];
+
+// Or Surface Variant
+[MDCTabBarColorThemer applySurfaceVariantWithColorScheme:colorScheme toTabs:tabBar];
+
+// Apply typography scheme.
+[MDCTabBarTypographyThemer applyTypographyScheme:typographyScheme toTabBar:tabBar];
+
+```
+
+
## Example
### Creating a tab bar

original_message:
[Tabs] Update Tabs Theme Section README.md (#3527)

* Update Tabs Theme Section README.md

* Update README.md

minor changes.

* Update README.md

minor fixes.

https://github.com/material-components/material-components-ios/pull/3527


message:
[Tabs] update README.md Mistake
applySemanticColorScheme

diff:
@@ -157,7 +157,7 @@ let typographyScheme = MDCTypographyScheme()
let tabBar = MDCTabBar()
// Apply regular style
-MDCTabBarColorThemer.apply(colorScheme, toTabs: tabBar)
+MDCTabBarColorThemer.applySemanticColorScheme(colorScheme, toTabs: tabBar)
// Or Surface Variant
MDCTabBarColorThemer.applySurfaceVariant(withColorScheme: colorScheme, toTabs: tabBar)


message:
Textfield Readme.md mistake.
applySemanticColorScheme

diff:
@@ -188,11 +188,11 @@ MDCTextFieldTypographyThemer.apply(typographyScheme, to: textField)
// Applying theme to an input controller
let textField = MDCTextField()
let inputController = MDCTextInputControllerUnderline(textInput: inputController)
-MDCTextFieldColorThemer.apply(colorScheme, to: inputController)
+MDCTextFieldColorThemer.applySemanticColorScheme(colorScheme, to: inputController)
MDCTextFieldTypographyThemer.apply(typographyScheme, to: inputController)
// Applying theme to an specific class type of inputController
-MDCTextFieldColorThemer.apply(colorScheme,
+MDCTextFieldColorThemer.applySemanticColorScheme(colorScheme,
toAllControllersOfClass: MDCTextInputControllerUnderline.self)
MDCTextFieldTypographyThemer.apply(typographyScheme,
toAllControllersOfClass: MDCTextInputControllerUnderline.self)


message:
[AppBar] Add Theming Section to README.md
* Update README.md
Added Theming Documentation to AppBar.
* Update README.md
* Update README.md
Made some minor changes.
* Update README.md
minor fix
* Update README.md
applySemanticColorScheme

diff:
@@ -249,3 +249,59 @@ recommendation for building interactive background views is the following:
[Usage](../FlexibleHeader/#usage) docs.
3. Add your views to this flexible header instance.
4. Create a Navigation Bar if you need one. Treat it like any other custom view.
+
+### Theming
+
+You can theme an AppBar with your app's color scheme and typography scheme using the ColorThemer and TypographyThemer extensions.
+
+You must first add the Themer extensions to your project:
+
+``` bash
+pod 'MaterialComponents/AppBar+Extensions/ColorThemer'
+pod 'MaterialComponents/AppBar+Extensions/TypographyThemer'
+```
+
+You can then import the theming APIs:
+
+
+#### Swift
+``` swift
+import MaterialComponents.MaterialAppBar_ColorThemer
+import MaterialComponents.MaterialAppBar_TypographyThemer
+```
+
+#### Objective-C
+
+``` objc
+#import "MaterialAppBar+ColorThemer.h"
+#import "MaterialAppBar+TypographyThemer.h"
+```
+
+
+MDCAppBarColorThemer allows you to theme an app bar with your app's color scheme.
+
+MDCAppBarTypographyThemer allows you to theme an app bar with your app's typography scheme.
+
+
+#### Swift
+``` swift
+let colorScheme = MDCSemanticColorScheme()
+let typographyScheme = MDCTypographyScheme()
+
+let appBar = MDCAppBar()
+MDCAppBarColorThemer.applySemanticColorScheme(colorScheme, to: appBar)
+MDCAppBarTypographyThemer.apply(typographyScheme, to: appBar)
+```
+
+#### Objective-C
+
+``` objc
+id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
+id<MDCTypographyScheming> typographyScheme = [[MDCTypographyScheme alloc] init];
+
+MDCAppBar *appBar = [[MDCAppBar alloc] init];
+[MDCAppBarColorThemer applySemanticColorScheme:colorScheme toAppBar:appBar];
+[MDCAppBarTypographyThemer applyTypographyScheme:typographyScheme toAppBar:appBar];
+
+```
+

original_message:
[AppBar] Add Theming Section to README.md (#3516)

* Update README.md

Added Theming Documentation to AppBar.

* Update README.md

* Update README.md

Made some minor changes.

* Update README.md

minor fix

* Update README.md

applySemanticColorScheme

https://github.com/material-components/material-components-ios/pull/3516


message: Fix typo in MaterialComponents.podspec

diff:
@@ -267,7 +267,7 @@ Pod::Spec.new do |mdc|
component.subspec "CardThemer" do |extension|
extension.ios.deployment_target = '8.0'
extension.public_header_files = "components/Cards/src/#{extension.base_name}/*.h"
- extension.source_files = "components/Cards/src/#{extension.base_name}/*.{h,m}", "components/Slider/src/#{extension.base_name}/private/*.{h,m}"
+ extension.source_files = "components/Cards/src/#{extension.base_name}/*.{h,m}"
extension.dependency "MaterialComponents/Cards"
extension.dependency "MaterialComponents/Cards+Extensions/ColorThemer"
end

original_message: Fix typo in MaterialComponents.podspec (#3529)


diff:
@@ -111,6 +111,52 @@ func didChangeSliderValue(senderSlider:MDCSlider) {
```
<!--</div>-->
+### Theming
+
+You can theme a Slider with your app's color scheme using the ColorThemer extension.
+
+You must first add the color themer extension to your project:
+
+``` bash
+pod 'MaterialComponents/Slider+Extensions/ColorThemer'
+```
+
+You can then import the theming APIs:
+
+<!--<div class="material-code-render" markdown="1">-->
+#### Swift
+``` swift
+import MaterialComponents.MaterialSlider_ColorThemer
+```
+
+#### Objective-C
+
+``` objc
+#import "MaterialSlider+ColorThemer.h"
+```
+<!--</div>-->
+
+MDCSliderColorThemer allows you to theme an slider with your app's color scheme.
+
+<!--<div class="material-code-render" markdown="1">-->
+#### Swift
+``` swift
+let colorScheme = MDCSemanticColorScheme()
+
+let slider = MDCSlider()
+MDCSliderColorThemer.applySemanticColorScheme(colorScheme, to: slider)
+```
+
+#### Objective-C
+
+``` objc
+id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
+
+MDCSlider *slider = [[MDCSlider alloc] init];
+[MDCSliderColorThemer applySemanticColorScheme:colorScheme toSlider:slider];
+
+```
+<!--</div>-->
### The differences between the UISlider class and the MDCSlider class:
Does not have api to:

original_message: [Slider] Added Theming Section to README (#3530)


message:
[Slider] Stateful API Section Added.
Pivotal:

diff:
@@ -117,6 +117,32 @@ func didChangeSliderValue(senderSlider:MDCSlider) {
```
<!--</div>-->
+### Stateful API
+
+`MDCSlider` exposes stateful APIs to customize the colors for different control states. In order to use this API you must enable `statefulAPIEnabled` on your `MDCSlider` instances.
+
+<!--<div class="material-code-render" markdown="1">-->
+#### Swift
+
+``` swift
+ let slider = MDCSlider()
+ slider.isStatefulAPIEnabled = true
+
+ // Setting a thumb color for selected state.
+ slider.setThumbColor(.red, for: .selected)
+```
+
+#### Objective C
+
+``` objc
+ MDCSlider *slider = [[MDCSlider alloc] init];
+ slider.statefulAPIEnabled = YES;
+
+ // Setting a thumb color for selected state.
+ [slider setThumbColor:[UIColor redColor] forState:UIControlStateSelected];
+```
+<!--</div>-->
+
### The differences between the UISlider class and the MDCSlider class:
Does not have api to:

original_message:
[Slider] Stateful API Section Added. (#3565)

Pivotal: https://www.pivotaltracker.com/story/show/156898304


message:
Create a ChipThemer for material and outlined schemes
Before:
![simulator screen shot - iphone x - 2018-04-27 at 13 43 06](https://user-images.githubusercontent.com/1418389/39376826-0283c50a-4a21-11e8-921f-1d18ac2e8c38.png)
After:
![simulator screen shot - iphone x - 2018-04-27 at 13 42 03](https://user-images.githubusercontent.com/1418389/39376832-050ea088-4a21-11e8-8c93-29ba62114249.png)

diff:
@@ -313,6 +313,15 @@ Pod::Spec.new do |mdc|
extension.dependency "MaterialComponents/Chips"
extension.dependency "MaterialComponents/schemes/Typography"
end
+ component.subspec "ChipThemer" do |extension|
+ extension.ios.deployment_target = '8.0'
+ extension.public_header_files = "components/Chips/src/#{extension.base_name}/*.h"
+ extension.source_files = "components/Chips/src/#{extension.base_name}/*.{h,m}"
+
+ extension.dependency "MaterialComponents/Chips"
+ extension.dependency "MaterialComponents/Chips+Extensions/ColorThemer"
+ extension.dependency "MaterialComponents/Chips+Extensions/TypographyThemer"
+ end
end
mdc.subspec "CollectionCells" do |component|

old_path: components/Chips/BUILD

new_path: components/Chips/BUILD

diff:
@@ -39,6 +39,19 @@ mdc_public_objc_library(
],
)
+mdc_objc_library(
+ name = "ChipThemer",
+ srcs = native.glob(["src/ChipThemer/*.m"]),
+ hdrs = native.glob(["src/ChipThemer/*.h"]),
+ includes = ["src/ChipThemer"],
+ deps = [
+ ":Chips",
+ ":ColorThemer",
+ ":TypographyThemer",
+ ],
+ visibility = ["//visibility:public"],
+)
+
mdc_objc_library(
name = "FontThemer",
srcs = native.glob(["src/FontThemer/*.m"]),

diff:
#import "ChipsExamplesSupplemental.h"
#import "MaterialChips.h"
-#import "MaterialChips+ColorThemer.h"
+#import "MaterialChips+ChipThemer.h"
@implementation ChipsActionExampleViewController {
UICollectionView *_collectionView;
// Customize Chip
chipView.titleLabel.text = self.titles[indexPath.row];
+ MDCChipViewScheme *scheme = [[MDCChipViewScheme alloc] init];
+ scheme.colorScheme = self.colorScheme;
+
// Apply Theming
if (_isStroked) {
- [chipView setBorderWidth:1 forState:UIControlStateNormal];
- [MDCChipViewColorThemer applySemanticColorScheme:self.colorScheme toStrokedChipView:chipView];
+ [MDCChipViewThemer applyOutlinedVariantWithScheme:scheme toChipView:chipView];
} else {
- [chipView setBorderWidth:0 forState:UIControlStateNormal];
- [MDCChipViewColorThemer applySemanticColorScheme:self.colorScheme toChipView:chipView];
+ [MDCChipViewThemer applyScheme:scheme toChipView:chipView];
}
return cell;

diff:
#import "ChipsExamplesSupplemental.h"
#import "MaterialChips.h"
-#import "MaterialChips+ColorThemer.h"
+#import "MaterialChips+ChipThemer.h"
@implementation ChipsChoiceExampleViewController {
MDCChipView *_sizingChip;
if (indexPath.row == 2) {
[chipView setEnabled:NO];
}
+
+ MDCChipViewScheme *scheme = [[MDCChipViewScheme alloc] init];
+ scheme.colorScheme = self.colorScheme;
+
if (_isStroked) {
- [chipView setBorderWidth:1 forState:UIControlStateNormal];
- [MDCChipViewColorThemer applySemanticColorScheme:_colorScheme toStrokedChipView:chipView];
+ [MDCChipViewThemer applyOutlinedVariantWithScheme:scheme toChipView:chipView];
} else {
- [chipView setBorderWidth:0 forState:UIControlStateNormal];
- [MDCChipViewColorThemer applySemanticColorScheme:_colorScheme toChipView:chipView];
+ [MDCChipViewThemer applyScheme:scheme toChipView:chipView];
}
return cell;

diff:
#import "ChipsExamplesSupplemental.h"
#import "MaterialChips.h"
-#import "MaterialChips+ColorThemer.h"
+#import "MaterialChips+ChipThemer.h"
@implementation ChipsFilterExampleViewController {
UICollectionView *_collectionView;
chipView.selected = [_selectedIndecies containsObject:indexPath];
cell.alwaysAnimateResize = [self shouldAnimateResize];
+ MDCChipViewScheme *scheme = [[MDCChipViewScheme alloc] init];
+ scheme.colorScheme = self.colorScheme;
+
if (_isStroked) {
- [chipView setBorderWidth:1 forState:UIControlStateNormal];
- [MDCChipViewColorThemer applySemanticColorScheme:self.colorScheme toStrokedChipView:chipView];
+ [MDCChipViewThemer applyOutlinedVariantWithScheme:scheme toChipView:chipView];
} else {
- [chipView setBorderWidth:0 forState:UIControlStateNormal];
- [MDCChipViewColorThemer applySemanticColorScheme:self.colorScheme toChipView:chipView];
+ [MDCChipViewThemer applyScheme:scheme toChipView:chipView];
}
return cell;

diff:
#import "MaterialChips.h"
#import "MaterialTextFields.h"
-#import "MaterialChips+ColorThemer.h"
+#import "MaterialChips+ChipThemer.h"
@interface ChipsInputExampleViewController () <MDCChipFieldDelegate>
@end
}
- (void)chipField:(MDCChipField *)chipField didAddChip:(MDCChipView *)chip {
+ MDCChipViewScheme *scheme = [[MDCChipViewScheme alloc] init];
+ scheme.colorScheme = self.colorScheme;
+
// Every other chip is stroked
if (chipField.chips.count%2) {
- [chip setBorderWidth:1 forState:UIControlStateNormal];
- [MDCChipViewColorThemer applySemanticColorScheme:self.colorScheme toStrokedChipView:chip];
+ [MDCChipViewThemer applyOutlinedVariantWithScheme:scheme toChipView:chip];
} else {
- [chip setBorderWidth:0 forState:UIControlStateNormal];
- [MDCChipViewColorThemer applySemanticColorScheme:self.colorScheme toChipView:chip];
+ [MDCChipViewThemer applyScheme:scheme toChipView:chip];
}
[chip sizeToFit];
CGFloat chipVerticalInset = MIN(0, (CGRectGetHeight(chip.bounds) - 48) / 2);

change_type: ADD

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MaterialChips.h"
+#import "MaterialColorScheme.h"
+#import "MaterialTypographyScheme.h"
+
+#import <Foundation/Foundation.h>
+
+/**
+ MDCChipViewScheming represents the design parameters for an MDCChipView.
+
+ An instance of this protocol can be applied to an instance of MDCChipView using any of the
+ MDCChipViewThemer APIs.
+ */
+@protocol MDCChipViewScheming
+
+/**
+ The color scheme to apply to a chip view.
+ */
+@property(nonnull, readonly, nonatomic) id<MDCColorScheming> colorScheme;
+
+/**
+ The typography scheme to apply to a chip view.
+ */
+@property(nonnull, readonly, nonatomic) id<MDCTypographyScheming> typographyScheme;
+
+@end
+
+/**
+ An MDCChipViewScheme is a mutable representation of the design parameters for an MDCChipView.
+ */
+@interface MDCChipViewScheme : NSObject <MDCChipViewScheming>
+
+/**
+ A mutable representation of a color scheme.
+
+ By default, this is initialized with the latest color scheme defaults.
+ */
+@property(nonnull, readwrite, nonatomic) id<MDCColorScheming> colorScheme;
+
+/**
+ A mutable representation of a typography scheme.
+
+ By default, this is initialized with the latest typography scheme defaults.
+ */
+@property(nonnull, readwrite, nonatomic) id<MDCTypographyScheming> typographyScheme;
+
+@end

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MDCChipViewScheme.h"
+
+@implementation MDCChipViewScheme
+
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ _colorScheme = [[MDCSemanticColorScheme alloc] init];
+ _typographyScheme = [[MDCTypographyScheme alloc] init];
+ }
+ return self;
+}
+@end

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MDCChipViewScheme.h"
+
+#import "MaterialChips.h"
+
+#import <Foundation/Foundation.h>
+
+/**
+ The Material Design themer for instances of MDCChipView.
+ */
+@interface MDCChipViewThemer : NSObject
+
+/**
+ Applies a chip view scheme's properties to an MDCChipView.
+
+ @param scheme The chip view scheme to apply to the component instance.
+ @param chip A component instance to which the scheme should be applied.
+ */
++ (void)applyScheme:(nonnull id<MDCChipViewScheming>)scheme
+ toChipView:(nonnull MDCChipView *)chip;
+
+/**
+ Applies a chip view scheme's properties to an MDCChipView using the outlined style.
+
+ @param scheme The chip view scheme to apply to the component instance.
+ @param chip A component instance to which the scheme should be applied.
+ */
++ (void)applyOutlinedVariantWithScheme:(nonnull id<MDCChipViewScheming>)scheme
+ toChipView:(nonnull MDCChipView *)chip;
+
+@end

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MaterialChips+ChipThemer.h"
+
+#import "MaterialChips+ColorThemer.h"
+#import "MaterialChips+TypographyThemer.h"
+
+@implementation MDCChipViewThemer
+
++ (void)applyScheme:(nonnull id<MDCChipViewScheming>)scheme
+ toChipView:(nonnull MDCChipView *)chip {
+ NSUInteger maximumStateValue =
+ UIControlStateNormal | UIControlStateSelected | UIControlStateHighlighted |
+ UIControlStateDisabled;
+ for (NSUInteger state = 0; state <= maximumStateValue; ++state) {
+ [chip setBorderWidth:0 forState:state];
+ }
+ [MDCChipViewColorThemer applySemanticColorScheme:scheme.colorScheme toChipView:chip];
+ [MDCChipViewTypographyThemer applyTypographyScheme:scheme.typographyScheme toChipView:chip];
+}
+
++ (void)applyOutlinedVariantWithScheme:(nonnull id<MDCChipViewScheming>)scheme
+ toChipView:(nonnull MDCChipView *)chip {
+ NSUInteger maximumStateValue =
+ UIControlStateNormal | UIControlStateSelected | UIControlStateHighlighted |
+ UIControlStateDisabled;
+ for (NSUInteger state = 0; state <= maximumStateValue; ++state) {
+ [chip setBorderWidth:1 forState:state];
+ }
+ [MDCChipViewColorThemer applyOutlinedVariantWithColorScheme:scheme.colorScheme toChipView:chip];
+ [MDCChipViewTypographyThemer applyTypographyScheme:scheme.typographyScheme toChipView:chip];
+}
+
+@end
+
+

diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import "MDCChipViewThemer.h"
+#import "MDCChipViewScheme.h"

diff:
+ (void)applySemanticColorScheme:(nonnull id<MDCColorScheming>)colorScheme
toChipView:(nonnull MDCChipView *)chipView;
+/**
+ Applies a color scheme's properties to the component instance with the outlined style.
+
+ @param colorScheme The color scheme to apply to the component instance.
+ @param chipView @c A component instance to which the color scheme should be applied.
+ */
++ (void)applyOutlinedVariantWithColorScheme:(nonnull id<MDCColorScheming>)colorScheme
+ toChipView:(nonnull MDCChipView *)chipView;
+
+#pragma mark - Soon to be deprecated
+
/**
Applies a color scheme's properties to a stroked MDCChipView.
+ @warning This method will soon be deprecated. Consider using
+ @c +applyOutlinedVariantWithColorScheme:toChipView: instead.
+
@param colorScheme The color scheme to apply to the component instance.
@param strokedChipView A component instance to which the color scheme should be applied.
*/

diff:
forState:UIControlStateDisabled];
}
++ (void)applyOutlinedVariantWithColorScheme:(nonnull id<MDCColorScheming>)colorScheme
+ toChipView:(nonnull MDCChipView *)chipView {
+ [MDCChipViewColorThemer resetUIControlStatesForChipTheming:chipView];
+ UIColor *onSurface12Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:0.12f];
+ UIColor *onSurface87Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:0.87f];
+ UIColor *onSurface16Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:0.16f];
+ UIColor *selectedBackgroundColor =
+ [MDCSemanticColorScheme blendColor:onSurface12Opacity
+ withBackgroundColor:colorScheme.surfaceColor];
+ UIColor *borderColor =
+ [MDCSemanticColorScheme blendColor:onSurface12Opacity
+ withBackgroundColor:colorScheme.surfaceColor];
+ UIColor *textColor =
+ [MDCSemanticColorScheme blendColor:onSurface87Opacity
+ withBackgroundColor:colorScheme.surfaceColor];
+ UIColor *selectedTextColor =
+ [MDCSemanticColorScheme blendColor:onSurface87Opacity
+ withBackgroundColor:selectedBackgroundColor];
+
+ [chipView setInkColor:onSurface16Opacity forState:UIControlStateNormal];
+ [chipView setTitleColor:textColor forState:UIControlStateNormal];
+ [chipView setBackgroundColor:colorScheme.surfaceColor forState:UIControlStateNormal];
+ [chipView setBorderColor:borderColor forState:UIControlStateNormal];
+
+ [chipView setTitleColor:selectedTextColor forState:UIControlStateSelected];
+ [chipView setBackgroundColor:selectedBackgroundColor forState:UIControlStateSelected];
+ [chipView setBorderColor:[UIColor clearColor] forState:UIControlStateSelected];
+
+ [chipView setTitleColor:[textColor colorWithAlphaComponent:0.38f]
+ forState:UIControlStateDisabled];
+ [chipView setBackgroundColor:[colorScheme.surfaceColor colorWithAlphaComponent:0.38f]
+ forState:UIControlStateDisabled];
+ [chipView setBorderColor:[borderColor colorWithAlphaComponent:0.38f]
+ forState:UIControlStateDisabled];
+}
+
+ (void)applySemanticColorScheme:(nonnull id<MDCColorScheming>)colorScheme
toStrokedChipView:(nonnull MDCChipView *)strokedChipView {
[MDCChipViewColorThemer resetUIControlStatesForChipTheming:strokedChipView];

diff:
}
- (void)testStrokedChipViewColorThemer {
- [MDCChipViewColorThemer applySemanticColorScheme:self.colorScheme toStrokedChipView:self.chip];
+ [MDCChipViewColorThemer applyOutlinedVariantWithColorScheme:self.colorScheme
+ toChipView:self.chip];
UIColor *onSurface12Opacity = [self.colorScheme.onSurfaceColor colorWithAlphaComponent:0.12f];
UIColor *onSurface87Opacity = [self.colorScheme.onSurfaceColor colorWithAlphaComponent:0.87f];
UIColor *onSurface16Opacity = [self.colorScheme.onSurfaceColor colorWithAlphaComponent:0.16f];

original_message:
Create a ChipThemer for material and outlined schemes (#3563)

Before:
![simulator screen shot - iphone x - 2018-04-27 at 13 43 06](https://user-images.githubusercontent.com/1418389/39376826-0283c50a-4a21-11e8-921f-1d18ac2e8c38.png)

After:
![simulator screen shot - iphone x - 2018-04-27 at 13 42 03](https://user-images.githubusercontent.com/1418389/39376832-050ea088-4a21-11e8-8c93-29ba62114249.png)


message:
Fix outlined button themer tests
Build fix

diff:
@@ -71,16 +71,16 @@ static const CGFloat kEpsilonAccuracy = 0.001f;
XCTAssertEqualObjects([button backgroundColorForState:UIControlStateNormal],
[UIColor clearColor]);
XCTAssertEqualObjects([button backgroundColorForState:UIControlStateDisabled],
- [UIColor clearColor]);
+ nil);
XCTAssertEqualObjects([button titleColorForState:UIControlStateNormal],
scheme.colorScheme.primaryColor);
XCTAssertEqualWithAccuracy(button.disabledAlpha, 1, kEpsilonAccuracy);
XCTAssertEqualObjects(button.inkColor,
[scheme.colorScheme.primaryColor colorWithAlphaComponent:0.16f]);
XCTAssertEqualObjects([button borderColorForState:UIControlStateNormal],
- MDCPalette.greyPalette.tint300);
+ [scheme.colorScheme.onSurfaceColor colorWithAlphaComponent:0.12f]);
XCTAssertEqualObjects([button borderColorForState:UIControlStateDisabled],
- MDCPalette.greyPalette.tint100);
+ nil);
// Typography
XCTAssertEqualObjects([button titleFontForState:UIControlStateNormal],

original_message:
Fix outlined button themer tests (#3598)

Build fix


diff:
@@ -103,3 +103,21 @@ MDCFloatingActionButtonThemer.applyScheme(buttonScheme, to: button)
[MDCFloatingActionButtonThemer applyScheme:buttonScheme toButton:button];
```
<!--</div>-->
+
+## Outlined buttons
+
+To theme a button as a Material Design outlined button, use `MDCOutlinedButtonThemer`
+with an `MDCButton`.
+
+<!--<div class="material-code-render" markdown="1">-->
+#### Swift
+```swift
+MDCOutlinedButtonThemer.applyScheme(buttonScheme, to: button)
+```
+
+#### Objective-C
+
+```objc
+[MDCOutlinedButtonThemer applyScheme:buttonScheme toButton:button];
+```
+<!--</div>-->

diff:
@@ -116,6 +116,9 @@ An `MDCCard` can be added and used as you would add any `UIView` or `UIControl`,
An `MDCCardCollectionCell` can be added, used, and reused as a `UICollectionViewCell`, if manually in code, or through the interface builder.
+### Style Variants
+MDCCardThemer exposes apis to theme MDCCard and MDCCardCollectionCell instances as either a default or outlined variant. An outlined variant behaves identically to a default styled card, but differs in its coloring and in that it has a stroked border. Use 'applyScheme:toCard:' to style an instance with default values and 'applyOutlinedVariantWithScheme:toCard:' to style an instance with the outlined values.
+
### Importing
Before using Cards, you'll need to import it:

diff:
@@ -261,6 +261,13 @@ the others (`contentPadding`). This is useful so that you can set each of the pa
ensure your chips look correct whether or not they have an image and/or accessory view. The chip
uses these property to determine `intrinsicContentSize` and `sizeThatFits`.
+### Style Variants
+MDCChipViewThemer exposes apis to theme MDCChipView instances as either a default or outlined
+variant. An outlined variant behaves identically to a default styled chipview, but differs in its
+coloring and in that it has a stroked border. Use 'applyScheme:toChipView:' to style an instance
+with default values and 'applyOutlinedVariantWithScheme:toChipView:' to style an instance with
+the outlined values.
+
- - -
## Examples

original_message:
Add documentation describing variants to buttons, chips and cards (#3600)

https://www.pivotaltracker.com/story/show/157164168


message:
Ensure buttons and cards reset their states correctly
Dont reset other states to 0 within MDCOutlinedButtonThemer, because since its an int thats not resetting, its overriding the behavior of defaulting to UIControlStateNormal
Within MDCCardThemer reset elevation and border to 0 in the non outlined variant.

diff:
UIControlStateNormal | UIControlStateSelected | UIControlStateHighlighted |
UIControlStateDisabled;
for (NSUInteger state = 0; state <= maximumStateValue; ++state) {
- [button setBorderWidth:0 forState:state];
+ [button setBorderWidth:1.f forState:state];
}
-
- [button setBorderWidth:1.0f forState:UIControlStateNormal];
}
@end

diff:
@@ -94,7 +94,7 @@ static const CGFloat kEpsilonAccuracy = 0.001f;
kEpsilonAccuracy);
XCTAssertEqualWithAccuracy([button borderWidthForState:UIControlStateNormal], 1,
kEpsilonAccuracy);
- XCTAssertEqualWithAccuracy([button borderWidthForState:UIControlStateHighlighted], 0,
+ XCTAssertEqualWithAccuracy([button borderWidthForState:UIControlStateHighlighted], 1,
kEpsilonAccuracy);
}

diff:
@@ -27,11 +27,24 @@ static const CGFloat kBorderWidth = 1.f;
+ (void)applyScheme:(nonnull id<MDCCardScheming>)scheme
toCard:(nonnull MDCCard *)card {
+ NSUInteger maximumStateValue =
+ UIControlStateNormal | UIControlStateSelected | UIControlStateHighlighted |
+ UIControlStateDisabled;
+ for (NSUInteger state = 0; state <= maximumStateValue; ++state) {
+ [card setBorderWidth:0.f forState:state];
+ [card setShadowElevation:0.f forState:state];
+ }
[MDCCardsColorThemer applySemanticColorScheme:scheme.colorScheme toCard:card];
}
+ (void)applyScheme:(nonnull id<MDCCardScheming>)scheme
toCardCell:(nonnull MDCCardCollectionCell *)cardCell {
+ for (MDCCardCellState state = MDCCardCellStateNormal;
+ state <= MDCCardCellStateSelected;
+ state++) {
+ [cardCell setShadowElevation:0.f forState:state];
+ [cardCell setBorderWidth:0.f forState:state];
+ }
[MDCCardsColorThemer applySemanticColorScheme:scheme.colorScheme toCardCell:cardCell];
}

original_message:
Ensure buttons and cards reset their states correctly (#3599)

Dont reset other states to 0 within MDCOutlinedButtonThemer, because since its an int thats not resetting, its overriding the behavior of defaulting to UIControlStateNormal

Within MDCCardThemer reset elevation and border to 0 in the non outlined variant.


message:
[Tabs] readme update.
* adding tabs docs components.
* auto generated tabs
* fixing color and typography theming docs.
* typography themeing is added.
* tab bar to tab-bar,
image tags added back.
* reverting tab bar -> tab-bar
* regenerating the readme.

diff:
@@ -5,3 +5,4 @@ root_path=/catalog/tabs
icon_id=tabs
color_themer_api=MDCTabBarColorThemer
typography_themer_api=MDCTabBarTypographyThemer
+short_description=Material Design tabs are bars of buttons used to navigate between groups of content.

diff:
title: "Tabs"
layout: detail
section: components
-excerpt: "Tabs make it easy to explore and switch between different views."
+excerpt: "Material Design tabs are bars of buttons used to navigate between groups of content."
iconId: tabs
path: /catalog/tabs/
+api_doc_root: true
-->
+
+
# Tabs

@@ -15,59 +18,84 @@ path: /catalog/tabs/
Tabs are bars of buttons used to navigate between groups of content.
-## Design & API Documentation
+## Design & API documentation

Material Design guidelines: Tabs

-## Extensions
-
-

-
Color Theming

-
Typography Theming

-

+## Table of contents
+
+- [Overview](#overview)
+- [Installation](#installation)
+ - [Installation with CocoaPods](#installation-with-cocoapods)
+ - [Importing](#importing)
+- [Usage](#usage)
+ - [Importing](#importing)
+ - [Delegate](#delegate)
+ - [Selected item](#selected-item)
+ - [Appearance](#appearance)
+ - [Styling](#styling)
+ - [Custom selection indicators](#custom-selection-indicators)
+ - [Bottom navigation](#bottom-navigation)
+- [Examples](#examples)
+ - [Creating a tab bar](#creating-a-tab-bar)
+- [Extensions](#extensions)
+ - [Color Theming](#color-theming)
+ - [Typography Theming](#typography-theming)
- - -
+## Overview
+
+When a user taps a tab, the content changes to match the selected subject in the tabs.
+
+We provide this functionality through MDCTabBar which communicates via a delegate as well as
+MDCTabBarViewController which provides a view containment model similar to UITabViewController.
+
+Tabs can also show a badge (usually a number) like UITabBar.
+
## Installation
+
+
### Installation with CocoaPods
-To add this component to your Xcode project using CocoaPods, add the
-following to your `Podfile`:
+Add the following to your `Podfile`:
-```
+```bash
pod 'MaterialComponents/Tabs'
```
<!--{: .code-renderer.code-renderer--install }-->
-To add this component along with its themer and other related extensions, please add the following instead:
-```bash
-pod 'MaterialComponents/Tabs+Extensions'
-```
-
Then, run the following command:
```bash
pod install
```
-- - -
+### Importing
-## Overview
+To import the component:
-When a user taps a tab, the content changes to match the selected subject in the tabs.
+<!--<div class="material-code-render" markdown="1">-->
+#### Swift
+```swift
+import MaterialComponents.MaterialTabs
+```
-We provide this functionality through MDCTabBar which communicates via a delegate as well as
-MDCTabBarViewController which provides a view containment model similar to UITabViewController.
+#### Objective-C
-Tabs can also show a badge (usually a number) like UITabBar.
+```objc
+#import "MaterialTabs.h"
+```
+<!--</div>-->
-- - -
## Usage
+<!-- Extracted from docs/Usage.md -->
+
### Importing
To use the tab bar in your code, import the MaterialTabs umbrella header (Objective-C) or MaterialComponents module (Swift).
@@ -121,9 +149,10 @@ See `MDCTabBarIndicatorTemplate` and `MDCTabBarIndicatorAttributes` for details.
Implement `positionForBar:` and return `UIBarPositionBottom` to configure the tab bar as a bottom
navigation bar. The bar will automatically update with the appropriate styling.
-- - -
-## Example
+## Examples
+
+<!-- Extracted from docs/Examples.md -->
### Creating a tab bar
@@ -158,3 +187,92 @@ tabBar.autoresizingMask =
```

+
+
+## Extensions
+
+
+
+### Color Theming
+
+You can theme a tab bar with your app's color scheme using the ColorThemer extension.
+
+You must first add the Color Themer extension to your project:
+
+```bash
+pod 'MaterialComponents/Tabs+Extensions/ColorThemer'
+```
+
+
+#### Swift
+```swift
+// Step 1: Import the ColorThemer extension
+import MaterialComponents.MaterialTabs_ColorThemer
+
+// Step 2: Create or get a color scheme
+let colorScheme = MDCSemanticColorScheme()
+
+// Step 3: Apply the color scheme to your component
+// Primary variant
+MDCTabBarColorThemer.applySemanticColorScheme(colorScheme, toTabs: component)
+// Or surface variant
+MDCTabBarColorThemer.applySurfaceVariant(withColorScheme: colorScheme, toTabs: component)
+```
+
+#### Objective-C
+
+```objc
+// Step 1: Import the ColorThemer extension
+#import "MaterialTabs+ColorThemer.h"
+
+// Step 2: Create or get a color scheme
+id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
+
+// Step 3: Apply the color scheme to your component
+// Primary variant
+[MDCTabBarColorThemer applySemanticColorScheme:colorScheme toTabs:component];
+// Or surface variant
+[MDCTabBarColorThemer applySurfaceVariantWithColorScheme:colorScheme toTabs:component];
+```
+
+
+
+
+
+### Typography Theming
+
+You can theme a tab bar with your app's typography scheme using the TypographyThemer extension.
+
+You must first add the Typography Themer extension to your project:
+
+```bash
+pod 'MaterialComponents/Tabs+Extensions/TypographyThemer'
+```
+
+#### Swift
+```swift
+// Step 1: Import the TypographyThemer extension
+import MaterialComponents.MaterialTabs_TypographyThemer
+
+// Step 2: Create or get a typography scheme
+let typographyScheme = MDCTypographyScheme()
+
+// Step 3: Apply the typography scheme to your component
+MDCTabBarTypographyThemer.applyTypographyScheme(typographyScheme, to: component)
+```
+
+#### Objective-C
+
+```objc
+// Step 1: Import the TypographyThemer extension
+#import "MaterialTabs+TypographyThemer.h"
+
+// Step 2: Create or get a typography scheme
+id<MDCTypographyScheming> typographyScheme = [[MDCTypographyScheme alloc] init];
+
+// Step 3: Apply the typography scheme to your component
+[MDCTabBarTypographyThemer applyTypographyScheme:colorScheme
+ toTabBar:component];
+```
+
+

diff:
+### Creating a tab bar
+
+
+#### Swift
+
+```swift
+let tabBar = MDCTabBar(frame: view.bounds)
+tabBar.items = [
+UITabBarItem(title: "Recents", image: UIImage(named: "phone"), tag: 0),
+UITabBarItem(title: "Favorites", image: UIImage(named: "heart"), tag: 0),
+]
+tabBar.itemAppearance = .titledImages
+tabBar.autoresizingMask = [.flexibleWidth, .flexibleBottomMargin]
+tabBar.sizeToFit()
+view.addSubview(tabBar)
+```
+
+#### Objective-C
+
+```objc
+MDCTabBar *tabBar = [[MDCTabBar alloc] initWithFrame:self.view.bounds];
+tabBar.items = @[
+ [[UITabBarItem alloc] initWithTitle:@"Recents" image:[UIImage imageNamed:@"phone"] tag:0],
+ [[UITabBarItem alloc] initWithTitle:@"Favorites" image:[UIImage imageNamed:@"heart"] tag:0],
+];
+tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages;
+tabBar.autoresizingMask =
+ UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
+[tabBar sizeToFit];
+[self.view addSubview:tabBar];
+```
+
+

diff:
+# Tabs
+
+

+
+

+
+Tabs are bars of buttons used to navigate between groups of content.
+
+## Design & API documentation
+
+* [Material Design guidelines: Tabs](https://material.io/go/design-tabs)
+
+
+
+- - -
+
+## Overview
+
+When a user taps a tab, the content changes to match the selected subject in the tabs.
+
+We provide this functionality through MDCTabBar which communicates via a delegate as well as
+MDCTabBarViewController which provides a view containment model similar to UITabViewController.
+
+Tabs can also show a badge (usually a number) like UITabBar.
+
+## Installation
+
+- [Typical installation](../../../docs/component-installation.md)
+
+## Usage
+
+- [Usage](Usage.md)
+
+## Examples
+
+- [Examples](Examples.md)
+
+## Extensions
+
+- [Color Theming](color-theming.md)
+
+- [Typography Theming](typography-theming.md)

diff:
+### Importing
+
+To use the tab bar in your code, import the MaterialTabs umbrella header (Objective-C) or MaterialComponents module (Swift).
+
+
+#### Swift
+
+```swift
+import MaterialComponents
+```
+
+#### Objective-C
+
+```objc
+#import "MaterialTabs.h"
+```
+
+
+
+### Delegate
+
+Conform your class to the MDCTabBarDelegate protocol and set it as the tab bar's delegate to handle updating the UI when the user selects a tab.
+
+### Selected item
+
+Update the selected tab programmatically by setting `selectedItem`, optionally with an animation. Delegate methods are not called for programmatic changes, so callers are responsible for updating UI as needed after updating the selected item.
+
+### Appearance
+
+Set the `itemAppearance` property on the tab bar to switch between item display modes. Items can be displayed as titles (the default), icons, or combined.
+
+### Styling
+
+By default, the tab bar is configured to display items with white text and icons. To customize the color of the tab bar, set the `tintColor`, `selectedItemTintColor`, `unselectedItemTintColor`, `inkColor`, and `barTintColor` properties. If `selectedItemTintColor` is nil, the tab bar's `tintColor` will be used automatically for selected items.
+
+Configure where items are placed in the tab bar by setting the `alignment` property.
+
+### Custom selection indicators
+
+The currently-selected tab is indicated visually by a *selection indicator*. By default this is an
+underline, but you can customize its appearance by defining a selection indicator template and
+setting the `selectionIndicatorTemplate` property on the tab bar. Template objects are provided
+contextual information about a tab's content and return *attributes* that describe how that tab's
+indicator should appear. The indicator will then automatically display the provided shape and
+animate changes as the user selects different tabs.
+
+See `MDCTabBarIndicatorTemplate` and `MDCTabBarIndicatorAttributes` for details.
+
+### Bottom navigation
+
+Implement `positionForBar:` and return `UIBarPositionBottom` to configure the tab bar as a bottom
+navigation bar. The bar will automatically update with the appropriate styling.

diff:
-<!--docs:
-title: "Color Theming"
-layout: detail
-section: components
-excerpt: "How to theme Tabs using the Material Design color system."
-iconId: tabs
-path: /catalog/tabs/color-theming/
--->
-
-# Tabs Color Theming
+### Color Theming
You can theme a tab bar with your app's color scheme using the ColorThemer extension.
@@ -17,8 +8,6 @@ You must first add the Color Themer extension to your project:
pod 'MaterialComponents/Tabs+Extensions/ColorThemer'
```
-## Example code
-
<!--<div class="material-code-render" markdown="1">-->
#### Swift
```swift

diff:
-<!--docs:
-title: "Typography Theming"
-layout: detail
-section: components
-excerpt: "How to theme Tabs using the Material Design typography system."
-iconId: tabs
-path: /catalog/tabs/typography-theming/
--->
-
-# Tabs Typography Theming
+### Typography Theming
You can theme a tab bar with your app's typography scheme using the TypographyThemer extension.
@@ -16,9 +7,6 @@ You must first add the Typography Themer extension to your project:
```bash
pod 'MaterialComponents/Tabs+Extensions/TypographyThemer'
```
-
-## Example code
-
<!--<div class="material-code-render" markdown="1">-->
#### Swift
```swift

original_message:
[Tabs] readme update. (#3613)

* adding tabs docs components.

* auto generated tabs

* fixing color and typography theming docs.

* typography themeing is added.

* tab bar to tab-bar,
image tags added back.

* reverting tab bar -> tab-bar

* regenerating the readme.

https://github.com/material-components/material-components-ios/pull/3613


message:
Update README.md
lower case file name.

diff:
@@ -29,11 +29,11 @@ Tabs can also show a badge (usually a number) like UITabBar.
## Usage
-- [Usage](Usage.md)
+- [Usage](usage.md)
## Examples
-- [Examples](Examples.md)
+- [Examples](examples.md)
## Extensions

original_message:
Update README.md

lower case file name.


message: regenerating tabs after file change.

diff:
@@ -94,7 +94,7 @@ import MaterialComponents.MaterialTabs
## Usage
-<!-- Extracted from docs/Usage.md -->
+<!-- Extracted from docs/usage.md -->
### Importing
@@ -152,7 +152,7 @@ navigation bar. The bar will automatically update with the appropriate styling.
## Examples
-<!-- Extracted from docs/Examples.md -->
+<!-- Extracted from docs/examples.md -->
### Creating a tab bar

original_message: regenerating tabs after file change. (#3623)


diff:
@@ -41,6 +41,8 @@ static void CancelGestureRecognizer(UIGestureRecognizer *gesture) {
_dragRecognizer.maximumNumberOfTouches = 1;
_dragRecognizer.delegate = self;
[self addGestureRecognizer:_dragRecognizer];
+
+ self.clipsToBounds = YES;
}
return self;
}

original_message: Fix issue causing black squares on bottom sheet rotation (#3630)


diff:
// Flat button
- MDCFlatButton *flatButton = [[MDCFlatButton alloc] init];
+ MDCButton *flatButton = [[MDCButton alloc] init];
[flatButton setTitle:@"Oval Flat" forState:UIControlStateNormal];
- [MDCButtonTypographyThemer applyTypographyScheme:self.typographyScheme
- toButton:flatButton];
- [MDCButtonColorThemer applySemanticColorScheme:self.colorScheme
- toFlatButton:flatButton];
+ [MDCTextButtonThemer applyScheme:buttonScheme toButton:flatButton];
MDCPillShapeGenerator *flatShapeGenerator = [[MDCPillShapeGenerator alloc] init];
flatButton.shapeGenerator = flatShapeGenerator;
[floatingShapeGenerator setCorners:
[[MDCCutCornerTreatment alloc] initWithCut:CGRectGetWidth(self.floatingButton.bounds) / 2.f]];
self.floatingButton.shapeGenerator = floatingShapeGenerator;
+ [MDCFloatingActionButtonThemer applyScheme:buttonScheme toButton:self.floatingButton];
[self.floatingButton addTarget:self
action:@selector(didTap:)

original_message:
FAB button in shapes example should be themed. (#3737)

https://github.com/material-components/material-components-ios/pull/3737


message:
[Catalog] Bottom App bar should theme the FAB Button.
* Bottom App bar should theme the FAB Button,
View should not be loaded in init,
Scheme properties are added.
* lf, header name.

diff:
#import <UIKit/UIKit.h>
#import "MaterialBottomAppBar.h"
-#import "MaterialButtons+ColorThemer.h"
+#import "MaterialButtons+ButtonThemer.h"
#import "supplemental/BottomAppBarTypicalUseSupplemental.h"
+@interface BottomAppBarTypicalUseExample ()
+
+@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
+@property(nonatomic, strong) MDCTypographyScheme *typographyScheme;
+
+@end
+
@implementation BottomAppBarTypicalUseExample
- (id)init {
self = [super init];
if (self) {
self.title = @"Bottom App Bar";
- [self commonBottomBarTypicalUseExampleInit];
}
return self;
}
-- (void)commonBottomBarTypicalUseExampleInit {
+- (void)commonBottomBarSetup {
[self setupExampleTableLayout];
// Add touch handler to the floating button.
forControlEvents:UIControlEventTouchUpInside];
// Set the image on the floating button.
- UIImage *addImage = [UIImage imageNamed:@"Add"];
+ UIImage *addImage =
+ [[UIImage imageNamed:@"Add"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.bottomBarView.floatingButton setImage:addImage forState:UIControlStateNormal];
- // Theme the floating button.
- MDCSemanticColorScheme *colorScheme = [[MDCSemanticColorScheme alloc] init];
- [MDCButtonColorThemer applySemanticColorScheme:colorScheme
- toFloatingButton:self.bottomBarView.floatingButton];
-
// Configure the navigation buttons to be shown on the bottom app bar.
UIBarButtonItem *barButtonLeadingItem =
[[UIBarButtonItem alloc] initWithTitle:nil
[self.bottomBarView setTrailingBarButtonItems:@[ barButtonTrailingItem ]];
}
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ [self commonBottomBarSetup];
+
+ MDCButtonScheme *buttonScheme = [[MDCButtonScheme alloc] init];
+ buttonScheme.colorScheme = self.colorScheme;
+ buttonScheme.typographyScheme = self.typographyScheme;
+ [MDCFloatingActionButtonThemer applyScheme:buttonScheme
+ toButton:self.bottomBarView.floatingButton];
+}
- (void)didTapFloatingButton:(id)sender {
[self.bottomBarView setFloatingButtonHidden:YES animated:YES];
}

diff:
@implementation BottomAppBarTypicalUseViewController
-- (instancetype)initWithCoder:(NSCoder *)aDecoder {
- self = [super initWithCoder:aDecoder];
- if (self) {
- [self commonMDCBottomAppBarViewControllerInit];
- }
- return self;
-}
-
-- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- [self commonMDCBottomAppBarViewControllerInit];
- }
- return self;
-}
-
-- (void)commonMDCBottomAppBarViewControllerInit {
+- (void)commonMDCBottomAppBarViewControllerSetup {
_bottomBarView = [[MDCBottomAppBarView alloc] initWithFrame:CGRectZero];
_bottomBarView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin);
_bottomBarView.frame = bottomBarViewFrame;
}
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ [self commonMDCBottomAppBarViewControllerSetup];
+}
+
+
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
[self layoutBottomAppBar];

original_message:
[Catalog] Bottom App bar should theme the FAB Button. (#3740)

* Bottom App bar should theme the FAB Button,
View should not be loaded in init,
Scheme properties are added.

* lf, header name.

https://github.com/material-components/material-components-ios/pull/3740


message:
Add an app bar to the bottom app bar demo
![simulator screen shot - iphone 8 plus - 2018-05-09 at 18 02 53](https://user-images.githubusercontent.com/1418389/39842126-53b96150-53b3-11e8-94c6-8b1ed403cbe5.png)

diff:
#import "supplemental/BottomAppBarTypicalUseSupplemental.h"
-@interface BottomAppBarTypicalUseExample ()
-
-@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
-@property(nonatomic, strong) MDCTypographyScheme *typographyScheme;
-
-@end
-
@implementation BottomAppBarTypicalUseExample
- (id)init {

diff:
#import "BottomAppBarTypicalUseViewController.h"
#import "MaterialBottomAppBar.h"
+#import "MaterialColorScheme.h"
+#import "MaterialTypographyScheme.h"
@interface BottomAppBarTypicalUseExample : BottomAppBarTypicalUseViewController
+@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
+
+@property(nonatomic, strong) MDCTypographyScheme *typographyScheme;
+
@end
@interface BottomAppBarTypicalUseExample (Supplemental)

diff:
#import "BottomAppBarTypicalUseSupplemental.h"
+#import "MaterialAppBar.h"
+#import "MaterialAppBar+ColorThemer.h"
+#import "MaterialAppBar+TypographyThemer.h"
+
static NSString *const kCellIdentifier = @"cell";
@interface BottomAppBarExampleTableViewController ()
@property(nonatomic, strong) UISwitch *fabVisibilitySwitch;
+@property(nonatomic, strong) MDCAppBar *appBar;
+@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
+@property(nonatomic, strong) MDCTypographyScheme *typographyScheme;
@end
@implementation BottomAppBarTypicalUseExample (CatalogByConvention)
@@ -52,6 +59,8 @@ static NSString *const kCellIdentifier = @"cell";
BottomAppBarExampleTableViewController *tableView =
[[BottomAppBarExampleTableViewController alloc] initWithNibName:nil bundle:nil];
tableView.bottomBarView = self.bottomBarView;
+ tableView.colorScheme = self.colorScheme;
+ tableView.typographyScheme = self.typographyScheme;
self.viewController = tableView;
}
@@ -74,6 +83,11 @@ static NSString *const kCellIdentifier = @"cell";
@"Secondary Elevation Floating Button",
@"Visible FAB" ];
_listItems = listItems;
+
+ self.title = @"Bottom App Bar";
+
+ _appBar = [[MDCAppBar alloc] init];
+ [self addChildViewController:_appBar.headerViewController];
}
return self;
}
@@ -81,6 +95,14 @@ static NSString *const kCellIdentifier = @"cell";
- (void)viewDidLoad {
[super viewDidLoad];
+ [MDCAppBarTypographyThemer applyTypographyScheme:self.typographyScheme toAppBar:_appBar];
+ [MDCAppBarColorThemer applySemanticColorScheme:self.colorScheme toAppBar:_appBar];
+
+ self.appBar.headerViewController.headerView.trackingScrollView = self.tableView;
+ self.tableView.delegate = self.appBar.headerViewController;
+
+ [self.appBar addSubviewsToParent];
+
self.fabVisibilitySwitch = [[UISwitch alloc] init];
self.fabVisibilitySwitch.on = !self.bottomBarView.floatingButtonHidden;
[self.fabVisibilitySwitch addTarget:self

original_message:
Add an app bar to the bottom app bar demo (#3760)

https://www.pivotaltracker.com/story/show/157256931

![simulator screen shot - iphone 8 plus - 2018-05-09 at 18 02 53](https://user-images.githubusercontent.com/1418389/39842126-53b96150-53b3-11e8-94c6-8b1ed403cbe5.png)


diff:
#import "MDCTextInputControllerBase.h"
#import "MDCTextInputControllerFloatingPlaceholder.h"
#import "MDCTextInputUnderlineView.h"
-#import "private/MDCPaddedLabel.h"
#import "private/MDCTextInputControllerBase+Subclassing.h"
#import "MaterialMath.h"
static const CGFloat MDCTextInputOutlinedTextFieldFullPadding = 16.f;
static const CGFloat MDCTextInputOutlinedTextFieldNormalPlaceholderPadding = 20.f;
-static const CGFloat MDCTextInputOutlinedTextFieldPlaceholderPadding = 4.f;
+static const CGFloat MDCTextInputOutlinedTextFieldFloatingPlaceholderPadding = 8.f;
static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
@@ -69,8 +68,6 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
UIOffset offset = [super floatingPlaceholderOffset];
CGFloat textVerticalOffset = 0;
offset.vertical = textVerticalOffset;
- MDCPaddedLabel *placeholderLabel = (MDCPaddedLabel *)self.textInput.placeholderLabel;
- offset.horizontal += placeholderLabel.horizontalPadding;
return offset;
}
@@ -140,9 +137,12 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
[self.textInput.placeholderLabel systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]
.width * (CGFloat)self.floatingPlaceholderScale.floatValue;
+ placeholderWidth += MDCTextInputOutlinedTextFieldFloatingPlaceholderPadding;
+
path = [self roundedPathFromRect:pathRect
withTextSpace:placeholderWidth
- leftOffset:MDCTextInputOutlinedTextFieldFullPadding];
+ leftOffset:MDCTextInputOutlinedTextFieldFullPadding -
+ MDCTextInputOutlinedTextFieldFloatingPlaceholderPadding/2.0f];
} else {
CGSize cornerRadius = CGSizeMake(MDCTextInputControllerBaseDefaultBorderRadius,
MDCTextInputControllerBaseDefaultBorderRadius);
@@ -171,9 +171,9 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
// Draw the path
[path moveToPoint:CGPointMake(radius + xOffset, yOffset)];
- [path addLineToPoint:CGPointMake(offset + xOffset - radius, yOffset)];
+ [path addLineToPoint:CGPointMake(offset + xOffset, yOffset)];
- [path moveToPoint:CGPointMake(textSpace + offset + xOffset - radius, yOffset)];
+ [path moveToPoint:CGPointMake(textSpace + offset + xOffset, yOffset)];
[path addLineToPoint:CGPointMake(f.size.width - radius + xOffset, yOffset)];
[path addArcWithCenter:CGPointMake(f.size.width - radius + xOffset, radius + yOffset)
@@ -229,9 +229,6 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
}
self.placeholderCenterY.constant = placeholderConstant;
- MDCPaddedLabel *placeholderLabel = (MDCPaddedLabel *)self.textInput.placeholderLabel;
- placeholderLabel.horizontalPadding = MDCTextInputOutlinedTextFieldPlaceholderPadding;
-
if (!self.placeholderLeading) {
self.placeholderLeading =
[NSLayoutConstraint constraintWithItem:self.textInput.placeholderLabel
@@ -240,8 +237,7 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
toItem:self.textInput
attribute:NSLayoutAttributeLeading
multiplier:1
- constant:MDCTextInputOutlinedTextFieldFullPadding -
- placeholderLabel.horizontalPadding];
+ constant:MDCTextInputOutlinedTextFieldFullPadding];
self.placeholderLeading.priority = UILayoutPriorityDefaultHigh;
self.placeholderLeading.active = YES;
}

change_type: DELETE

diff:
-/*
- Copyright 2017-present the Material Components for iOS authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#import <UIKit/UIKit.h>
-
-/**
- A label with in-frame padding.
-
- @note This label was created for use with auto layout. If you are using manual layout, test it
- first. You may need to adjust code around sizeThatFits: etc.
- */
-@interface MDCPaddedLabel : UILabel
-
-/**
- The padding to be applied.
-
- The padding is applied the same on each side (left and right both get the value of
- .horizontalPadding added to them. This will result in a label that's 2 * .horizontalPadding wider
- than a plain UILabel.
- */
-@property(nonatomic, assign) CGFloat horizontalPadding;
-
-@end

diff:
-/*
- Copyright 2017-present the Material Components for iOS authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#import "MDCPaddedLabel.h"
-
-static NSString *const MDCPaddedLabelHorizontalPaddingKey = @"MDCPaddedLabelHorizontalPaddingKey";
-
-@implementation MDCPaddedLabel
-
-- (instancetype)initWithCoder:(NSCoder *)aDecoder {
- self = [super initWithCoder:aDecoder];
- if (self) {
- _horizontalPadding = (CGFloat)[aDecoder decodeDoubleForKey:MDCPaddedLabelHorizontalPaddingKey];
- }
- return self;
-}
-
-- (void)encodeWithCoder:(NSCoder *)aCoder {
- [super encodeWithCoder:aCoder];
- [aCoder encodeDouble:(double)_horizontalPadding forKey:MDCPaddedLabelHorizontalPaddingKey];
-}
-
-#pragma mark - Setters
-
-- (void)setHorizontalPadding:(CGFloat)horizontalPadding {
- _horizontalPadding = horizontalPadding;
-
- [self invalidateIntrinsicContentSize];
-}
-
-#pragma mark - UILabel Overrides
-
-- (void)drawTextInRect:(CGRect)rect {
- [super drawTextInRect:CGRectInset(rect, self.horizontalPadding, 0)];
-}
-
-#pragma mark - UIView Overrides
-
-- (CGSize)intrinsicContentSize {
- CGSize size = [super intrinsicContentSize];
-
- size.width += self.horizontalPadding * 2.f;
-
- return size;
-}
-
-@end

diff:
#import "MDCMultilineTextField.h"
#import "MDCMultilineTextInputDelegate.h"
-#import "MDCPaddedLabel.h"
#import "MDCTextField.h"
#import "MDCTextFieldPositioningDelegate.h"
#import "MDCTextInput.h"
@@ -337,7 +336,7 @@ static inline UIColor *MDCTextInputUnderlineColor() {
- (void)setupPlaceholderLabel {
if (!_placeholderLabel) {
- _placeholderLabel = [[MDCPaddedLabel alloc] initWithFrame:CGRectZero];
+ _placeholderLabel = [[UILabel alloc] initWithFrame:CGRectZero];
}
_placeholderLabel.translatesAutoresizingMaskIntoConstraints = NO;
[_placeholderLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow - 2

original_message: Getting rid of paddedLabel Class since it's not needed anymore. (#4196)


diff:
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import <UIKit/UIKit.h>
+
+#import "MaterialAppBar.h"
+#import "MaterialAppBar+ColorThemer.h"
+#import "MaterialAppBar+TypographyThemer.h"
+
+
+@interface WrappedDemoViewController : UIViewController
+@end
+
+@implementation WrappedDemoViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ self.title = @"Wrapped App Bar";
+
+ self.view.backgroundColor = [UIColor colorWithWhite:0.95f alpha:1];
+
+ UILabel *label = [[UILabel alloc] init];
+ label.text = @"Wrapped UIViewController";
+ [self.view addSubview:label];
+
+ [label sizeToFit];
+ label.center = self.view.center;
+}
+
+@end
+
+@interface AppBarWrappedExample : UIViewController
+
+@property(nonatomic, strong) MDCAppBarContainerViewController *appBarContainerViewController;
+@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
+@property(nonatomic, strong) MDCTypographyScheme *typographyScheme;
+
+@end
+
+@implementation AppBarWrappedExample
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ WrappedDemoViewController *demoVC = [[WrappedDemoViewController alloc] init];
+ self.appBarContainerViewController =
+ [[MDCAppBarContainerViewController alloc] initWithContentViewController:demoVC];
+
+ [MDCAppBarColorThemer applySemanticColorScheme:self.colorScheme
+ toAppBar:self.appBarContainerViewController.appBar];
+ [MDCAppBarTypographyThemer applyTypographyScheme:self.typographyScheme
+ toAppBar:self.appBarContainerViewController.appBar];
+
+ // Need to update the status bar style after applying the theme.
+ [self setNeedsStatusBarAppearanceUpdate];
+
+ [self addChildViewController:self.appBarContainerViewController];
+ self.appBarContainerViewController.view.frame = self.view.bounds;
+ [self.view addSubview:self.appBarContainerViewController.view];
+ [self.appBarContainerViewController didMoveToParentViewController:self];
+}
+
+@end
+
+@implementation AppBarWrappedExample (CatalogByConvention)
+
++ (NSArray *)catalogBreadcrumbs {
+ return @[ @"App Bar", @"Wrapped" ];
+}
+
++ (BOOL)catalogIsPrimaryDemo {
+ return NO;
+}
+
+- (BOOL)catalogShouldHideNavigation {
+ return YES;
+}
+
++ (BOOL)catalogIsPresentable {
+ return YES;
+}
+
+@end

original_message: Create an example of MDCAppBarContainerViewController usage (#4197)


diff:
@@ -168,16 +168,16 @@ static const CGFloat kMDCFeatureHighlightPulseAnimationInterval = 1.5f;
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
+ UIViewController *presenter = self.presentingViewController;
+ UIViewController *presentingViewController = self;
+ [self dismissViewControllerAnimated:NO completion:nil];
+
[coordinator animateAlongsideTransition:^(__unused
id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
- CGPoint point = [self->_highlightedView.superview convertPoint:self->_highlightedView.center
- toView:self.featureHighlightView];
-
- self.featureHighlightView.highlightPoint = point;
- [self.featureHighlightView layoutIfNeeded];
- [self.featureHighlightView updateOuterHighlight];
}
- completion:nil];
+ completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
+ [presenter presentViewController:presentingViewController animated:YES completion:nil];
+ }];
}
- (void)setOuterHighlightColor:(UIColor *)outerHighlightColor {

original_message:
we dismiss and present feature highlight from the new spot. (#4300)

https://github.com/material-components/material-components-ios/pull/4300


message:
Apply updates to catalog spacing, labels, and cell styles
Implements updated layouts specified in the spec.
![simulator screen shot - iphone 8 plus - 2018-05-17 at 15 59 59](https://user-images.githubusercontent.com/1418389/40200870-69ed2d88-59eb-11e8-976e-f81476232e86.png)
![simulator screen shot - iphone 8 plus - 2018-05-17 at 15 59 47](https://user-images.githubusercontent.com/1418389/40200873-6ca394b8-59eb-11e8-90a0-1268cd7e0df6.png)

diff:
@@ -22,13 +22,12 @@ class MDCCatalogCollectionViewCell: UICollectionViewCell {
fileprivate struct Constants {
static let imageWidthHeight: CGFloat = 80
- static let xPadding: CGFloat = 14
- static let yPadding: CGFloat = 16
+ static let padding: CGFloat = 16
}
private lazy var label: UILabel = {
let label = UILabel()
- label.textColor = UIColor(white: 0, alpha: MDCTypography.buttonFontOpacity())
+ label.textColor = AppTheme.defaultTheme.colorScheme.primaryColor
label.font = MDCTypography.buttonFont()
return label
@@ -55,9 +54,9 @@ class MDCCatalogCollectionViewCell: UICollectionViewCell {
super.layoutSubviews()
label.sizeToFit()
label.frame = CGRect(
- x: Constants.xPadding,
- y: frame.height - label.frame.height - Constants.yPadding,
- width: frame.width - Constants.xPadding * 2,
+ x: Constants.padding,
+ y: frame.height - label.frame.height - Constants.padding,
+ width: frame.width - Constants.padding * 2,
height: label.frame.height
)
tile.bounds = CGRect(x: 0,

diff:
@@ -37,8 +37,48 @@ class NodeViewTableViewDemoCell: UITableViewCell {
// Ensure subtitile text is proportionally less pronounced than the title label
let textLabelFont = textLabel!.font
- detailTextLabel?.alpha = CGFloat(0.5)
- detailTextLabel?.font = textLabelFont?.withSize(CGFloat((textLabelFont?.pointSize)! * 0.5))
+ detailTextLabel?.alpha = MDCTypography.captionFontOpacity()
+ detailTextLabel?.font = MDCTypography.body2Font()
+
+ let lineDivider = UIView()
+ lineDivider.backgroundColor = UIColor(white: 0.85, alpha: 1)
+ lineDivider.translatesAutoresizingMaskIntoConstraints = false
+ self.addSubview(lineDivider)
+
+ NSLayoutConstraint(
+ item: lineDivider,
+ attribute: .height,
+ relatedBy: .equal,
+ toItem: nil,
+ attribute: .notAnAttribute,
+ multiplier: 1.0,
+ constant: 1).isActive = true
+
+ // Line divider to section view
+ NSLayoutConstraint(
+ item: textLabel!,
+ attribute: .leading,
+ relatedBy: .equal,
+ toItem: lineDivider,
+ attribute: .leading,
+ multiplier: 1.0,
+ constant: 0).isActive = true
+ NSLayoutConstraint(
+ item: self,
+ attribute: .trailing,
+ relatedBy: .equal,
+ toItem: lineDivider,
+ attribute: .trailing,
+ multiplier: 1.0,
+ constant: 0).isActive = true
+ NSLayoutConstraint(
+ item: self,
+ attribute: .bottom,
+ relatedBy: .equal,
+ toItem: lineDivider,
+ attribute: .bottom,
+ multiplier: 1.0,
+ constant: 0).isActive = true
}
required init(coder: NSCoder) {
@@ -92,14 +132,14 @@ class NodeViewTableViewPrimaryDemoCell: UITableViewCell {
toItem: containedButton,
attribute: .top,
multiplier: 1,
- constant: -8).isActive = true
+ constant: -10).isActive = true
NSLayoutConstraint(item: contentView,
attribute: .bottom,
relatedBy: .equal,
toItem: containedButton,
attribute: .bottom,
multiplier: 1,
- constant: 8).isActive = true
+ constant: 6).isActive = true
}
}
@@ -113,11 +153,14 @@ class MDCNodeListViewController: CBCNodeListViewController {
let sectionNames = ["Description", "Additional Examples"]
let estimadedDescriptionSectionHeight = CGFloat(100)
let estimadedAdditionalExamplesSectionHeight = CGFloat(50)
- let estimadedDemoRowHeight = CGFloat(60)
- let estimadedRowHeight = CGFloat(50)
let padding = CGFloat(16)
var componentDescription = ""
var selectedNode: CBCNode? = nil
+ var titleMaxY = CGFloat(36)
+ var titleDescriptionMargin = CGFloat(34)
+ var descriptionLineHeight = CGFloat(24)
+ var demoButtonRowHeight = CGFloat(54)
+ var additionalDemoRowHeight = CGFloat(64)
enum Section: Int {
case description = 0
@@ -148,21 +191,12 @@ class MDCNodeListViewController: CBCNodeListViewController {
componentDescription = childrenNodes.first?.exampleDescription() ?? ""
self.addChildViewController(appBar.headerViewController)
- let appBarFont: UIFont
- if #available(iOS 9.0, *) {
- appBarFont = UIFont.monospacedDigitSystemFont(ofSize: 16, weight: UIFontWeightRegular)
- } else {
- let attribute: [String: UIFontDescriptorSymbolicTraits] =
- [UIFontSymbolicTrait: UIFontDescriptorSymbolicTraits.traitMonoSpace]
- let descriptor: UIFontDescriptor = UIFontDescriptor(fontAttributes: attribute)
- appBarFont = UIFont(descriptor: descriptor, size: 16)
- }
- appBar.navigationBar.titleTextAttributes = [
- NSForegroundColorAttributeName: UIColor.white,
- NSFontAttributeName: appBarFont ]
appBar.navigationBar.titleAlignment = .center
applyColorScheme(AppTheme.globalTheme.colorScheme)
+ MDCAppBarTypographyThemer.applyTypographyScheme(
+ AppTheme.globalTheme.typographyScheme,
+ to:appBar)
NotificationCenter.default.addObserver(
self,
@@ -186,7 +220,6 @@ class MDCNodeListViewController: CBCNodeListViewController {
additionalExamplesSectionHeader = createAdditionalExamplesSectionHeader()
self.tableView.backgroundColor = UIColor.white
self.tableView.separatorStyle = .none
- self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.sectionHeaderHeight = UITableViewAutomaticDimension
var charactersCount = 0
@@ -313,11 +346,11 @@ extension MDCNodeListViewController {
titleForHeaderInSection section: Int) -> String? {
return sectionNames[section]
}
- override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
+ override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == Section.description.rawValue {
- return estimadedDemoRowHeight
+ return demoButtonRowHeight
}
- return estimadedRowHeight
+ return additionalDemoRowHeight
}
override func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat {
@@ -457,13 +490,18 @@ extension MDCNodeListViewController {
sectionTitleLabel.setContentCompressionResistancePriority(1000, for: .vertical)
let descriptionLabel = UILabel()
- descriptionLabel.text = componentDescription
- descriptionLabel.font = MDCTypography.captionFont()
- descriptionLabel.alpha = MDCTypography.captionFontOpacity()
+ descriptionLabel.font = MDCTypography.body1Font()
+
+ let paragraphStyle = NSMutableParagraphStyle()
+ paragraphStyle.lineSpacing = descriptionLineHeight - descriptionLabel.font.lineHeight
+ let attrs = [NSParagraphStyleAttributeName: paragraphStyle]
+
+ descriptionLabel.attributedText =
+ NSAttributedString(string:componentDescription, attributes:attrs)
+ descriptionLabel.alpha = MDCTypography.body1FontOpacity()
descriptionLabel.translatesAutoresizingMaskIntoConstraints = false
descriptionLabel.numberOfLines = 0
descriptionLabel.setContentCompressionResistancePriority(1000, for: .vertical)
-
sectionView.addSubview(sectionTitleLabel)
sectionView.addSubview(descriptionLabel)
@@ -503,13 +541,13 @@ extension MDCNodeListViewController {
#endif
NSLayoutConstraint(
- item: sectionView,
- attribute: .top,
+ item: sectionTitleLabel,
+ attribute: .lastBaseline,
relatedBy: .equal,
- toItem: sectionTitleLabel,
+ toItem: sectionView,
attribute: .top,
multiplier: 1.0,
- constant: -padding).isActive = true
+ constant: titleMaxY).isActive = true
// descriptionLabel to sectionTitleLabel
NSLayoutConstraint(
@@ -530,12 +568,12 @@ extension MDCNodeListViewController {
constant: 0).isActive = true
NSLayoutConstraint(
item: sectionTitleLabel,
- attribute: .bottom,
+ attribute: .lastBaseline,
relatedBy: .equal,
toItem: descriptionLabel,
- attribute: .top,
+ attribute: .firstBaseline,
multiplier: 1.0,
- constant: -10).isActive = true
+ constant: -titleDescriptionMargin).isActive = true
// descriptionLabel to SectionView
NSLayoutConstraint(

original_message:
Apply updates to catalog spacing, labels, and cell styles (#4187)

Implements updated layouts specified in the spec.

![simulator screen shot - iphone 8 plus - 2018-05-17 at 15 59 59](https://user-images.githubusercontent.com/1418389/40200870-69ed2d88-59eb-11e8-976e-f81476232e86.png)
![simulator screen shot - iphone 8 plus - 2018-05-17 at 15 59 47](https://user-images.githubusercontent.com/1418389/40200873-6ca394b8-59eb-11e8-90a0-1268cd7e0df6.png)


message:
Fix accessibilityIncrement for discrete sliders
When numberOfDiscreteValues is non-zero, the MDCSlider should use these as the step value in accessibilityIncrement and accessibilityDecrement. If the number of discrete values is fewer than 8, then VoiceOver users cannot modify the slider value by swiping up or down.

diff:
@@ -445,7 +445,11 @@ static inline UIColor *MDCThumbTrackDefaultColor(void) {
- (void)accessibilityIncrement {
if (self.enabled) {
CGFloat range = self.maximumValue - self.minimumValue;
- CGFloat newValue = self.value + kSliderAccessibilityIncrement * range;
+ CGFloat adjustmentAmount = kSliderAccessibilityIncrement * range;
+ if (self.numberOfDiscreteValues > 1) {
+ adjustmentAmount = range / (self.numberOfDiscreteValues - 1);
+ }
+ CGFloat newValue = self.value + adjustmentAmount;
[_thumbTrack setValue:newValue
animated:NO
animateThumbAfterMove:NO
@@ -459,7 +463,11 @@ static inline UIColor *MDCThumbTrackDefaultColor(void) {
- (void)accessibilityDecrement {
if (self.enabled) {
CGFloat range = self.maximumValue - self.minimumValue;
- CGFloat newValue = self.value - kSliderAccessibilityIncrement * range;
+ CGFloat adjustmentAmount = kSliderAccessibilityIncrement * range;
+ if (self.numberOfDiscreteValues > 1) {
+ adjustmentAmount = range / (self.numberOfDiscreteValues - 1);
+ }
+ CGFloat newValue = self.value - adjustmentAmount;
[_thumbTrack setValue:newValue
animated:NO
animateThumbAfterMove:NO

diff:
@@ -1069,6 +1069,27 @@ static const CGFloat kEpsilonAccuracy = 0.001f;
XCTAssertTrue(self.slider.accessibilityTraits & UIAccessibilityTraitAdjustable);
}
+- (void)testAccessibilityIncrementDiscreteSlider {
+ for (NSUInteger i = 2; i < 20; ++i) {
+ // Given
+ self.slider.numberOfDiscreteValues = i;
+ self.slider.minimumValue = 0;
+ self.slider.maximumValue = 1;
+ self.slider.value = self.slider.minimumValue;
+
+ // When
+ [self.slider accessibilityIncrement];
+
+ // Then
+ CGFloat stepValue = (self.slider.maximumValue - self.slider.minimumValue) /
+ (self.slider.numberOfDiscreteValues - 1);
+ CGFloat expectedValue = self.slider.minimumValue + stepValue;
+ XCTAssertEqualWithAccuracy(self.slider.value, expectedValue, 0.0001,
+ @"A slider with (%lu) discrete values should have step of '%.3f'.",
+ (unsigned long)self.slider.numberOfDiscreteValues, stepValue);
+ }
+}
+
#pragma mark Private test helpers
- (CGFloat)randomNumber {

original_message:
Fix accessibilityIncrement for discrete sliders (#4327)

When numberOfDiscreteValues is non-zero, the MDCSlider should use these as the step value in accessibilityIncrement and accessibilityDecrement. If the number of discrete values is fewer than 8, then VoiceOver users cannot modify the slider value by swiping up or down.


message:
[FlexibleHeader] Fix odd scrolling bugs in voiceover
Prevent the flexible header view from over extending or jumping to incorrect scroll positions when focus swiping in voiceover. There should be no visual difference in either mode, and no functional difference with voice over disabled.

diff:
@@ -191,12 +191,14 @@ static NSString *const MDCFlexibleHeaderDelegateKey = @"MDCFlexibleHeaderDelegat
@synthesize sharedWithManyScrollViews = _sharedWithManyScrollViews;
@synthesize visibleShadowOpacity = _visibleShadowOpacity;
-#if DEBUG
- (void)dealloc {
+#if DEBUG
[_trackingScrollView.panGestureRecognizer removeTarget:self
action:@selector(fhv_scrollViewDidPan:)];
-}
#endif
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
@@ -352,6 +354,11 @@ static NSString *const MDCFlexibleHeaderDelegateKey = @"MDCFlexibleHeaderDelegat
self.layer.shadowOffset = CGSizeMake(0, 1);
self.layer.shadowRadius = 4.f;
self.layer.shadowOpacity = 0;
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(fhv_updateLayout)
+ name:UIAccessibilityVoiceOverStatusChanged
+ object:nil];
}
- (void)setVisibleShadowOpacity:(float)visibleShadowOpacity {
@@ -1004,7 +1011,7 @@ static NSString *const MDCFlexibleHeaderDelegateKey = @"MDCFlexibleHeaderDelegat
CGRect bounds = self.bounds;
- if (_canOverExtend) {
+ if (_canOverExtend && !UIAccessibilityIsVoiceOverRunning()) {
bounds.size.height = MAX(self.computedMinimumHeight, headerHeight);
} else {
@@ -1069,11 +1076,28 @@ static NSString *const MDCFlexibleHeaderDelegateKey = @"MDCFlexibleHeaderDelegat
// header other than as a subview to the scroll view. This is the most common case to which the
// following logic has been written.
if (self.superview == self.trackingScrollView) {
- self.transform = CGAffineTransformMakeTranslation(0, self.trackingScrollView.contentOffset.y);
-
if (self.superview.subviews.lastObject != self) {
[self.superview bringSubviewToFront:self];
}
+
+ if (UIAccessibilityIsVoiceOverRunning()) {
+ // Clamp the offset to at least -self.maximumHeight. Accessibility may attempt to scroll to
+ // a lesser offset than this to pull the flexible header into the center of the scrollview on
+ // focusing.
+ CGPoint offset = self.trackingScrollView.contentOffset;
+ offset.y = MAX(offset.y, -self.maximumHeight);
+ self.trackingScrollView.contentOffset = offset;
+ // Setting the transform on the same run loop as the accessibility scroll can cause additional
+ // incorrect scrolling as the scrollview attempts to resolve to a position that will place
+ // the header in the center of the scroll. Punting to the next loop prevents this.
+ dispatch_async(dispatch_get_main_queue(), ^{
+ self.transform =
+ CGAffineTransformMakeTranslation(0, self.trackingScrollView.contentOffset.y);
+ [self fhv_updateLayout];
+ });
+ } else {
+ self.transform = CGAffineTransformMakeTranslation(0, self.trackingScrollView.contentOffset.y);
+ }
}
// While the interface orientation is rotating we don't respond to any adjustments to the content

original_message:
[FlexibleHeader] Fix odd scrolling bugs in voiceover (#4485)

Prevent the flexible header view from over extending or jumping to incorrect scroll positions when focus swiping in voiceover. There should be no visual difference in either mode, and no functional difference with voice over disabled.


diff:
self.view.backgroundColor = self.colorScheme.backgroundColor;
}
-- (void)viewWillLayoutSubviews {
- [super viewWillLayoutSubviews];
+- (void)viewDidLayoutSubviews {
+ [super viewDidLayoutSubviews];
[self layoutBottomNavBar];
}

original_message: Fix safe area insets on bottom nav example (#4637)


diff:
@@ -654,17 +654,12 @@ static const CGFloat MDCDialogMessageOpacity = (CGFloat)0.54;
CGRect actionsScrollViewRect = CGRectZero;
actionsScrollViewRect.size = self.actionsScrollView.contentSize;
+ actionsScrollViewRect.origin.y = CGRectGetHeight(self.bounds) - actionsScrollViewRect.size.height;
const CGFloat requestedHeight =
self.contentScrollView.contentSize.height + self.actionsScrollView.contentSize.height;
- if (requestedHeight <= CGRectGetHeight(self.bounds)) {
- // Simple layout case : both content and actions fit on the screen at once.
- self.contentScrollView.frame = contentScrollViewRect;
-
- actionsScrollViewRect.origin.y =
- CGRectGetHeight(self.bounds) - actionsScrollViewRect.size.height;
- self.actionsScrollView.frame = actionsScrollViewRect;
- } else {
+ // Check the layout: do both content and actions fit on the screen at once?
+ if (requestedHeight > CGRectGetHeight(self.bounds)) {
// Complex layout case : Split the space between the two scrollviews.
if (CGRectGetHeight(contentScrollViewRect) < CGRectGetHeight(self.bounds) * (CGFloat)0.5) {
actionsScrollViewRect.size.height =
@@ -673,15 +668,13 @@ static const CGFloat MDCDialogMessageOpacity = (CGFloat)0.54;
CGFloat maxActionsHeight = CGRectGetHeight(self.bounds) * (CGFloat)0.5;
actionsScrollViewRect.size.height = MIN(maxActionsHeight, actionsScrollViewRect.size.height);
}
- actionsScrollViewRect.origin.y =
- CGRectGetHeight(self.bounds) - actionsScrollViewRect.size.height;
+ contentScrollViewRect.size.height = CGRectGetHeight(self.bounds) -
+ actionsScrollViewRect.size.height -
+ contentScrollViewRect.origin.y;
+ }
self.actionsScrollView.frame = actionsScrollViewRect;
-
- contentScrollViewRect.size.height =
- CGRectGetHeight(self.bounds) - actionsScrollViewRect.size.height;
self.contentScrollView.frame = contentScrollViewRect;
}
-}
#pragma mark - Dynamic Type

original_message:
Avoid code duplication for placing action and content scroll views in 'layoutSubviews' method of MDCAlerControllerView.

PiperOrigin-RevId: 291984194


diff:
@@ -130,6 +130,10 @@ static NSString *const kMaterialDialogsBundle = @"MaterialDialogs.bundle";
return self;
}
+- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
if (self.traitCollectionDidChangeBlock) {

diff:
@@ -97,10 +97,6 @@ static const CGFloat MDCDialogMessageOpacity = (CGFloat)0.54;
return self;
}
-- (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-}
-
- (NSString *)title {
return self.titleLabel.text;
}

original_message:
Ensure to remove correct notification observer for the style updates.

Looks like notification observers are added for MDCAlertController in mdc_setAdjustsFontForContentSizeCategory: method, but never removed.
On the other hand they seem to be removed for MDCAlertControllerView instead, which doesn't look to observe anything.

PiperOrigin-RevId: 292010203