diff --git a/CHANGELOG.md b/CHANGELOG.md index ee290989077..2035bf5cf9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,157 @@ +# 95.0.0 + +In this major release we deleted a bunch of APIs already marked deprecated in the Button Bar, + Button, Ink, Chip componnts. + +## Breaking changes + +### Button + +`MDCButton` removed `cornerRadius`. + +#### Chips + +We removed a bunch of themer classes and protocols that are not part of our latest theming offering. + +## New deprecations + +### Navigation Bar + +We deprecated the color themer in preperation of deleting it. Use theming instead. + +### Outlined Button + +We deprecated the color themer in preperation of deleting it. Use theming instead. + +### Text Button + +We deprecated the color themer in preperation of deleting it. Use theming instead. + +### Cards + +We deprecated the color themer in preperation of deleting it. Use theming instead. + +### Tab Bar + +We deprecated the color themer in preperation of deleting it. Use theming instead. + + +### Text Field + +We deprecated the color themer in preperation of deleting it. Use theming instead. + +### Thumb Track + +We deprecated the private thumbtrack component's `thumbMaxRippleRadius`. + +## API changes + +#### MDCButton + +*removed* property: `cornerRadius` in `MDCButton` + +#### Chips + +*removed* protocol: `MDCChipViewScheming`. Use Chips+Theming instead. + +*removed* class: `MDCChipViewThemer`. Use Chips+Theming instead. + +*removed* class: `MDCChipViewColorThemer`. Use Chips+Theming instead. + +*removed* class: `MDCChipViewFontThemer`. Use Chips+Theming instead. + +*removed* class: `MDCChipViewShapeThemer`. Use Chips+Theming instead. + +*removed* class: `MDCChipViewTypographyThemer`. Use Chips+Theming instead. + +#### Navigation Bar + +*deprecated* class: MDCBottomNavigationBarColorThemer. Use MaterialBottomNavigation+Theming instead. + +#### Outlined Button + +*deprecated* class: MDCOutlinedButtonColorThemer. Please use +[MDCButton applyOutlinedThemeWithScheme:] instead. (Note: Color theming is no longer available as an +independent API. + +#### Text Button + +*deprecated* class: MDCTextButtonColorThemer. Please use [MDCButton applyTextThemeWithScheme:] +instead. (Note: Color theming is no longer available as an independent API.)") + +#### Cards + +*deprecated* class: MDCCardsColorThemer. Please use MaterialCards+Theming instead. + +#### Tab Bar + +*deprecated* class: MDCTabBarFontThemer. Please use the theming extension instead. + +#### Text Field + +*deprecated* class: MDCTextFieldColorThemer. Please use the MaterialTextFields+Theming instead. + +#### Thumb Track + +*deprecated* property: `thumbMaxRippleRadius` in `MDCThumbTrack`. Opt-in to Ripple by setting +enableRippleBehavior to YES, and then use thumbRippleMaximumRadius instead. Learn more at +https://github.com/material-components/material-components-ios/tree/develop/components/Ink#migration-guide-ink-to-ripple + +## Component changes + +## Changes + +### Banner + +* [Add unit test to test background color change when user interface changes. (#9073)](https://github.com/material-components/material-components-ios/commit/8a2650d5c31cddd73f3ca497a8a9e5f64bb6bdb4) (Wenyu Zhang) +* [Implement UIAccessibilityContainer informal protocol to correct accessibility order. (#9116)](https://github.com/material-components/material-components-ios/commit/8a9a81a74811112de32c92215819dada5cd4672e) (Wenyu Zhang) +* [Post accessibility notification when Banner shows on the screen in examples. (#9111)](https://github.com/material-components/material-components-ios/commit/0fcef85a440e108745cdf74d1e698fd47563881c) (Wenyu Zhang) + +### BottomNavigation + +* [Deprecate MDCBottomNavigationBarColorThemer (#9126)](https://github.com/material-components/material-components-ios/commit/352a110b81ca1f8b562ad7d150715b7448d4e6e2) (Bryan Oltman) + +### ButtonBar + +* [delete-MDCButtonBarTypographyThemer (#9117)](https://github.com/material-components/material-components-ios/commit/7ece2c118751771fab24fbf27642e0066ef826cc) (Andrew Overton) + +### Buttons + +* [Delete MDCButton cornerRadius (#9121)](https://github.com/material-components/material-components-ios/commit/c0464f44da0a4c460f6fc28daef5f4b00f18295a) (Bryan Oltman) +* [Deprecate MDCOutlinedButtonColorThemer (#9048)](https://github.com/material-components/material-components-ios/commit/92ac86ec863564cfad5e618c8d17ca63f2ade3c7) (Galia Kaufman) +* [Deprecating MDCTextButtonColorThemer (#9049)](https://github.com/material-components/material-components-ios/commit/705dfd7788ba8f9ef03ca6d9cbeb2d2c7d56a63c) (Galia Kaufman) + +### Cards + +* [Deprecate MDCCardsColorThemer (#9078)](https://github.com/material-components/material-components-ios/commit/285c8898c094ed314b6b38cfe63f2f1bdb50232c) (Bryan Oltman) + +### Chips + +* [Move themer code to MDCChipView+MaterialTheming (#9110)](https://github.com/material-components/material-components-ios/commit/322d162c5ef3035f3447f51adc206aedb8ed995e) (Bryan Oltman) + +### Ink + +* [Delete deprecated MDCInkTouchControllerLegacyDelegate (#9077)](https://github.com/material-components/material-components-ios/commit/0aa91cca0a1cacdb11c327413f119c41a7e611dd) (Bryan Oltman) + +### Tabs + +* [Deprecate MDCTabbarFontThemer (#9114)](https://github.com/material-components/material-components-ios/commit/23ddfe27155f4eef619a8291ec8f38c14419cb39) (Andrew Overton) +* [Don't use MDCTabBarColorThemer in examples (#9125)](https://github.com/material-components/material-components-ios/commit/38840677fff750814bf31d4ac5ae15eb4d9f0882) (Andrew Overton) + +### TextFields + +* [Mark MDCTextFieldColorThemer as deprecated (#9076)](https://github.com/material-components/material-components-ios/commit/9adc054ce046bb5f938f229f32f62f63697923b6) (Bryan Oltman) + +### private/ThumbTrack + +* [deprecate-MDCThumbTrack-thumbMaxRippleRadius (#9120)](https://github.com/material-components/material-components-ios/commit/8e1dae7e3ec64ed08864eb3c3616499d4270a593) (Andrew Overton) + +## Multi-component changes + +* [Delete Themers (#9028)](https://github.com/material-components/material-components-ios/commit/f848eaf5eed5a242fc02b0a7b815541e11041979) (Bryan Oltman) + +--- + # 94.5.0 This minor release introduces new APIs to AppBar, FlexibleHeader and Dialogs. AppBar and diff --git a/MaterialComponents.podspec b/MaterialComponents.podspec index d1e453e80cd..0013191a790 100644 --- a/MaterialComponents.podspec +++ b/MaterialComponents.podspec @@ -2,7 +2,7 @@ load 'scripts/generated/icons.rb' Pod::Spec.new do |mdc| mdc.name = "MaterialComponents" - mdc.version = "94.5.0" + mdc.version = "95.0.0" mdc.authors = "The Material Components authors." mdc.summary = "A collection of stand-alone production-ready UI libraries focused on design details." mdc.homepage = "https://github.com/material-components/material-components-ios" @@ -260,6 +260,8 @@ Pod::Spec.new do |mdc| "components/#{extension.base_name.split('+')[0]}/tests/unit/#{extension.base_name.split('+')[1]}/*.{h,m,swift}" ] unit_tests.dependency "MaterialComponents/schemes/Container" + unit_tests.dependency "MaterialComponents/private/Color" + unit_tests.dependency "MaterialComponents/private/Math" end end @@ -575,7 +577,6 @@ Pod::Spec.new do |mdc| "components/#{component.base_name}/tests/unit/supplemental/*.{h,m,swift}" ] unit_tests.resources = "components/#{component.base_name}/tests/unit/resources/*" - unit_tests.dependency "MaterialComponents/ButtonBar+TypographyThemer" end end @@ -592,21 +593,6 @@ Pod::Spec.new do |mdc| extension.dependency "MaterialComponents/Themes" end - # ButtonBar is not intended to be themed as a standalone component. - # Please theme it via the AppBar component's Theming extension instead. - mdc.subspec "ButtonBar+TypographyThemer" do |extension| - extension.ios.deployment_target = '9.0' - extension.public_header_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h" - ] - extension.source_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.{h,m}" - ] - - extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}" - extension.dependency "MaterialComponents/schemes/Typography" - end - # Cards mdc.subspec "Cards" do |component| @@ -723,79 +709,10 @@ Pod::Spec.new do |mdc| "components/#{component.base_name}/tests/unit/supplemental/*.{h,m,swift}" ] unit_tests.resources = "components/#{component.base_name}/tests/unit/resources/*" - unit_tests.dependency "MaterialComponents/Chips+ChipThemer" - unit_tests.dependency "MaterialComponents/Chips+FontThemer" unit_tests.dependency "MaterialComponents/Themes" end end - mdc.subspec "Chips+ChipThemer" do |extension| - extension.ios.deployment_target = '9.0' - extension.public_header_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h" - ] - extension.source_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.{h,m}" - ] - - extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}" - extension.dependency "MaterialComponents/Chips+ColorThemer" - extension.dependency "MaterialComponents/Chips+ShapeThemer" - extension.dependency "MaterialComponents/Chips+TypographyThemer" - end - - mdc.subspec "Chips+ColorThemer" do |extension| - extension.ios.deployment_target = '9.0' - extension.public_header_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h" - ] - extension.source_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.{h,m}" - ] - - extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}" - extension.dependency "MaterialComponents/schemes/Color" - end - - mdc.subspec "Chips+FontThemer" do |extension| - extension.ios.deployment_target = '9.0' - extension.public_header_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h" - ] - extension.source_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.{h,m}" - ] - - extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}" - extension.dependency "MaterialComponents/Themes" - end - - mdc.subspec "Chips+ShapeThemer" do |extension| - extension.ios.deployment_target = '9.0' - extension.public_header_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h" - ] - extension.source_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.{h,m}" - ] - - extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}" - extension.dependency "MaterialComponents/schemes/Shape" - end - - mdc.subspec "Chips+TypographyThemer" do |extension| - extension.ios.deployment_target = '9.0' - extension.public_header_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h" - ] - extension.source_files = [ - "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.{h,m}" - ] - - extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}" - extension.dependency "MaterialComponents/schemes/Typography" - end - mdc.subspec "Chips+Theming" do |extension| extension.ios.deployment_target = '9.0' extension.public_header_files = "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/*.h" @@ -804,8 +721,6 @@ Pod::Spec.new do |mdc| "components/#{extension.base_name.split('+')[0]}/src/#{extension.base_name.split('+')[1]}/private/*.{h,m}" ] extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}" - extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}+ColorThemer" - extension.dependency "MaterialComponents/#{extension.base_name.split('+')[0]}+ShapeThemer" extension.dependency "MaterialComponents/schemes/Container" extension.dependency "MaterialComponents/Typography" diff --git a/MaterialComponentsBeta.podspec b/MaterialComponentsBeta.podspec index da51bca5989..14273bee319 100644 --- a/MaterialComponentsBeta.podspec +++ b/MaterialComponentsBeta.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |mdc| mdc.name = "MaterialComponentsBeta" - mdc.version = "94.5.0" + mdc.version = "95.0.0" mdc.authors = "The Material Components authors." mdc.summary = "A collection of stand-alone alpha UI libraries that are not yet guaranteed to be ready for general production use. Use with caution." mdc.homepage = "https://github.com/material-components/material-components-ios" diff --git a/MaterialComponentsEarlGreyTests.podspec b/MaterialComponentsEarlGreyTests.podspec index 5fa0728c3e4..421eaa76680 100644 --- a/MaterialComponentsEarlGreyTests.podspec +++ b/MaterialComponentsEarlGreyTests.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MaterialComponentsEarlGreyTests" - s.version = "94.5.0" + s.version = "95.0.0" s.authors = "The Material Components authors." s.summary = "This spec is an aggregate of all the Material Components EarlGrey tests." s.description = "This spec is made for use in the MDC Catalog." diff --git a/MaterialComponentsExamples.podspec b/MaterialComponentsExamples.podspec index 3da43cf6338..6a51363046b 100644 --- a/MaterialComponentsExamples.podspec +++ b/MaterialComponentsExamples.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MaterialComponentsExamples" - s.version = "94.5.0" + s.version = "95.0.0" s.authors = "The Material Components authors." s.summary = "This spec is an aggregate of all the Material Components examples." s.description = "This spec is made for use in the MDC Catalog. Used in conjunction with CatalogByConvention we create our Material Catalog." diff --git a/MaterialComponentsSnapshotTests.podspec b/MaterialComponentsSnapshotTests.podspec index 603ae12234a..08ee999876d 100644 --- a/MaterialComponentsSnapshotTests.podspec +++ b/MaterialComponentsSnapshotTests.podspec @@ -53,7 +53,7 @@ end Pod::Spec.new do |s| s.name = "MaterialComponentsSnapshotTests" - s.version = "94.5.0" + s.version = "95.0.0" s.authors = "The Material Components authors." s.summary = "This spec is an aggregate of all the Material Components snapshot tests." s.homepage = "https://github.com/material-components/material-components-ios" diff --git a/VERSION b/VERSION index ccd6b46ed35..8842e8c6c4c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -94.5.0 +95.0.0 diff --git a/catalog/MDCCatalog/Info.plist b/catalog/MDCCatalog/Info.plist index c0bb57f5f53..aa099aa6621 100644 --- a/catalog/MDCCatalog/Info.plist +++ b/catalog/MDCCatalog/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 94.5.0 + 95.0.0 CFBundleSignature ???? CFBundleVersion - 94.5.0 + 95.0.0 LSRequiresIPhoneOS UIAppFonts diff --git a/catalog/MDCDragons/Info.plist b/catalog/MDCDragons/Info.plist index 2f3937771f9..bb7ec40e728 100644 --- a/catalog/MDCDragons/Info.plist +++ b/catalog/MDCDragons/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 94.5.0 + 95.0.0 CFBundleVersion - 94.5.0 + 95.0.0 LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/catalog/MaterialCatalog/MaterialCatalog.podspec b/catalog/MaterialCatalog/MaterialCatalog.podspec index 31fa2353297..01cbf50fde6 100644 --- a/catalog/MaterialCatalog/MaterialCatalog.podspec +++ b/catalog/MaterialCatalog/MaterialCatalog.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MaterialCatalog" - s.version = "94.5.0" + s.version = "95.0.0" s.summary = "Helper Objective-C classes for the MDC catalog." s.description = "This spec is made for use in the MDC Catalog." s.homepage = "https://github.com/material-components/material-components-ios" diff --git a/components/Banner/BUILD b/components/Banner/BUILD index 64f530a0813..73b41834b8b 100644 --- a/components/Banner/BUILD +++ b/components/Banner/BUILD @@ -85,6 +85,8 @@ mdc_unit_test_objc_library( ":Banner", ":Theming", "//components/Buttons", + "//components/private/Color", + "//components/private/Math", "//components/Typography", ], ) diff --git a/components/Banner/examples/AppBarBannerExample.m b/components/Banner/examples/AppBarBannerExample.m index 57825e70fe6..4028a0eec25 100644 --- a/components/Banner/examples/AppBarBannerExample.m +++ b/components/Banner/examples/AppBarBannerExample.m @@ -92,6 +92,8 @@ - (void)showBanner { forControlEvents:UIControlEventTouchUpInside]; self.banner.trailingButton.hidden = YES; self.appBarViewController.headerStackView.bottomBar = self.banner; + + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.banner); } @end diff --git a/components/Banner/examples/BannerAutolayoutExampleViewController.m b/components/Banner/examples/BannerAutolayoutExampleViewController.m index b042f0721e3..536708fe6cb 100644 --- a/components/Banner/examples/BannerAutolayoutExampleViewController.m +++ b/components/Banner/examples/BannerAutolayoutExampleViewController.m @@ -88,6 +88,7 @@ - (void)viewDidLoad { - (void)didTapButton { self.bannerView.hidden = NO; + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.bannerView); } - (void)didTapDismissOnBannerView { diff --git a/components/Banner/examples/BannerTypicalUseExampleViewController.m b/components/Banner/examples/BannerTypicalUseExampleViewController.m index 8c26f49a27e..068af532835 100644 --- a/components/Banner/examples/BannerTypicalUseExampleViewController.m +++ b/components/Banner/examples/BannerTypicalUseExampleViewController.m @@ -271,8 +271,7 @@ - (void)showSingleLineStyleBanner { margins.left = exampleBannerContentPadding; margins.right = exampleBannerContentPadding; bannerView.layoutMargins = margins; - [self.view addSubview:bannerView]; - self.bannerView = bannerView; + [self addBannerView:bannerView]; MDCButton *button = bannerView.leadingButton; [button applyTextThemeWithScheme:self.containerScheme]; @@ -310,8 +309,7 @@ - (void)showMultiLineAlignedButtonStyleBanner { margins.right = exampleBannerContentPadding; bannerView.layoutMargins = margins; bannerView.imageView.hidden = YES; - [self.view addSubview:bannerView]; - self.bannerView = bannerView; + [self addBannerView:bannerView]; MDCButton *dismissButton = bannerView.leadingButton; [dismissButton applyTextThemeWithScheme:self.containerScheme]; @@ -351,8 +349,7 @@ - (void)showMultiLineStackedButtonStyleBanner { margins.right = exampleBannerContentPadding; bannerView.layoutMargins = margins; bannerView.imageView.hidden = YES; - [self.view addSubview:bannerView]; - self.bannerView = bannerView; + [self addBannerView:bannerView]; MDCButton *dismissButton = bannerView.leadingButton; [dismissButton setTitle:@"Dismiss" forState:UIControlStateNormal]; @@ -392,8 +389,7 @@ - (void)showSingleLineLongTextStyleBanner { margins.left = exampleBannerContentPadding; margins.right = exampleBannerContentPadding; bannerView.layoutMargins = margins; - [self.view addSubview:bannerView]; - self.bannerView = bannerView; + [self addBannerView:bannerView]; MDCButton *button = bannerView.leadingButton; [button applyTextThemeWithScheme:self.containerScheme]; @@ -418,8 +414,7 @@ - (void)showMultilineLongTextStyleBanner { margins.left = exampleBannerContentPadding; margins.right = exampleBannerContentPadding; bannerView.layoutMargins = margins; - [self.view addSubview:bannerView]; - self.bannerView = bannerView; + [self addBannerView:bannerView]; MDCButton *button = bannerView.leadingButton; [button applyTextThemeWithScheme:self.containerScheme]; @@ -457,8 +452,7 @@ - (void)showMultilineLongAttributedTextStyleBanner { margins.left = exampleBannerContentPadding; margins.right = exampleBannerContentPadding; bannerView.layoutMargins = margins; - [self.view addSubview:bannerView]; - self.bannerView = bannerView; + [self addBannerView:bannerView]; MDCButton *button = bannerView.leadingButton; [button applyTextThemeWithScheme:self.containerScheme]; @@ -484,8 +478,7 @@ - (void)showExtraLongTextStyleBanner { margins.left = exampleBannerContentPadding; margins.right = exampleBannerContentPadding; bannerView.layoutMargins = margins; - [self.view addSubview:bannerView]; - self.bannerView = bannerView; + [self addBannerView:bannerView]; MDCButton *button = bannerView.leadingButton; [button applyTextThemeWithScheme:self.containerScheme]; @@ -499,6 +492,12 @@ - (void)showExtraLongTextStyleBanner { forControlEvents:UIControlEventTouchUpInside]; } +- (void)addBannerView:(MDCBannerView *)bannerView { + [self.view addSubview:bannerView]; + self.bannerView = bannerView; + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.bannerView); +} + - (void)dismissBanner { [self.bannerView removeFromSuperview]; } diff --git a/components/Banner/src/MDCBannerView.m b/components/Banner/src/MDCBannerView.m index d8d8f4ef956..b34f03a66b8 100644 --- a/components/Banner/src/MDCBannerView.m +++ b/components/Banner/src/MDCBannerView.m @@ -636,4 +636,10 @@ - (void)updateTextFont { } } +#pragma mark - Accessibility + +- (NSArray *)accessibilityElements { + return @[ self.textView, self.leadingButton, self.trailingButton ]; +} + @end diff --git a/components/Banner/tests/unit/Theming/MDCBannerViewThemingTests.m b/components/Banner/tests/unit/Theming/MDCBannerViewThemingTests.m index 899f3b3047a..8463be3c951 100644 --- a/components/Banner/tests/unit/Theming/MDCBannerViewThemingTests.m +++ b/components/Banner/tests/unit/Theming/MDCBannerViewThemingTests.m @@ -17,6 +17,8 @@ #import "MaterialBanner+Theming.h" #import "MaterialBanner.h" #import "MaterialContainerScheme.h" +#import "MaterialMath.h" +#import "UIColor+MaterialDynamic.h" // The opacity value applied to text view. static CGFloat const kTextViewOpacity = (CGFloat)0.87; @@ -88,6 +90,7 @@ - (void)tearDown { [super tearDown]; } + - (void)testThemingWithDefaultValues { // When [self.bannerView applyThemeWithScheme:self.containerScheme]; @@ -205,6 +208,31 @@ - (void)testFontsAreScaledWhenTypographySchemeRequestsPrescaling { } } +- (void)testBannerViewBackgroundColorChangeWhenUIUserInterfaceStyleChangesOnIOS13 { +#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0) + if (@available(iOS 13.0, *)) { + // Given + UIColor *darkSurfaceColor = UIColor.blackColor; + UIColor *lightSurfaceColor = UIColor.whiteColor; + + UIColor *dynamicSurfaceColor = [UIColor colorWithUserInterfaceStyleDarkColor:darkSurfaceColor + defaultColor:lightSurfaceColor]; + self.containerScheme.colorScheme.surfaceColor = dynamicSurfaceColor; + self.containerScheme.colorScheme.elevationOverlayEnabledForDarkMode = YES; + + // When + [self.bannerView applyThemeWithScheme:self.containerScheme]; + UITraitCollection *previousTraitCollection = [self.bannerView.traitCollection copy]; + self.bannerView.overrideUserInterfaceStyle = UIUserInterfaceStyleDark; + [self.bannerView traitCollectionDidChange:previousTraitCollection]; + + // Then + XCTAssertTrue([self compareColorsWithFloatPrecisionFirstColor:self.bannerView.backgroundColor + secondColor:darkSurfaceColor]); + } +#endif +} + - (void)assertTraitCollectionAndElevationBlockForBannerView:(MDCBannerView *)bannerView colorScheme:(id)colorScheme { if (colorScheme.elevationOverlayEnabledForDarkMode) { @@ -216,4 +244,17 @@ - (void)assertTraitCollectionAndElevationBlockForBannerView:(MDCBannerView *)ban } } +// TODO(https://github.com/material-components/material-components-ios/issues/8532): Replace the +// usage of this method with generic macro when available. +- (BOOL)compareColorsWithFloatPrecisionFirstColor:(UIColor *)firstColor + secondColor:(UIColor *)secondColor { + CGFloat fRed = 0.0, fGreen = 0.0, fBlue = 0.0, fAlpha = 0.0; + [firstColor getRed:&fRed green:&fGreen blue:&fBlue alpha:&fAlpha]; + CGFloat sRed = 0.0, sGreen = 0.0, sBlue = 0.0, sAlpha = 0.0; + [secondColor getRed:&sRed green:&sGreen blue:&sBlue alpha:&sAlpha]; + + return (MDCCGFloatEqual(fRed, sRed) && MDCCGFloatEqual(fGreen, sGreen) && + MDCCGFloatEqual(fBlue, sBlue) && MDCCGFloatEqual(fAlpha, sAlpha)); +} + @end diff --git a/components/BottomNavigation/examples/BottomNavigationBlurExample.m b/components/BottomNavigation/examples/BottomNavigationBlurExample.m index 940d42f84b7..e74985ef847 100644 --- a/components/BottomNavigation/examples/BottomNavigationBlurExample.m +++ b/components/BottomNavigation/examples/BottomNavigationBlurExample.m @@ -97,8 +97,11 @@ - (void)configureBlurToggleButton { - (void)applyTheming { [MDCBottomNavigationBarTypographyThemer applyTypographyScheme:self.typographyScheme toBottomNavigationBar:self.bottomNavBar]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [MDCBottomNavigationBarColorThemer applySemanticColorScheme:self.colorScheme toBottomNavigation:self.bottomNavBar]; +#pragma clang diagnostic pop self.bottomNavBar.barTintColor = [self.bottomNavBar.barTintColor colorWithAlphaComponent:(CGFloat)0.85]; self.view.backgroundColor = self.colorScheme.backgroundColor; diff --git a/components/BottomNavigation/examples/BottomNavigationTypicalUseExample.m b/components/BottomNavigation/examples/BottomNavigationTypicalUseExample.m index ecc3e645863..c856bbf1a6c 100644 --- a/components/BottomNavigation/examples/BottomNavigationTypicalUseExample.m +++ b/components/BottomNavigation/examples/BottomNavigationTypicalUseExample.m @@ -115,8 +115,11 @@ - (void)viewDidLoad { [MDCBottomNavigationBarTypographyThemer applyTypographyScheme:self.typographyScheme toBottomNavigationBar:self.bottomNavBar]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [MDCBottomNavigationBarColorThemer applySemanticColorScheme:self.colorScheme toBottomNavigation:self.bottomNavBar]; +#pragma clang diagnostic pop self.view.backgroundColor = self.colorScheme.backgroundColor; } diff --git a/components/BottomNavigation/src/ColorThemer/MDCBottomNavigationBarColorThemer.h b/components/BottomNavigation/src/ColorThemer/MDCBottomNavigationBarColorThemer.h index eeb8f3b5c67..dc96d507b72 100644 --- a/components/BottomNavigation/src/ColorThemer/MDCBottomNavigationBarColorThemer.h +++ b/components/BottomNavigation/src/ColorThemer/MDCBottomNavigationBarColorThemer.h @@ -17,15 +17,9 @@ /** The Material Design color system's themer for instances of MDCBottomNavigationBar. - - @warning This API will eventually be deprecated. There is no replacement yet. - Track progress here: https://github.com/material-components/material-components-ios/issues/7172 - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions */ -@interface MDCBottomNavigationBarColorThemer : NSObject -@end - -@interface MDCBottomNavigationBarColorThemer (ToBeDeprecated) +__deprecated_msg("Please use MaterialBottomNavigation+Theming instead.") + @interface MDCBottomNavigationBarColorThemer : NSObject /** Applies a color scheme's properties to an MDCBottomNavigationBar. diff --git a/components/ButtonBar/BUILD b/components/ButtonBar/BUILD index 33a94f3955f..bf435e8e354 100644 --- a/components/ButtonBar/BUILD +++ b/components/ButtonBar/BUILD @@ -117,15 +117,3 @@ mdc_snapshot_test( name = "snapshot_tests", deps = [":snapshot_test_lib"], ) - -# Deprecated - -mdc_extension_objc_library( - name = "TypographyThemer", - deprecation = "ButtonBar is not intended to be themed as a standalone component." + - " Please theme it via the AppBar component's Theming extension instead.", - deps = [ - ":ButtonBar", - "//components/schemes/Typography", - ], -) diff --git a/components/ButtonBar/src/TypographyThemer/MDCButtonBarTypographyThemer.h b/components/ButtonBar/src/TypographyThemer/MDCButtonBarTypographyThemer.h deleted file mode 100644 index 31e3aa5380d..00000000000 --- a/components/ButtonBar/src/TypographyThemer/MDCButtonBarTypographyThemer.h +++ /dev/null @@ -1,44 +0,0 @@ -// 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 "MaterialButtonBar.h" -#import "MaterialTypographyScheme.h" - -/** - The Material Design typography system's themer for instances of MDCButtonBar. - - @warning This API will eventually be deprecated. The replacement API is: - `MDCButtonBar`'s `-applyPrimaryThemeWithScheme:` - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -__deprecated_msg("ButtonBar is not intended to be themed as a standalone component." - " Please theme it via the AppBar component's Theming extension instead.") - @interface MDCButtonBarTypographyThemer : NSObject - -/** - Applies a typography scheme's properties to an MDCButtonBar. - - @param typographyScheme The typography scheme to apply to the component instance. - @param buttonBar A component instance to which the typography scheme should be applied. - - @warning This API will eventually be deprecated. The replacement API is: - `MDCButtonBar`'s `-applyPrimaryThemeWithScheme:` - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applyTypographyScheme:(nonnull id)typographyScheme - toButtonBar:(nonnull MDCButtonBar *)buttonBar - __deprecated_msg("ButtonBar is not intended to be themed as a standalone component." - " Please theme it via the AppBar component's Theming extension instead."); - -@end diff --git a/components/ButtonBar/src/TypographyThemer/MDCButtonBarTypographyThemer.m b/components/ButtonBar/src/TypographyThemer/MDCButtonBarTypographyThemer.m deleted file mode 100644 index ba352e66ce8..00000000000 --- a/components/ButtonBar/src/TypographyThemer/MDCButtonBarTypographyThemer.m +++ /dev/null @@ -1,32 +0,0 @@ -// 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 "MDCButtonBarTypographyThemer.h" - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -@implementation MDCButtonBarTypographyThemer -#pragma clang diagnostic pop - -+ (void)applyTypographyScheme:(nonnull id)typographyScheme - toButtonBar:(nonnull MDCButtonBar *)buttonBar { - NSUInteger maximumStateValue = UIControlStateNormal | UIControlStateSelected | - UIControlStateHighlighted | UIControlStateDisabled; - for (NSUInteger state = 0; state <= maximumStateValue; ++state) { - [buttonBar setButtonsTitleFont:nil forState:state]; - } - [buttonBar setButtonsTitleFont:typographyScheme.button forState:UIControlStateNormal]; -} - -@end diff --git a/components/ButtonBar/src/TypographyThemer/MaterialButtonBar+TypographyThemer.h b/components/ButtonBar/src/TypographyThemer/MaterialButtonBar+TypographyThemer.h deleted file mode 100644 index 62ee8aa61e2..00000000000 --- a/components/ButtonBar/src/TypographyThemer/MaterialButtonBar+TypographyThemer.h +++ /dev/null @@ -1,15 +0,0 @@ -// 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 "MDCButtonBarTypographyThemer.h" diff --git a/components/Buttons/src/ColorThemer/MDCOutlinedButtonColorThemer.h b/components/Buttons/src/ColorThemer/MDCOutlinedButtonColorThemer.h index 97491d5d9fd..45c9dbc02a2 100644 --- a/components/Buttons/src/ColorThemer/MDCOutlinedButtonColorThemer.h +++ b/components/Buttons/src/ColorThemer/MDCOutlinedButtonColorThemer.h @@ -22,10 +22,9 @@ `MDCButton`'s `-applyOutlinedThemeWithScheme:` Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions */ -@interface MDCOutlinedButtonColorThemer : NSObject -@end - -@interface MDCOutlinedButtonColorThemer (ToBeDeprecated) +__deprecated_msg("Please use [MDCButton applyOutlinedThemeWithScheme:] instead. (Note: Color " + "theming is no longer available as an independent API.") + @interface MDCOutlinedButtonColorThemer : NSObject /** Applies a color scheme's properties to an MDCButton using the outlined button style. diff --git a/components/Buttons/src/ColorThemer/MDCTextButtonColorThemer.h b/components/Buttons/src/ColorThemer/MDCTextButtonColorThemer.h index 010d3f90635..d1136dd7ddf 100644 --- a/components/Buttons/src/ColorThemer/MDCTextButtonColorThemer.h +++ b/components/Buttons/src/ColorThemer/MDCTextButtonColorThemer.h @@ -24,10 +24,9 @@ `MDCButton`'s `-applyTextThemeWithScheme:` Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions */ -@interface MDCTextButtonColorThemer : NSObject -@end - -@interface MDCTextButtonColorThemer (ToBeDeprecated) +__deprecated_msg("Please use [MDCButton applyTextThemeWithScheme:] instead. (Note: Color theming " + "is no longer available as an independent API.)") + @interface MDCTextButtonColorThemer : NSObject /** Applies a color scheme's properties to an MDCButton using the text button style. diff --git a/components/Buttons/src/MDCButton.m b/components/Buttons/src/MDCButton.m index 52870d80bec..96bb3ee3856 100644 --- a/components/Buttons/src/MDCButton.m +++ b/components/Buttons/src/MDCButton.m @@ -258,12 +258,6 @@ - (void)layoutSubviews { if (!self.layer.shapeGenerator) { self.layer.shadowPath = [self boundingPath].CGPath; } - if ([self respondsToSelector:@selector(cornerRadius)]) { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - self.layer.cornerRadius = [self cornerRadius]; -#pragma clang diagnostic pop - } // Center unbounded ink view frame taking into account possible insets using contentRectForBounds. if (_inkView.inkStyle == MDCInkStyleUnbounded && _inkView.usesLegacyInkRipple) { @@ -853,15 +847,7 @@ - (void)evaporateInkToPoint:(CGPoint)toPoint { } - (UIBezierPath *)boundingPath { - CGFloat cornerRadius = self.layer.cornerRadius; - - if ([self respondsToSelector:@selector(cornerRadius)]) { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - cornerRadius = [self cornerRadius]; -#pragma clang diagnostic pop - } - return [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:cornerRadius]; + return [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:self.layer.cornerRadius]; } - (UIEdgeInsets)defaultContentEdgeInsets { diff --git a/components/Buttons/src/Theming/MDCButton+MaterialTheming.m b/components/Buttons/src/Theming/MDCButton+MaterialTheming.m index 7f6865fb411..28057d5ba5a 100644 --- a/components/Buttons/src/Theming/MDCButton+MaterialTheming.m +++ b/components/Buttons/src/Theming/MDCButton+MaterialTheming.m @@ -140,7 +140,18 @@ - (void)applyTextThemeWithScheme:(nonnull id)scheme { } - (void)applyTextThemeWithColorScheme:(id)colorScheme { - [MDCTextButtonColorThemer applySemanticColorScheme:colorScheme toButton:self]; + [self resetUIControlStatesForButtonTheming]; + + [self setBackgroundColor:UIColor.clearColor forState:UIControlStateNormal]; + [self setBackgroundColor:UIColor.clearColor forState:UIControlStateDisabled]; + [self setTitleColor:colorScheme.primaryColor forState:UIControlStateNormal]; + [self setTitleColor:[colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.38] + forState:UIControlStateDisabled]; + [self setImageTintColor:colorScheme.primaryColor forState:UIControlStateNormal]; + [self setImageTintColor:[colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.38] + forState:UIControlStateDisabled]; + self.disabledAlpha = 1; + self.inkColor = [colorScheme.primaryColor colorWithAlphaComponent:(CGFloat)0.16]; } - (void)applyTextThemeWithTypographyScheme:(id)typographyScheme { @@ -177,4 +188,13 @@ - (void)resetButtonColorsForAllStates { } } +- (void)resetUIControlStatesForButtonTheming { + NSUInteger maximumStateValue = UIControlStateNormal | UIControlStateSelected | + UIControlStateHighlighted | UIControlStateDisabled; + for (NSUInteger state = 0; state <= maximumStateValue; ++state) { + [self setBackgroundColor:nil forState:state]; + [self setTitleColor:nil forState:state]; + } +} + @end diff --git a/components/Buttons/src/private/MDCButton+Subclassing.h b/components/Buttons/src/private/MDCButton+Subclassing.h index a386ede5e82..7bfbfe600b8 100644 --- a/components/Buttons/src/private/MDCButton+Subclassing.h +++ b/components/Buttons/src/private/MDCButton+Subclassing.h @@ -37,12 +37,6 @@ /** The bounding path of the button. The shadow will follow that path. */ - (nonnull UIBezierPath *)boundingPath; -/** - Previously used to set the corner radius of the button. This has been deprecated and the layer's - |cornerRadius| property should be set directly. - */ -- (CGFloat)cornerRadius __deprecated_msg("Set layer.cornerRadius explicitly"); - /** The default content edge insets of the button. They are set at initialization time. */ - (UIEdgeInsets)defaultContentEdgeInsets; diff --git a/components/Cards/src/ColorThemer/MDCCardsColorThemer.h b/components/Cards/src/ColorThemer/MDCCardsColorThemer.h index ae7c827ae74..928197e4d49 100644 --- a/components/Cards/src/ColorThemer/MDCCardsColorThemer.h +++ b/components/Cards/src/ColorThemer/MDCCardsColorThemer.h @@ -19,15 +19,9 @@ /** The Material Design color system's themer for instances of MDCCard and MDCCardCollectionCell. - - @warning This API will eventually be deprecated. See the individual method documentation for - details on replacement APIs. - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions */ -@interface MDCCardsColorThemer : NSObject -@end - -@interface MDCCardsColorThemer (ToBeDeprecated) +__deprecated_msg("Please use MaterialCards+Theming instead.") @interface MDCCardsColorThemer + : NSObject /** Applies a color scheme's properties to an MDCCard. diff --git a/components/Chips/BUILD b/components/Chips/BUILD index dd6f1a62347..6076b18a08b 100644 --- a/components/Chips/BUILD +++ b/components/Chips/BUILD @@ -55,23 +55,11 @@ mdc_extension_objc_library( name = "Theming", deps = [ ":Chips", - ":ColorThemer", - ":ShapeThemer", "//components/Typography", "//components/schemes/Container", ], ) -mdc_extension_objc_library( - name = "ChipThemer", - deps = [ - ":Chips", - ":ColorThemer", - ":ShapeThemer", - ":TypographyThemer", - ], -) - mdc_objc_library( name = "privateHeaders", testonly = 1, @@ -80,46 +68,11 @@ mdc_objc_library( deps = [":Chips"], ) -mdc_extension_objc_library( - name = "FontThemer", - deps = [ - ":Chips", - "//components/Themes", - ], -) - -mdc_extension_objc_library( - name = "ColorThemer", - deps = [ - ":Chips", - "//components/schemes/Color", - ], -) - -mdc_extension_objc_library( - name = "ShapeThemer", - deps = [ - ":Chips", - "//components/schemes/Shape", - ], -) - -mdc_extension_objc_library( - name = "TypographyThemer", - deps = [ - ":Chips", - "//components/Typography", - "//components/schemes/Typography", - ], -) - mdc_examples_objc_library( name = "ObjcExamples", deps = [ ":Chips", - ":ShapeThemer", ":Theming", - ":TypographyThemer", "//components/ShapeLibrary", "//components/Shapes", "//components/Slider", @@ -159,12 +112,7 @@ mdc_unit_test_swift_library( mdc_unit_test_objc_library( name = "unit_test_sources", deps = [ - ":ChipThemer", ":Chips", - ":ColorThemer", - ":FontThemer", - ":ShapeThemer", - ":TypographyThemer", ":privateHeaders", "//components/ShapeLibrary", "//components/TextFields:private", diff --git a/components/Chips/src/ChipThemer/MDCChipViewScheme.h b/components/Chips/src/ChipThemer/MDCChipViewScheme.h deleted file mode 100644 index 0fe422fad56..00000000000 --- a/components/Chips/src/ChipThemer/MDCChipViewScheme.h +++ /dev/null @@ -1,83 +0,0 @@ -// 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 "MaterialShapeScheme.h" -#import "MaterialTypographyScheme.h" - -#import - -/** - 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. - - @warning This API is deprecated. The replacement API is: `MDCContainerScheming`. - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -__deprecated_msg("Use Chips+Theming instead.") @protocol MDCChipViewScheming - -/** - The color scheme to apply to a chip view. - */ -@property(nonnull, readonly, nonatomic) id colorScheme; - -/** - The shape scheme to apply to a chip view. - */ -@property(nonnull, readonly, nonatomic) id shapeScheme; - -/** - The typography scheme to apply to a chip view. - */ -@property(nonnull, readonly, nonatomic) id typographyScheme; - -@end - -/** - An MDCChipViewScheme is a mutable representation of the design parameters for an MDCChipView. - - @warning This API is deprecated. The replacement API is: `MDCContainerScheme`. - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -__deprecated_msg("Use Chips+Theming instead.") @interface MDCChipViewScheme - : NSObject - -/** - A mutable representation of a color scheme. - - By default, this is initialized with the latest color scheme defaults. - */ -@property(nonnull, readwrite, nonatomic) id colorScheme __deprecated_msg( - "Use Chips+Theming instead."); - -/** - A mutable representation of a shape scheme. - - By default, this is initialized with the latest shape scheme defaults. - */ -@property(nonnull, readwrite, nonatomic) id shapeScheme __deprecated_msg( - "Use Chips+Theming instead."); - -/** - A mutable representation of a typography scheme. - - By default, this is initialized with the latest typography scheme defaults. - */ -@property(nonnull, readwrite, nonatomic) id typographyScheme - __deprecated_msg("Use Chips+Theming instead."); - -@end diff --git a/components/Chips/src/ChipThemer/MDCChipViewScheme.m b/components/Chips/src/ChipThemer/MDCChipViewScheme.m deleted file mode 100644 index a38194d3587..00000000000 --- a/components/Chips/src/ChipThemer/MDCChipViewScheme.m +++ /dev/null @@ -1,29 +0,0 @@ -// 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] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; - _shapeScheme = [[MDCShapeScheme alloc] init]; - _typographyScheme = [[MDCTypographyScheme alloc] init]; - } - return self; -} -@end diff --git a/components/Chips/src/ChipThemer/MDCChipViewThemer.h b/components/Chips/src/ChipThemer/MDCChipViewThemer.h deleted file mode 100644 index be416c903cf..00000000000 --- a/components/Chips/src/ChipThemer/MDCChipViewThemer.h +++ /dev/null @@ -1,56 +0,0 @@ -// 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 - -/** - The Material Design themer for instances of MDCChipView. - - @warning This API is deprecated. Learn more at - + docs/theming.md#migration-guide-themers-to-theming-extensions - */ -__deprecated_msg("Use Chips+Theming instead.") @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. - - @warning This API is deprecated. The replacement API is: - `MDCChipView`'s `-applyThemeWithScheme:` - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applyScheme:(nonnull id)scheme - toChipView:(nonnull MDCChipView *)chip __deprecated_msg("Use Chips+Theming instead."); - -/** - 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. - - @warning This API is deprecated. The replacement API is: - `MDCChipView`'s `-applyOutlinedThemeWithScheme:` - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applyOutlinedVariantWithScheme:(nonnull id)scheme - toChipView:(nonnull MDCChipView *)chip - __deprecated_msg("Use Chips+Theming instead."); - -@end diff --git a/components/Chips/src/ChipThemer/MDCChipViewThemer.m b/components/Chips/src/ChipThemer/MDCChipViewThemer.m deleted file mode 100644 index df98dbd7179..00000000000 --- a/components/Chips/src/ChipThemer/MDCChipViewThemer.m +++ /dev/null @@ -1,46 +0,0 @@ -// 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+ShapeThemer.h" -#import "MaterialChips+TypographyThemer.h" - -@implementation MDCChipViewThemer - -+ (void)applyScheme:(nonnull id)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]; - [MDCChipViewShapeThemer applyShapeScheme:scheme.shapeScheme toChipView:chip]; - [MDCChipViewTypographyThemer applyTypographyScheme:scheme.typographyScheme toChipView:chip]; -} - -+ (void)applyOutlinedVariantWithScheme:(nonnull id)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]; - [MDCChipViewShapeThemer applyShapeScheme:scheme.shapeScheme toChipView:chip]; - [MDCChipViewTypographyThemer applyTypographyScheme:scheme.typographyScheme toChipView:chip]; -} - -@end diff --git a/components/Chips/src/ChipThemer/MaterialChips+ChipThemer.h b/components/Chips/src/ChipThemer/MaterialChips+ChipThemer.h deleted file mode 100644 index 702f2b12923..00000000000 --- a/components/Chips/src/ChipThemer/MaterialChips+ChipThemer.h +++ /dev/null @@ -1,16 +0,0 @@ -// 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 "MDCChipViewThemer.h" diff --git a/components/Chips/src/ColorThemer/MDCChipViewColorThemer.h b/components/Chips/src/ColorThemer/MDCChipViewColorThemer.h deleted file mode 100644 index b0869e9c686..00000000000 --- a/components/Chips/src/ColorThemer/MDCChipViewColorThemer.h +++ /dev/null @@ -1,68 +0,0 @@ -// 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 - -/** - The Material Design color system's themer for instances of MDCChipView. - - @warning This API will eventually be deleted. See the individual method documentation for - details on replacement APIs. - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -__deprecated_msg("Use Chips+Theming instead.") @interface MDCChipViewColorThemer : NSObject - -/** - Applies a color scheme's properties to an MDCChipView. - - @param colorScheme The color scheme to apply to the component instance. - @param chipView A component instance to which the color scheme should be applied. - - @warning This API will eventually be deprecated. The replacement API is: - `MDCChipView`'s `-applyThemeWithScheme:` - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applySemanticColorScheme:(nonnull id)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. - - @warning This API will eventually be deprecated. The replacement API is: - `MDCChipView`'s `-applyOutlinedThemeWithScheme:` - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applyOutlinedVariantWithColorScheme:(nonnull id)colorScheme - toChipView:(nonnull MDCChipView *)chipView; - -/** - Applies a color scheme's properties to a stroked MDCChipView. - - @param colorScheme The color scheme to apply to the component instance. - @param strokedChipView A component instance to which the color scheme should be applied. - - @warning This API will eventually be deprecated. The replacement API is: - `MDCChipView`'s `-applyOutlinedThemeWithScheme:` - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applySemanticColorScheme:(nonnull id)colorScheme - toStrokedChipView:(nonnull MDCChipView *)strokedChipView; - -@end diff --git a/components/Chips/src/ColorThemer/MDCChipViewColorThemer.m b/components/Chips/src/ColorThemer/MDCChipViewColorThemer.m deleted file mode 100644 index 2cb77287626..00000000000 --- a/components/Chips/src/ColorThemer/MDCChipViewColorThemer.m +++ /dev/null @@ -1,123 +0,0 @@ -// 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 "MDCChipViewColorThemer.h" - -@implementation MDCChipViewColorThemer - -+ (void)applySemanticColorScheme:(nonnull id)colorScheme - toChipView:(nonnull MDCChipView *)chipView { - [MDCChipViewColorThemer resetUIControlStatesForChipTheming:chipView]; - UIColor *onSurface12Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.12]; - UIColor *onSurface87Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.87]; - UIColor *onSurface16Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.16]; - - UIColor *backgroundColor = [MDCSemanticColorScheme blendColor:onSurface12Opacity - withBackgroundColor:colorScheme.surfaceColor]; - UIColor *selectedBackgroundColor = [MDCSemanticColorScheme blendColor:onSurface12Opacity - withBackgroundColor:backgroundColor]; - UIColor *textColor = [MDCSemanticColorScheme blendColor:onSurface87Opacity - withBackgroundColor:backgroundColor]; - UIColor *selectedTextColor = [MDCSemanticColorScheme blendColor:onSurface87Opacity - withBackgroundColor:selectedBackgroundColor]; - - [chipView setInkColor:onSurface16Opacity forState:UIControlStateNormal]; - [chipView setTitleColor:textColor forState:UIControlStateNormal]; - [chipView setBackgroundColor:backgroundColor forState:UIControlStateNormal]; - - [chipView setTitleColor:selectedTextColor forState:UIControlStateSelected]; - [chipView setBackgroundColor:selectedBackgroundColor forState:UIControlStateSelected]; - - [chipView setTitleColor:[textColor colorWithAlphaComponent:(CGFloat)0.38] - forState:UIControlStateDisabled]; - [chipView setBackgroundColor:[backgroundColor colorWithAlphaComponent:(CGFloat)0.38] - forState:UIControlStateDisabled]; -} - -+ (void)applyOutlinedVariantWithColorScheme:(nonnull id)colorScheme - toChipView:(nonnull MDCChipView *)chipView { - [MDCChipViewColorThemer resetUIControlStatesForChipTheming:chipView]; - UIColor *onSurface12Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.12]; - UIColor *onSurface87Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.87]; - UIColor *onSurface16Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.16]; - 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:(CGFloat)0.38] - forState:UIControlStateDisabled]; - [chipView setBackgroundColor:[colorScheme.surfaceColor colorWithAlphaComponent:(CGFloat)0.38] - forState:UIControlStateDisabled]; - [chipView setBorderColor:[borderColor colorWithAlphaComponent:(CGFloat)0.38] - forState:UIControlStateDisabled]; -} - -+ (void)applySemanticColorScheme:(nonnull id)colorScheme - toStrokedChipView:(nonnull MDCChipView *)strokedChipView { - [MDCChipViewColorThemer resetUIControlStatesForChipTheming:strokedChipView]; - UIColor *onSurface12Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.12]; - UIColor *onSurface87Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.87]; - UIColor *onSurface16Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.16]; - 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]; - - [strokedChipView setInkColor:onSurface16Opacity forState:UIControlStateNormal]; - [strokedChipView setTitleColor:textColor forState:UIControlStateNormal]; - [strokedChipView setBackgroundColor:colorScheme.surfaceColor forState:UIControlStateNormal]; - [strokedChipView setBorderColor:borderColor forState:UIControlStateNormal]; - - [strokedChipView setTitleColor:selectedTextColor forState:UIControlStateSelected]; - [strokedChipView setBackgroundColor:selectedBackgroundColor forState:UIControlStateSelected]; - [strokedChipView setBorderColor:[UIColor clearColor] forState:UIControlStateSelected]; - - [strokedChipView setTitleColor:[textColor colorWithAlphaComponent:(CGFloat)0.38] - forState:UIControlStateDisabled]; - [strokedChipView - setBackgroundColor:[colorScheme.surfaceColor colorWithAlphaComponent:(CGFloat)0.38] - forState:UIControlStateDisabled]; - [strokedChipView setBorderColor:[borderColor colorWithAlphaComponent:(CGFloat)0.38] - forState:UIControlStateDisabled]; -} - -+ (void)resetUIControlStatesForChipTheming:(nonnull MDCChipView *)chipView { - NSUInteger maximumStateValue = UIControlStateNormal | UIControlStateSelected | - UIControlStateHighlighted | UIControlStateDisabled; - for (NSUInteger state = 0; state <= maximumStateValue; ++state) { - [chipView setBackgroundColor:nil forState:state]; - [chipView setTitleColor:nil forState:state]; - [chipView setBorderColor:nil forState:state]; - } -} - -@end diff --git a/components/Chips/src/ColorThemer/MaterialChips+ColorThemer.h b/components/Chips/src/ColorThemer/MaterialChips+ColorThemer.h deleted file mode 100644 index d594e554b3f..00000000000 --- a/components/Chips/src/ColorThemer/MaterialChips+ColorThemer.h +++ /dev/null @@ -1,15 +0,0 @@ -// 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 "MDCChipViewColorThemer.h" diff --git a/components/Chips/src/FontThemer/MDCChipViewFontThemer.h b/components/Chips/src/FontThemer/MDCChipViewFontThemer.h deleted file mode 100644 index e4ba4e840a6..00000000000 --- a/components/Chips/src/FontThemer/MDCChipViewFontThemer.h +++ /dev/null @@ -1,39 +0,0 @@ -// 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 "MaterialTypographyScheme.h" - -#import - -/** - Themes @c MDCChipView objects to set their text font to the appropriate font trait given a font - scheme. - - @warning This API is deprecated. Learn more at - docs/theming.md#migration-guide-themers-to-theming-extensions - */ -__deprecated_msg("Use Chips+Theming instead.") @interface MDCChipViewFontThemer : NSObject - -/** - Applies the provided font scheme to the given Chip. - - @warning This API is deprecated. Learn more at - docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applyFontScheme:(nonnull id)fontScheme - toChipView:(nonnull MDCChipView *)chipView - __deprecated_msg("Use Chips+Theming instead."); - -@end diff --git a/components/Chips/src/FontThemer/MDCChipViewFontThemer.m b/components/Chips/src/FontThemer/MDCChipViewFontThemer.m deleted file mode 100644 index 63d146683bb..00000000000 --- a/components/Chips/src/FontThemer/MDCChipViewFontThemer.m +++ /dev/null @@ -1,26 +0,0 @@ -// 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 "MDCChipViewFontThemer.h" - -#import "MaterialChips.h" -#import "MaterialThemes.h" - -@implementation MDCChipViewFontThemer - -+ (void)applyFontScheme:(id)fontScheme toChipView:(MDCChipView *)chipView { - chipView.titleFont = fontScheme.body2; -} - -@end diff --git a/components/Chips/src/FontThemer/MaterialChips+FontThemer.h b/components/Chips/src/FontThemer/MaterialChips+FontThemer.h deleted file mode 100644 index d1e6b433034..00000000000 --- a/components/Chips/src/FontThemer/MaterialChips+FontThemer.h +++ /dev/null @@ -1,15 +0,0 @@ -// 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 "MDCChipViewFontThemer.h" diff --git a/components/Chips/src/ShapeThemer/MDCChipViewShapeThemer.h b/components/Chips/src/ShapeThemer/MDCChipViewShapeThemer.h deleted file mode 100644 index b05a166d24c..00000000000 --- a/components/Chips/src/ShapeThemer/MDCChipViewShapeThemer.h +++ /dev/null @@ -1,44 +0,0 @@ -// 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 - -#import "MaterialChips.h" -#import "MaterialShapeLibrary.h" -#import "MaterialShapeScheme.h" -#import "MaterialShapes.h" - -/** - The Material Design shape system's themer for instances of MDCChipView. - - @warning This API will eventually be deleted. See the individual method documentation for - details on replacement APIs. - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -__deprecated_msg("Use Chips+Theming instead.") @interface MDCChipViewShapeThemer : NSObject - -/** - Applies a shape scheme's properties to an MDCChipView. - - @param shapeScheme The shape scheme to apply to the component instance. - @param chipView A component instance to which the shape scheme should be applied. - - @warning This API will eventually be deprecated. The replacement API is any of `MDCCard`'s theming - extensions. - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applyShapeScheme:(nonnull id)shapeScheme - toChipView:(nonnull MDCChipView *)chipView; - -@end diff --git a/components/Chips/src/ShapeThemer/MDCChipViewShapeThemer.m b/components/Chips/src/ShapeThemer/MDCChipViewShapeThemer.m deleted file mode 100644 index 232e396d9de..00000000000 --- a/components/Chips/src/ShapeThemer/MDCChipViewShapeThemer.m +++ /dev/null @@ -1,32 +0,0 @@ -// 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 "MDCChipViewShapeThemer.h" - -static const CGFloat kChipViewBaselineShapePercentageValue = (CGFloat)0.5; - -@implementation MDCChipViewShapeThemer - -+ (void)applyShapeScheme:(nonnull id)shapeScheme - toChipView:(nonnull MDCChipView *)chipView { - // This is an override of the default scheme to fit the baseline values. - MDCRectangleShapeGenerator *rectangleShape = [[MDCRectangleShapeGenerator alloc] init]; - MDCCornerTreatment *cornerTreatment = - [MDCCornerTreatment cornerWithRadius:kChipViewBaselineShapePercentageValue - valueType:MDCCornerTreatmentValueTypePercentage]; - [rectangleShape setCorners:cornerTreatment]; - chipView.shapeGenerator = rectangleShape; -} - -@end diff --git a/components/Chips/src/ShapeThemer/MaterialChips+ShapeThemer.h b/components/Chips/src/ShapeThemer/MaterialChips+ShapeThemer.h deleted file mode 100644 index 8d5a11f9c3e..00000000000 --- a/components/Chips/src/ShapeThemer/MaterialChips+ShapeThemer.h +++ /dev/null @@ -1,15 +0,0 @@ -// 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 "MDCChipViewShapeThemer.h" diff --git a/components/Chips/src/Theming/MDCChipView+MaterialTheming.m b/components/Chips/src/Theming/MDCChipView+MaterialTheming.m index c1ecf72d10a..8daa1b14038 100644 --- a/components/Chips/src/Theming/MDCChipView+MaterialTheming.m +++ b/components/Chips/src/Theming/MDCChipView+MaterialTheming.m @@ -14,10 +14,11 @@ #import "MDCChipView+MaterialTheming.h" -#import "MaterialChips+ColorThemer.h" -#import "MaterialChips+ShapeThemer.h" +#import "MaterialShapeLibrary.h" #import "MaterialTypography.h" +static const CGFloat kChipViewBaselineShapePercentageValue = (CGFloat)0.5; + @implementation MDCChipView (MaterialTheming) #pragma mark - Standard Chip @@ -35,11 +36,41 @@ - (void)applyThemeWithScheme:(id)scheme { } - (void)applyThemeWithColorScheme:(id)colorScheme { - [MDCChipViewColorThemer applySemanticColorScheme:colorScheme toChipView:self]; + [self resetUIControlStatesForChipTheming]; + + UIColor *onSurface12Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.12]; + UIColor *onSurface87Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.87]; + UIColor *onSurface16Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.16]; + + UIColor *backgroundColor = [MDCSemanticColorScheme blendColor:onSurface12Opacity + withBackgroundColor:colorScheme.surfaceColor]; + UIColor *selectedBackgroundColor = [MDCSemanticColorScheme blendColor:onSurface12Opacity + withBackgroundColor:backgroundColor]; + UIColor *textColor = [MDCSemanticColorScheme blendColor:onSurface87Opacity + withBackgroundColor:backgroundColor]; + UIColor *selectedTextColor = [MDCSemanticColorScheme blendColor:onSurface87Opacity + withBackgroundColor:selectedBackgroundColor]; + + [self setInkColor:onSurface16Opacity forState:UIControlStateNormal]; + [self setTitleColor:textColor forState:UIControlStateNormal]; + [self setBackgroundColor:backgroundColor forState:UIControlStateNormal]; + + [self setTitleColor:selectedTextColor forState:UIControlStateSelected]; + [self setBackgroundColor:selectedBackgroundColor forState:UIControlStateSelected]; + + [self setTitleColor:[textColor colorWithAlphaComponent:(CGFloat)0.38] + forState:UIControlStateDisabled]; + [self setBackgroundColor:[backgroundColor colorWithAlphaComponent:(CGFloat)0.38] + forState:UIControlStateDisabled]; } - (void)applyThemeWithShapeScheme:(id)shapeScheme { - [MDCChipViewShapeThemer applyShapeScheme:shapeScheme toChipView:self]; + MDCRectangleShapeGenerator *rectangleShape = [[MDCRectangleShapeGenerator alloc] init]; + MDCCornerTreatment *cornerTreatment = + [MDCCornerTreatment cornerWithRadius:kChipViewBaselineShapePercentageValue + valueType:MDCCornerTreatmentValueTypePercentage]; + [rectangleShape setCorners:cornerTreatment]; + self.shapeGenerator = rectangleShape; } - (void)applyThemeWithTypographyScheme:(id)typographyScheme { @@ -65,7 +96,47 @@ - (void)applyOutlinedThemeWithScheme:(nonnull id)scheme { } - (void)applyOutlinedThemeWithColorScheme:(id)colorScheme { - [MDCChipViewColorThemer applyOutlinedVariantWithColorScheme:colorScheme toChipView:self]; + [self resetUIControlStatesForChipTheming]; + + UIColor *onSurface12Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.12]; + UIColor *onSurface87Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.87]; + UIColor *onSurface16Opacity = [colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.16]; + 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]; + + [self setInkColor:onSurface16Opacity forState:UIControlStateNormal]; + [self setTitleColor:textColor forState:UIControlStateNormal]; + [self setBackgroundColor:colorScheme.surfaceColor forState:UIControlStateNormal]; + [self setBorderColor:borderColor forState:UIControlStateNormal]; + + [self setTitleColor:selectedTextColor forState:UIControlStateSelected]; + [self setBackgroundColor:selectedBackgroundColor forState:UIControlStateSelected]; + [self setBorderColor:[UIColor clearColor] forState:UIControlStateSelected]; + + [self setTitleColor:[textColor colorWithAlphaComponent:(CGFloat)0.38] + forState:UIControlStateDisabled]; + [self setBackgroundColor:[colorScheme.surfaceColor colorWithAlphaComponent:(CGFloat)0.38] + forState:UIControlStateDisabled]; + [self setBorderColor:[borderColor colorWithAlphaComponent:(CGFloat)0.38] + forState:UIControlStateDisabled]; +} + +#pragma mark - Private + +- (void)resetUIControlStatesForChipTheming { + NSUInteger maximumStateValue = UIControlStateNormal | UIControlStateSelected | + UIControlStateHighlighted | UIControlStateDisabled; + for (NSUInteger state = 0; state <= maximumStateValue; ++state) { + [self setBackgroundColor:nil forState:state]; + [self setTitleColor:nil forState:state]; + [self setBorderColor:nil forState:state]; + } } @end diff --git a/components/Chips/src/TypographyThemer/MDCChipViewTypographyThemer.h b/components/Chips/src/TypographyThemer/MDCChipViewTypographyThemer.h deleted file mode 100644 index 37f99f82642..00000000000 --- a/components/Chips/src/TypographyThemer/MDCChipViewTypographyThemer.h +++ /dev/null @@ -1,41 +0,0 @@ -// 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 "MaterialTypographyScheme.h" - -#import - -/** - The Material Design typography system's themer for instances of MDCChipView. - - @warning This API is deprecated. Learn more at - docs/theming.md#migration-guide-themers-to-theming-extensions - */ -__deprecated_msg("Use Chips+Theming instead.") @interface MDCChipViewTypographyThemer : NSObject - -/** - Applies a typography scheme's properties to an MDCChipView. - - @param typographyScheme The typography scheme to apply to the component instance. - @param chipView A component instance to which the typography scheme should be applied. - - @warning This API is deprecated. Learn more at - docs/theming.md#migration-guide-themers-to-theming-extensions - */ -+ (void)applyTypographyScheme:(nonnull id)typographyScheme - toChipView:(nonnull MDCChipView *)chipView - __deprecated_msg("Use Chips+Theming instead."); - -@end diff --git a/components/Chips/src/TypographyThemer/MDCChipViewTypographyThemer.m b/components/Chips/src/TypographyThemer/MDCChipViewTypographyThemer.m deleted file mode 100644 index c97f29e8955..00000000000 --- a/components/Chips/src/TypographyThemer/MDCChipViewTypographyThemer.m +++ /dev/null @@ -1,31 +0,0 @@ -// 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 "MDCChipViewTypographyThemer.h" - -#import "MaterialTypography.h" - -@implementation MDCChipViewTypographyThemer - -+ (void)applyTypographyScheme:(nonnull id)typographyScheme - toChipView:(nonnull MDCChipView *)chipView { - UIFont *titleFont = typographyScheme.body2; - - if (typographyScheme.useCurrentContentSizeCategoryWhenApplied) { - titleFont = [titleFont mdc_scaledFontForTraitEnvironment:chipView]; - } - chipView.titleFont = titleFont; -} - -@end diff --git a/components/Chips/src/TypographyThemer/MaterialChips+TypographyThemer.h b/components/Chips/src/TypographyThemer/MaterialChips+TypographyThemer.h deleted file mode 100644 index f0f8c9d7a9b..00000000000 --- a/components/Chips/src/TypographyThemer/MaterialChips+TypographyThemer.h +++ /dev/null @@ -1,15 +0,0 @@ -// 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 "MDCChipViewTypographyThemer.h" diff --git a/components/Chips/tests/unit/ChipViewColorThemerTests.m b/components/Chips/tests/unit/ChipViewColorThemerTests.m deleted file mode 100644 index 8241410d616..00000000000 --- a/components/Chips/tests/unit/ChipViewColorThemerTests.m +++ /dev/null @@ -1,112 +0,0 @@ -// 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 - -#import "MaterialChips+ColorThemer.h" -#import "MaterialChips.h" - -@interface ChipViewColorThemerTests : XCTestCase - -@property(nonatomic, strong) MDCChipView *chip; -@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme; - -@end - -@implementation ChipViewColorThemerTests - -- (void)setUp { - self.chip = [[MDCChipView alloc] init]; - self.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; -} - -- (void)tearDown { - self.chip = nil; - self.colorScheme = nil; -} - -- (void)testInputChipViewColorThemer { - [MDCChipViewColorThemer applySemanticColorScheme:self.colorScheme toChipView:self.chip]; - UIColor *onSurface12Opacity = - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.12]; - UIColor *onSurface87Opacity = - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.87]; - UIColor *onSurface16Opacity = - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.16]; - - UIColor *backgroundColor = [MDCSemanticColorScheme blendColor:onSurface12Opacity - withBackgroundColor:self.colorScheme.surfaceColor]; - UIColor *selectedBackgroundColor = [MDCSemanticColorScheme blendColor:onSurface12Opacity - withBackgroundColor:backgroundColor]; - UIColor *textColor = [MDCSemanticColorScheme blendColor:onSurface87Opacity - withBackgroundColor:backgroundColor]; - UIColor *selectedTextColor = [MDCSemanticColorScheme blendColor:onSurface87Opacity - withBackgroundColor:selectedBackgroundColor]; - - XCTAssertEqualObjects([self.chip inkColorForState:UIControlStateNormal], onSurface16Opacity); - XCTAssertEqualObjects([self.chip titleColorForState:UIControlStateNormal], textColor); - XCTAssertEqualObjects([self.chip backgroundColorForState:UIControlStateNormal], backgroundColor); - XCTAssertEqualObjects([self.chip backgroundColorForState:UIControlStateSelected], - selectedBackgroundColor); - XCTAssertEqualObjects([self.chip titleColorForState:UIControlStateSelected], selectedTextColor); - XCTAssertEqualObjects([self.chip backgroundColorForState:UIControlStateDisabled], - [backgroundColor colorWithAlphaComponent:(CGFloat)0.38]); - XCTAssertEqualObjects([self.chip titleColorForState:UIControlStateDisabled], - [textColor colorWithAlphaComponent:(CGFloat)0.38]); -} - -- (void)testStrokedChipViewColorThemer { - [MDCChipViewColorThemer applyOutlinedVariantWithColorScheme:self.colorScheme - toChipView:self.chip]; - UIColor *onSurface12Opacity = - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.12]; - UIColor *onSurface87Opacity = - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.87]; - UIColor *onSurface16Opacity = - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:(CGFloat)0.16]; - UIColor *selectedBackgroundColor = - [MDCSemanticColorScheme blendColor:onSurface12Opacity - withBackgroundColor:self.colorScheme.surfaceColor]; - UIColor *borderColor = [MDCSemanticColorScheme blendColor:onSurface12Opacity - withBackgroundColor:self.colorScheme.surfaceColor]; - UIColor *textColor = [MDCSemanticColorScheme blendColor:onSurface87Opacity - withBackgroundColor:self.colorScheme.surfaceColor]; - UIColor *selectedTextColor = [MDCSemanticColorScheme blendColor:onSurface87Opacity - withBackgroundColor:selectedBackgroundColor]; - - XCTAssertEqualObjects([self.chip borderColorForState:UIControlStateNormal], borderColor); - XCTAssertEqualObjects([self.chip borderColorForState:UIControlStateSelected], - [UIColor clearColor]); - XCTAssertEqualObjects([self.chip inkColorForState:UIControlStateNormal], onSurface16Opacity); - XCTAssertEqualObjects([self.chip titleColorForState:UIControlStateNormal], textColor); - XCTAssertEqualObjects([self.chip backgroundColorForState:UIControlStateNormal], - self.colorScheme.surfaceColor); - XCTAssertEqualObjects([self.chip backgroundColorForState:UIControlStateSelected], - selectedBackgroundColor); - XCTAssertEqualObjects([self.chip titleColorForState:UIControlStateSelected], selectedTextColor); - XCTAssertEqualObjects([self.chip backgroundColorForState:UIControlStateDisabled], - [self.colorScheme.surfaceColor colorWithAlphaComponent:(CGFloat)0.38]); - XCTAssertEqualObjects([self.chip titleColorForState:UIControlStateDisabled], - [textColor colorWithAlphaComponent:(CGFloat)0.38]); -} - -- (void)testBackgroundColorAfterColorTheming { - self.colorScheme.surfaceColor = [UIColor blueColor]; - [MDCChipViewColorThemer applyOutlinedVariantWithColorScheme:self.colorScheme - toChipView:self.chip]; - XCTAssertEqualObjects(self.colorScheme.surfaceColor, self.chip.backgroundColor); -} - -@end diff --git a/components/Chips/tests/unit/ChipViewFontThemerTests.m b/components/Chips/tests/unit/ChipViewFontThemerTests.m deleted file mode 100644 index 39f2699a8b3..00000000000 --- a/components/Chips/tests/unit/ChipViewFontThemerTests.m +++ /dev/null @@ -1,40 +0,0 @@ -// 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 - -#import "MaterialChips+FontThemer.h" -#import "MaterialChips.h" -#import "MaterialThemes.h" - -@interface ChipViewFontThemerTests : XCTestCase - -@end - -@implementation ChipViewFontThemerTests - -- (void)testFontThemer { - // Given - MDCChipView *chip = [[MDCChipView alloc] init]; - MDCBasicFontScheme *fontScheme = [[MDCBasicFontScheme alloc] init]; - fontScheme.body2 = [UIFont systemFontOfSize:99]; - - // When - [MDCChipViewFontThemer applyFontScheme:fontScheme toChipView:chip]; - - // Then - XCTAssertEqualObjects(chip.titleFont, fontScheme.body2); -} - -@end diff --git a/components/Chips/tests/unit/ChipViewShapeThemerTests.m b/components/Chips/tests/unit/ChipViewShapeThemerTests.m deleted file mode 100644 index 687e38ca784..00000000000 --- a/components/Chips/tests/unit/ChipViewShapeThemerTests.m +++ /dev/null @@ -1,65 +0,0 @@ -// 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 - -#import "MaterialChips+ChipThemer.h" -#import "MaterialChips+ShapeThemer.h" -#import "MaterialChips.h" - -@interface ChipViewShapeThemerTests : XCTestCase - -@property(nonatomic, strong) MDCChipView *chip; -@property(nonatomic, strong) MDCShapeScheme *shapeScheme; - -@end - -@implementation ChipViewShapeThemerTests - -- (void)setUp { - self.chip = [[MDCChipView alloc] init]; - self.shapeScheme = [[MDCShapeScheme alloc] init]; -} - -- (void)tearDown { - self.chip = nil; - self.shapeScheme = nil; -} - -- (void)testChipViewShapeThemer { - // Given - self.shapeScheme.smallComponentShape = - [[MDCShapeCategory alloc] initCornersWithFamily:MDCShapeCornerFamilyCut andSize:10]; - self.chip.shapeGenerator = [[MDCRectangleShapeGenerator alloc] init]; - - // When - [MDCChipViewShapeThemer applyShapeScheme:self.shapeScheme toChipView:self.chip]; - - // Then - MDCRectangleShapeGenerator *rect = (MDCRectangleShapeGenerator *)self.chip.shapeGenerator; - MDCCornerTreatment *corner = [MDCCornerTreatment cornerWithRadius:(CGFloat)0.5]; - corner.valueType = MDCCornerTreatmentValueTypePercentage; - XCTAssertEqualObjects(rect.topLeftCorner, corner); - XCTAssertEqualObjects(rect.topRightCorner, corner); - XCTAssertEqualObjects(rect.bottomLeftCorner, corner); - XCTAssertEqualObjects(rect.bottomRightCorner, corner); -} - -- (void)testBackgroundColorAfterChipTheming { - MDCChipViewScheme *scheme = [[MDCChipViewScheme alloc] init]; - [MDCChipViewThemer applyOutlinedVariantWithScheme:scheme toChipView:self.chip]; - XCTAssertEqualObjects(scheme.colorScheme.surfaceColor, self.chip.backgroundColor); -} - -@end diff --git a/components/Chips/tests/unit/ChipViewTypographyThemerTests.m b/components/Chips/tests/unit/ChipViewTypographyThemerTests.m deleted file mode 100644 index dc7fe3b0499..00000000000 --- a/components/Chips/tests/unit/ChipViewTypographyThemerTests.m +++ /dev/null @@ -1,85 +0,0 @@ -// 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 - -#import "MaterialChips+TypographyThemer.h" -#import "MaterialChips.h" -#import "MaterialTypography.h" - -/** Fake MDCChipView for unit testing. */ -@interface MDCChipsTypographyThemerTestsFakeChipView : MDCChipView - -/** Used to set the value of @c traitCollection. */ -@property(nonatomic, strong) UITraitCollection *traitCollectionOverride; - -@end - -@implementation MDCChipsTypographyThemerTestsFakeChipView - -- (UITraitCollection *)traitCollection { - return self.traitCollectionOverride ?: [super traitCollection]; -} - -@end - -@interface ChipViewTypographyThemerTests : XCTestCase - -@end - -@implementation ChipViewTypographyThemerTests - -- (void)testFontThemerWhenCurrentContentSizeCategoryIsUsed { - if (@available(iOS 10.0, *)) { - // Given - MDCChipsTypographyThemerTestsFakeChipView *chip = - [[MDCChipsTypographyThemerTestsFakeChipView alloc] init]; - MDCTypographyScheme *typographyScheme = [[MDCTypographyScheme alloc] init]; - typographyScheme.useCurrentContentSizeCategoryWhenApplied = YES; - UIContentSizeCategory size = UIContentSizeCategoryExtraExtraLarge; - UITraitCollection *traitCollection = - [UITraitCollection traitCollectionWithPreferredContentSizeCategory:size]; - chip.traitCollectionOverride = traitCollection; - - // When - [MDCChipViewTypographyThemer applyTypographyScheme:typographyScheme toChipView:chip]; - - // Then - XCTAssertNotNil(chip.titleFont.mdc_scalingCurve); - XCTAssertGreaterThan(chip.titleFont.pointSize, typographyScheme.body2.pointSize); - } -} - -- (void)testFontThemerWhenCurrentContentSizeCategoryIsNotUsed { - if (@available(iOS 10.0, *)) { - // Given - MDCChipsTypographyThemerTestsFakeChipView *chip = - [[MDCChipsTypographyThemerTestsFakeChipView alloc] init]; - MDCTypographyScheme *typographyScheme = [[MDCTypographyScheme alloc] init]; - typographyScheme.useCurrentContentSizeCategoryWhenApplied = NO; - UIContentSizeCategory size = UIContentSizeCategoryExtraExtraLarge; - UITraitCollection *traitCollection = - [UITraitCollection traitCollectionWithPreferredContentSizeCategory:size]; - chip.traitCollectionOverride = traitCollection; - - // When - [MDCChipViewTypographyThemer applyTypographyScheme:typographyScheme toChipView:chip]; - - // Then - XCTAssertNotNil(chip.titleFont.mdc_scalingCurve); - XCTAssertTrue([chip.titleFont mdc_isSimplyEqual:typographyScheme.body2]); - } -} - -@end diff --git a/components/Ink/src/MDCInkTouchController.m b/components/Ink/src/MDCInkTouchController.m index 06250823514..b3101ce0c3b 100644 --- a/components/Ink/src/MDCInkTouchController.m +++ b/components/Ink/src/MDCInkTouchController.m @@ -26,20 +26,6 @@ @interface MDCInkTouchController () @property(nonatomic, assign) CGPoint previousLocation; @end -@protocol MDCInkTouchControllerLegacyDelegate -@optional - -/** - This protocol is private and declares an old method signature that will be removed once legacy code - has been migrated to the new delegate protocol. - */ -- (BOOL)shouldInkTouchControllerProcessInkTouches: - (nonnull MDCInkTouchController *)inkTouchController - __deprecated_msg("shouldInkTouchControllerProcessInkTouches has been replaced with " - "inkTouchController:shouldProcessInkTouchesAtTouchLocation."); - -@end - @implementation MDCInkTouchController - (CGFloat)dragCancelDistance { @@ -211,15 +197,6 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { shouldProcessInkTouchesAtTouchLocation:)]) { CGPoint touchLocation = [gestureRecognizer locationInView:_view]; return [_delegate inkTouchController:self shouldProcessInkTouchesAtTouchLocation:touchLocation]; - } else if ([_delegate respondsToSelector:@selector(shouldInkTouchControllerProcessInkTouches:)]) { - // Please use inkTouchController:shouldProcessInkTouchesAtTouchLocation. The delegate call below - // is deprecated and only provided for legacy support. - id legacyDelegate = - (id)_delegate; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - return [legacyDelegate shouldInkTouchControllerProcessInkTouches:self]; -#pragma clang diagnostic pop } return YES; } diff --git a/components/LibraryInfo/src/MDCLibraryInfo.m b/components/LibraryInfo/src/MDCLibraryInfo.m index 3a31aa3ee71..8376b0160dd 100644 --- a/components/LibraryInfo/src/MDCLibraryInfo.m +++ b/components/LibraryInfo/src/MDCLibraryInfo.m @@ -19,7 +19,7 @@ // This string is updated automatically as a part of the release process and should not be edited // manually. Do not rename this constant or change the formatting without updating the release // scripts. -static NSString const *MDCLibraryInfoVersionString = @"94.5.0"; +static NSString const *MDCLibraryInfoVersionString = @"95.0.0"; @implementation MDCLibraryInfo diff --git a/components/LibraryInfo/tests/unit/LibraryInfoTests.m b/components/LibraryInfo/tests/unit/LibraryInfoTests.m index 58c6805a2b1..03ea08be410 100644 --- a/components/LibraryInfo/tests/unit/LibraryInfoTests.m +++ b/components/LibraryInfo/tests/unit/LibraryInfoTests.m @@ -26,7 +26,7 @@ - (void)testVersionFormat { // Given // This regex pattern does the following: - // Accept: "94.5.0", etc. + // Accept: "95.0.0", etc. // Reject: "0.0.0", "1.2", "1", "-1.2.3", "Hi, I'm a version 1.2.3", "1.2.3 is my version", etc. // // Note the major version must be >= 1 since "0.0.0" is used as the version when something goes diff --git a/components/Tabs/BUILD b/components/Tabs/BUILD index 06584387011..cc0f825612c 100644 --- a/components/Tabs/BUILD +++ b/components/Tabs/BUILD @@ -109,7 +109,6 @@ mdc_examples_objc_library( name = "ObjcExamples", data = [":TabsExamplesAssets"], deps = [ - ":ColorThemer", ":TabBarView", ":Tabs", ":Theming", @@ -135,8 +134,8 @@ mdc_examples_objc_library( mdc_examples_swift_library( name = "SwiftExamples", deps = [ - ":ColorThemer", ":Tabs", + ":Theming", "//components/AppBar", "//components/AppBar:ColorThemer", "//components/AppBar:TypographyThemer", diff --git a/components/Tabs/examples/BottomNavigationBarExample.m b/components/Tabs/examples/BottomNavigationBarExample.m index 38ff9343809..da3890ea648 100644 --- a/components/Tabs/examples/BottomNavigationBarExample.m +++ b/components/Tabs/examples/BottomNavigationBarExample.m @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#import "MaterialColorScheme.h" -#import "MaterialTabs+ColorThemer.h" +#import "MaterialContainerScheme.h" +#import "MaterialTabs+Theming.h" #import "MaterialTabs.h" @interface BottomNavigationBarExample : UIViewController -@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme; +@property(nonatomic, strong) MDCContainerScheme *containerScheme; @end @implementation BottomNavigationBarExample { @@ -28,8 +28,7 @@ @implementation BottomNavigationBarExample { - (id)init { self = [super init]; if (self) { - self.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; + _containerScheme = [[MDCContainerScheme alloc] init]; } return self; } @@ -40,7 +39,7 @@ - (void)viewDidLoad { _bottomNavigationBar = [[MDCTabBar alloc] initWithFrame:CGRectZero]; _bottomNavigationBar.translatesAutoresizingMaskIntoConstraints = NO; _bottomNavigationBar.delegate = self; - [MDCTabBarColorThemer applySemanticColorScheme:self.colorScheme toTabs:_bottomNavigationBar]; + [_bottomNavigationBar applyPrimaryThemeWithScheme:self.containerScheme]; _bottomNavigationBar.inkColor = [UIColor colorWithRed:0 green:(CGFloat)0.5 diff --git a/components/Tabs/examples/TabBarIconExample.m b/components/Tabs/examples/TabBarIconExample.m index 964bd4758b6..285cbb07fd4 100644 --- a/components/Tabs/examples/TabBarIconExample.m +++ b/components/Tabs/examples/TabBarIconExample.m @@ -15,12 +15,13 @@ #import "supplemental/TabBarIconExampleSupplemental.h" #import "MaterialAppBar.h" -#import "MaterialColorScheme.h" -#import "MaterialTabs+ColorThemer.h" +#import "MaterialContainerScheme.h" +#import "MaterialTabs+Theming.h" #import "MaterialTabs.h" @interface TabBarIconExample () @property(nonatomic, strong) UIBarButtonItem *addStarButtonItem; +@property(nonatomic, strong) MDCContainerScheme *containerScheme; @end @implementation TabBarIconExample @@ -28,9 +29,7 @@ @implementation TabBarIconExample - (id)init { self = [super init]; if (self) { - self.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; - self.typographyScheme = [[MDCTypographyScheme alloc] init]; + _containerScheme = [[MDCContainerScheme alloc] init]; } return self; } @@ -92,7 +91,7 @@ - (void)loadTabBar { // Give the second item a badge [tabBar.items[1] setBadgeValue:@"1"]; - [MDCTabBarColorThemer applySemanticColorScheme:self.colorScheme toTabs:tabBar]; + [tabBar applyPrimaryThemeWithScheme:self.containerScheme]; tabBar.inkColor = [[UIColor whiteColor] colorWithAlphaComponent:(CGFloat)0.1]; tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; diff --git a/components/Tabs/examples/TabBarIconExample.swift b/components/Tabs/examples/TabBarIconExample.swift index b135f029d36..eb41060da1e 100644 --- a/components/Tabs/examples/TabBarIconExample.swift +++ b/components/Tabs/examples/TabBarIconExample.swift @@ -19,7 +19,7 @@ import MaterialComponents.MaterialButtons import MaterialComponents.MaterialColorScheme import MaterialComponents.MaterialPalettes import MaterialComponents.MaterialTabs -import MaterialComponents.MaterialTabs_ColorThemer +import MaterialComponents.MaterialTabs_Theming import MaterialComponents.MaterialTypographyScheme class TabBarIconSwiftExample: UIViewController { @@ -38,8 +38,7 @@ class TabBarIconSwiftExample: UIViewController { lazy var appBarViewController: MDCAppBarViewController = self.setupAppBar() lazy var scrollView: UIScrollView = self.setupScrollView() lazy var starPage: UIView = self.setupStarPage() - @objc var colorScheme = MDCSemanticColorScheme() - @objc var typographyScheme = MDCTypographyScheme() + @objc var containerScheme = MDCContainerScheme() lazy var tabBar: MDCTabBar = { let tabBar = MDCTabBar() @@ -54,7 +53,7 @@ class TabBarIconSwiftExample: UIViewController { UITabBarItem(title: "Stars", image: star, tag:0)] tabBar.items[1].badgeValue = "1" - MDCTabBarColorThemer.applySemanticColorScheme(self.colorScheme, toTabs: tabBar); + tabBar.applyPrimaryTheme(withScheme: containerScheme) let blue = MDCPalette.blue.tint500 tabBar.inkColor = blue diff --git a/components/Tabs/examples/TabBarIndicatorTemplateExample.swift b/components/Tabs/examples/TabBarIndicatorTemplateExample.swift index ca4704e6585..ad397aeb3f0 100644 --- a/components/Tabs/examples/TabBarIndicatorTemplateExample.swift +++ b/components/Tabs/examples/TabBarIndicatorTemplateExample.swift @@ -18,10 +18,9 @@ import CoreGraphics import MaterialComponents.MaterialAppBar_ColorThemer import MaterialComponents.MaterialAppBar_TypographyThemer import MaterialComponents.MaterialButtons -import MaterialComponents.MaterialColorScheme -import MaterialComponents.MaterialTypographyScheme +import MaterialComponents.MaterialContainerScheme import MaterialComponents.MaterialTabs -import MaterialComponents.MaterialTabs_ColorThemer +import MaterialComponents.MaterialTabs_Theming class TabBarIndicatorTemplateExample: UIViewController { @@ -50,14 +49,13 @@ class TabBarIndicatorTemplateExample: UIViewController { lazy var alignmentButton: MDCButton = self.makeAlignmentButton() lazy var appearanceButton: MDCButton = self.makeAppearanceButton() lazy var appBarViewController: MDCAppBarViewController = self.makeAppBar() - @objc var colorScheme = MDCSemanticColorScheme() - @objc var typographyScheme = MDCTypographyScheme() + @objc var containerScheme = MDCContainerScheme() lazy var tabBar: MDCTabBar = { let tabBar = MDCTabBar() tabBar.alignment = .justified - MDCTabBarColorThemer.applySemanticColorScheme(self.colorScheme, toTabs: tabBar); + tabBar.applyPrimaryTheme(withScheme: containerScheme) let bundle = Bundle(for: TabBarIndicatorTemplateExample.self) let info = UIImage.init(named: "TabBarDemo_ic_info", in: bundle, compatibleWith:nil) @@ -97,8 +95,8 @@ class TabBarIndicatorTemplateExample: UIViewController { action: #selector(changeAppearance), for: .touchUpInside) - MDCAppBarColorThemer.applyColorScheme(self.colorScheme, to: self.appBarViewController) - MDCAppBarTypographyThemer.applyTypographyScheme(self.typographyScheme, + MDCAppBarColorThemer.applyColorScheme(containerScheme.colorScheme, to: self.appBarViewController) + MDCAppBarTypographyThemer.applyTypographyScheme(containerScheme.typographyScheme, to: self.appBarViewController) } diff --git a/components/Tabs/examples/TabBarInterfaceBuilderExample.m b/components/Tabs/examples/TabBarInterfaceBuilderExample.m index 48e3b0b91f7..97b405faa74 100644 --- a/components/Tabs/examples/TabBarInterfaceBuilderExample.m +++ b/components/Tabs/examples/TabBarInterfaceBuilderExample.m @@ -14,16 +14,16 @@ #import -#import "MaterialColorScheme.h" +#import "MaterialContainerScheme.h" #import "MaterialPalettes.h" -#import "MaterialTabs+ColorThemer.h" +#import "MaterialTabs+Theming.h" #import "MaterialTabs.h" @interface TabBarInterfaceBuilderExample : UIViewController @property(weak, nonatomic) IBOutlet MDCTabBar *tabBar; @property(nonatomic) NSArray *colors; -@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme; +@property(nonatomic, strong) MDCContainerScheme *containerScheme; @end @@ -32,8 +32,7 @@ @implementation TabBarInterfaceBuilderExample - (id)init { self = [super init]; if (self) { - self.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; + _containerScheme = [[MDCContainerScheme alloc] init]; } return self; } @@ -53,7 +52,7 @@ - (void)viewDidLoad { MDCPalette.greenPalette.tint500 ]; - [MDCTabBarColorThemer applySemanticColorScheme:self.colorScheme toTabs:self.tabBar]; + [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; self.view.backgroundColor = self.colors[0]; } diff --git a/components/Tabs/examples/TabBarTextOnlyExample.m b/components/Tabs/examples/TabBarTextOnlyExample.m index 9ad80f5f827..023effba611 100644 --- a/components/Tabs/examples/TabBarTextOnlyExample.m +++ b/components/Tabs/examples/TabBarTextOnlyExample.m @@ -18,8 +18,8 @@ #import "MaterialAppBar.h" #import "MaterialButtons.h" #import "MaterialCollections.h" -#import "MaterialColorScheme.h" -#import "MaterialTabs+ColorThemer.h" +#import "MaterialContainerScheme.h" +#import "MaterialTabs+Theming.h" #import "MaterialTabs.h" #import "supplemental/TabBarTextOnlyExampleSupplemental.h" @@ -29,8 +29,7 @@ - (id)initWithCollectionViewLayout:(UICollectionViewLayout *)layout { self = [super initWithCollectionViewLayout:layout]; if (self) { [self setupExampleViews:@[ @"Change Alignment", @"Toggle Case", @"Clear Selection" ]]; - self.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; + _containerScheme = [[MDCContainerScheme alloc] init]; } return self; } @@ -68,7 +67,7 @@ - (void)loadTabBar { tag:0], ]; - [MDCTabBarColorThemer applySemanticColorScheme:self.colorScheme toTabs:self.tabBar]; + [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; self.tabBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; diff --git a/components/Tabs/examples/TabBarViewControllerExample.m b/components/Tabs/examples/TabBarViewControllerExample.m index eff48ca1bd4..c5c7fd0f3cf 100644 --- a/components/Tabs/examples/TabBarViewControllerExample.m +++ b/components/Tabs/examples/TabBarViewControllerExample.m @@ -16,7 +16,7 @@ #import "MaterialColorScheme.h" #import "MaterialSlider.h" -#import "MaterialTabs+ColorThemer.h" +#import "MaterialTabs+Theming.h" #import "MaterialTabs.h" #import "supplemental/TabBarViewControllerExampleSupplemental.h" @@ -25,9 +25,7 @@ @implementation TabBarViewControllerExample - (id)init { self = [super init]; if (self) { - self.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; - self.typographyScheme = [[MDCTypographyScheme alloc] init]; + _containerScheme = [[MDCContainerScheme alloc] init]; } return self; } @@ -46,7 +44,7 @@ - (void)loadTabBar { self.viewControllers = viewControllers; self.selectedViewController = self.viewControllers.firstObject; self.tabBar.enableRippleBehavior = YES; - [MDCTabBarColorThemer applySemanticColorScheme:self.colorScheme toTabs:self.tabBar]; + [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; } @end diff --git a/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.swift b/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.swift index 73dddc886fc..a32db5f34d7 100644 --- a/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.swift +++ b/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.swift @@ -30,8 +30,8 @@ extension TabBarIconSwiftExample { let alignmentButton = MDCButton() let buttonScheme = MDCButtonScheme() - buttonScheme.colorScheme = colorScheme - buttonScheme.typographyScheme = typographyScheme + buttonScheme.colorScheme = containerScheme.colorScheme + buttonScheme.typographyScheme = containerScheme.typographyScheme MDCContainedButtonThemer.applyScheme(buttonScheme, to: alignmentButton) alignmentButton.setTitle("Change Alignment", for: .normal) @@ -65,8 +65,8 @@ extension TabBarIconSwiftExample { appBarViewController.headerView.minMaxHeightIncludesSafeArea = false appBarViewController.headerView.minimumHeight = 56 + 72 appBarViewController.headerView.tintColor = MDCPalette.blue.tint500 - MDCAppBarColorThemer.applyColorScheme(colorScheme, to: appBarViewController) - MDCAppBarTypographyThemer.applyTypographyScheme(typographyScheme, to: appBarViewController) + MDCAppBarColorThemer.applyColorScheme(containerScheme.colorScheme, to: appBarViewController) + MDCAppBarTypographyThemer.applyTypographyScheme(containerScheme.typographyScheme, to: appBarViewController) appBarViewController.headerStackView.bottomBar = self.tabBar appBarViewController.headerStackView.setNeedsLayout() diff --git a/components/Tabs/examples/supplemental/TabBarIndicatorTemplateExampleSupplemental.swift b/components/Tabs/examples/supplemental/TabBarIndicatorTemplateExampleSupplemental.swift index 42a561a1200..24ba3edffa1 100644 --- a/components/Tabs/examples/supplemental/TabBarIndicatorTemplateExampleSupplemental.swift +++ b/components/Tabs/examples/supplemental/TabBarIndicatorTemplateExampleSupplemental.swift @@ -22,8 +22,8 @@ extension TabBarIndicatorTemplateExample { private func themeButton(_ button: MDCButton) { let buttonScheme = MDCButtonScheme() - buttonScheme.colorScheme = colorScheme - buttonScheme.typographyScheme = typographyScheme + buttonScheme.colorScheme = containerScheme.colorScheme + buttonScheme.typographyScheme = containerScheme.typographyScheme MDCContainedButtonThemer.applyScheme(buttonScheme, to: button) } diff --git a/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.h b/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.h index 0faa6fae9c8..8f7cebfcb39 100644 --- a/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.h +++ b/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.h @@ -22,13 +22,13 @@ #import "MDCTabBarDisplayDelegate.h" #import "MaterialAppBar.h" #import "MaterialCollections.h" -#import "MaterialColorScheme.h" +#import "MaterialContainerScheme.h" #import "MaterialTabs.h" @interface TabBarTextOnlyExample : MDCCollectionViewController @property(nonatomic, nullable) MDCAppBarViewController *appBarViewController; -@property(nonatomic, nullable) MDCSemanticColorScheme *colorScheme; +@property(nonatomic, nullable) MDCContainerScheme *containerScheme; @property(nonatomic, nullable) MDCTabBar *tabBar; @property(nonatomic, nullable) NSArray *choices; @end diff --git a/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.h b/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.h index 5087017c306..3300d274a18 100644 --- a/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.h +++ b/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.h @@ -19,14 +19,14 @@ #import #import "MaterialButtons+ButtonThemer.h" -#import "MaterialColorScheme.h" +#import "MaterialContainerScheme.h" #import "MaterialTabs.h" #import "MaterialTypographyScheme.h" typedef void (^MDCButtonActionBlock)(void); @interface TabBarViewControllerExample : MDCTabBarViewController -@property(nonatomic, strong, nullable) MDCSemanticColorScheme *colorScheme; +@property(nonatomic, strong, nullable) MDCContainerScheme *containerScheme; @property(nonatomic, strong, nullable) MDCTypographyScheme *typographyScheme; @end diff --git a/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.m b/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.m index d6675e80898..a2de6fdc13b 100644 --- a/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.m +++ b/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.m @@ -152,8 +152,8 @@ - (void)setupTabBarColors { - (nonnull NSArray *)constructExampleViewControllers { NSBundle *bundle = [NSBundle bundleForClass:[TabBarViewControllerExample class]]; MDCButtonScheme *buttonScheme = [[MDCButtonScheme alloc] init]; - buttonScheme.colorScheme = self.colorScheme; - buttonScheme.typographyScheme = self.typographyScheme; + buttonScheme.colorScheme = self.containerScheme.colorScheme; + buttonScheme.typographyScheme = self.containerScheme.typographyScheme; TBVCSampleViewController *child1 = [TBVCSampleViewController sampleWithTitle:@"One" color:UIColor.redColor]; @@ -169,7 +169,7 @@ - (nonnull NSArray *)constructExampleViewControllers { TBVCSampleViewController *vc = [TBVCSampleViewController sampleWithTitle:@"Push&Hide" color:UIColor.grayColor]; - vc.colorScheme = strongSelf.colorScheme; + vc.colorScheme = strongSelf.containerScheme.colorScheme; vc.typographyScheme = strongSelf.typographyScheme; [strongSelf.navigationController pushViewController:vc animated:YES]; }]; @@ -190,7 +190,7 @@ - (nonnull NSArray *)constructExampleViewControllers { NSArray *viewControllers = @[ child1, child2, child3 ]; for (TBVCSampleViewController *vc in viewControllers) { - vc.colorScheme = self.colorScheme; + vc.colorScheme = self.containerScheme.colorScheme; vc.typographyScheme = self.typographyScheme; } return viewControllers; diff --git a/components/Tabs/src/FontThemer/MDCTabBarFontThemer.h b/components/Tabs/src/FontThemer/MDCTabBarFontThemer.h index a54967c7caa..868b7aade70 100644 --- a/components/Tabs/src/FontThemer/MDCTabBarFontThemer.h +++ b/components/Tabs/src/FontThemer/MDCTabBarFontThemer.h @@ -24,10 +24,8 @@ details on replacement APIs. Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions */ -@interface MDCTabBarFontThemer : NSObject -@end - -@interface MDCTabBarFontThemer (ToBeDeprecated) +__deprecated_msg("Please use the theming extension instead.") @interface MDCTabBarFontThemer + : NSObject /** Applies a font scheme to theme a MDCTabBar. @@ -39,6 +37,8 @@ extension. Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions */ -+ (void)applyFontScheme:(nonnull id)fontScheme toTabBar:(nonnull MDCTabBar *)tabBar; ++ (void)applyFontScheme:(nonnull id)fontScheme + toTabBar:(nonnull MDCTabBar *)tabBar + __deprecated_msg("Please use the theming extension instead."); @end diff --git a/components/Tabs/src/FontThemer/MDCTabBarFontThemer.m b/components/Tabs/src/FontThemer/MDCTabBarFontThemer.m index 3639f56aa7a..8a8440bcc24 100644 --- a/components/Tabs/src/FontThemer/MDCTabBarFontThemer.m +++ b/components/Tabs/src/FontThemer/MDCTabBarFontThemer.m @@ -14,7 +14,10 @@ #import "MDCTabBarFontThemer.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" @implementation MDCTabBarFontThemer +#pragma clang diagnostic pop + (void)applyFontScheme:(id)fontScheme toTabBar:(MDCTabBar *)tabBar { tabBar.selectedItemTitleFont = fontScheme.button; diff --git a/components/TextFields/src/ColorThemer/MDCTextFieldColorThemer.h b/components/TextFields/src/ColorThemer/MDCTextFieldColorThemer.h index 317fcc0a291..d6e5947b557 100644 --- a/components/TextFields/src/ColorThemer/MDCTextFieldColorThemer.h +++ b/components/TextFields/src/ColorThemer/MDCTextFieldColorThemer.h @@ -19,15 +19,9 @@ /** The Material Design color system's text field themer. - - @warning This API will eventually be deprecated. See the individual method documentation for - details on replacement APIs. - Learn more at docs/theming.md#migration-guide-themers-to-theming-extensions */ -@interface MDCTextFieldColorThemer : NSObject -@end - -@interface MDCTextFieldColorThemer (ToBeDeprecated) +__deprecated_msg("Please use the MaterialTextFields+Theming instead.") + @interface MDCTextFieldColorThemer : NSObject /** Applies a color scheme to theme MDCTextField in MDCTextInputController. diff --git a/components/private/ThumbTrack/src/MDCThumbTrack.h b/components/private/ThumbTrack/src/MDCThumbTrack.h index b11fe707d1c..351934d5d94 100644 --- a/components/private/ThumbTrack/src/MDCThumbTrack.h +++ b/components/private/ThumbTrack/src/MDCThumbTrack.h @@ -336,7 +336,12 @@ typedef NS_ENUM(NSUInteger, MDCThumbDiscreteDotVisibility) { enableRippleBehavior to YES, and then use thumbRippleMaximumRadius instead. Learn more at https://github.com/material-components/material-components-ios/tree/develop/components/Ink#migration-guide-ink-to-ripple */ -@property(nonatomic, assign) CGFloat thumbMaxRippleRadius; +@property(nonatomic, assign) CGFloat thumbMaxRippleRadius __deprecated_msg( + "Opt-in to Ripple by setting enableRippleBehavior to YES, and then use " + "thumbRippleMaximumRadius instead. Learn more at " + "https://github.com/material-components/material-components-ios/tree/develop/components/" + "Ink#migration-guide-ink-to-ripple"); +; @end diff --git a/components/private/ThumbTrack/src/MDCThumbTrack.m b/components/private/ThumbTrack/src/MDCThumbTrack.m index de83a9d4947..6ddb54511af 100644 --- a/components/private/ThumbTrack/src/MDCThumbTrack.m +++ b/components/private/ThumbTrack/src/MDCThumbTrack.m @@ -584,13 +584,19 @@ - (void)setDisplayThumbRadius:(CGFloat)thumbRadius { 2 * thumbRadius, 2 * thumbRadius); } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" - (CGFloat)thumbMaxRippleRadius { return _touchController.defaultInkView.maxRippleRadius; } +#pragma clang diagnostic pop +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-implementations" - (void)setThumbMaxRippleRadius:(CGFloat)thumbMaxRippleRadius { _touchController.defaultInkView.maxRippleRadius = thumbMaxRippleRadius; } +#pragma clang diagnostic pop - (CGFloat)thumbRippleMaximumRadius { return _rippleView.maximumRadius; diff --git a/components/schemes/Shape/BUILD b/components/schemes/Shape/BUILD index 17fa0637358..699c337b656 100644 --- a/components/schemes/Shape/BUILD +++ b/components/schemes/Shape/BUILD @@ -47,7 +47,6 @@ mdc_examples_objc_library( "//components/Cards:ShapeThemer", "//components/Cards:Theming", "//components/Chips", - "//components/Chips:ShapeThemer", "//components/Chips:Theming", "//components/ShapeLibrary", "//components/schemes/Color", diff --git a/components/schemes/Shape/examples/MDCShapeSchemeExampleViewController.m b/components/schemes/Shape/examples/MDCShapeSchemeExampleViewController.m index 9686c790655..30db65f9f14 100644 --- a/components/schemes/Shape/examples/MDCShapeSchemeExampleViewController.m +++ b/components/schemes/Shape/examples/MDCShapeSchemeExampleViewController.m @@ -15,7 +15,6 @@ #import "MDCShapeSchemeExampleViewController.h" #import "supplemental/MDCBottomSheetControllerShapeThemerDefaultMapping.h" -#import "supplemental/MDCChipViewShapeThemerDefaultMapping.h" #import "supplemental/MDCFloatingButtonShapeThemerDefaultMapping.h" #import "supplemental/MDCShapeExamplesDummyCollectionViewController.h" @@ -31,7 +30,6 @@ #import "MaterialCards+ShapeThemer.h" #import "MaterialCards+Theming.h" #import "MaterialCards.h" -#import "MaterialChips+ShapeThemer.h" #import "MaterialChips+Theming.h" #import "MaterialChips.h" #import "MaterialColorScheme.h" @@ -124,6 +122,12 @@ - (void)initializeComponentry { self.floatingButton.translatesAutoresizingMaskIntoConstraints = NO; [self.componentContentView addSubview:self.floatingButton]; + self.card = [[MDCCard alloc] init]; + self.card.translatesAutoresizingMaskIntoConstraints = NO; + [self.card applyThemeWithScheme:self.containerScheme]; + self.card.backgroundColor = _colorScheme.primaryColor; + [self.componentContentView addSubview:self.card]; + self.chipView = [[MDCChipView alloc] init]; self.chipView.titleLabel.text = @"Material"; self.chipView.imageView.image = [self faceImage]; @@ -133,12 +137,6 @@ - (void)initializeComponentry { [self.chipView applyThemeWithScheme:self.containerScheme]; [self.componentContentView addSubview:self.chipView]; - self.card = [[MDCCard alloc] init]; - self.card.translatesAutoresizingMaskIntoConstraints = NO; - [self.card applyThemeWithScheme:self.containerScheme]; - self.card.backgroundColor = _colorScheme.primaryColor; - [self.componentContentView addSubview:self.card]; - NSArray *cardConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[card]-|" options:0 @@ -335,18 +333,30 @@ - (void)updateComponentShapesWithBaselineOverrides:(BOOL)baselineOverrides { // We don't want baseline overrides. [MDCBottomSheetControllerShapeThemerDefaultMapping applyShapeScheme:_shapeScheme toBottomSheetController:self.bottomSheetController]; - [MDCChipViewShapeThemerDefaultMapping applyShapeScheme:_shapeScheme toChipView:self.chipView]; + [MDCShapeSchemeExampleViewController applyShapeScheme:_shapeScheme toChipView:self.chipView]; [MDCFloatingButtonShapeThemerDefaultMapping applyShapeScheme:_shapeScheme toButton:self.floatingButton]; } else { // We do want baseline overrides. [MDCBottomSheetControllerShapeThemer applyShapeScheme:_shapeScheme toBottomSheetController:self.bottomSheetController]; - [MDCChipViewShapeThemer applyShapeScheme:_shapeScheme toChipView:self.chipView]; + [self.chipView applyThemeWithScheme:self.containerScheme]; [MDCFloatingButtonShapeThemer applyShapeScheme:_shapeScheme toButton:self.floatingButton]; } } +#pragma mark - Support + ++ (void)applyShapeScheme:(nonnull id)shapeScheme + toChipView:(nonnull MDCChipView *)chipView { + MDCRectangleShapeGenerator *rectangleShape = [[MDCRectangleShapeGenerator alloc] init]; + rectangleShape.topLeftCorner = shapeScheme.smallComponentShape.topLeftCorner; + rectangleShape.topRightCorner = shapeScheme.smallComponentShape.topRightCorner; + rectangleShape.bottomLeftCorner = shapeScheme.smallComponentShape.bottomLeftCorner; + rectangleShape.bottomRightCorner = shapeScheme.smallComponentShape.bottomRightCorner; + chipView.shapeGenerator = rectangleShape; +} + @end #pragma mark - Catalog by convention diff --git a/components/schemes/Shape/examples/supplemental/MDCChipViewShapeThemerDefaultMapping.h b/components/schemes/Shape/examples/supplemental/MDCChipViewShapeThemerDefaultMapping.h deleted file mode 100644 index ad2f9bb7dcc..00000000000 --- a/components/schemes/Shape/examples/supplemental/MDCChipViewShapeThemerDefaultMapping.h +++ /dev/null @@ -1,33 +0,0 @@ -// 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 - -#import "MaterialChips+ShapeThemer.h" - -/** - The Material Design shape system's themer for instances of MDCChipView. - */ -@interface MDCChipViewShapeThemerDefaultMapping : MDCChipViewShapeThemer - -/** - Applies a shape scheme's properties to an MDCChipView. - - @param shapeScheme The shape scheme to apply to the component instance. - @param chipView A component instance to which the shape scheme should be applied. - */ -+ (void)applyShapeScheme:(nonnull id)shapeScheme - toChipView:(nonnull MDCChipView *)chipView; - -@end diff --git a/components/schemes/Shape/examples/supplemental/MDCChipViewShapeThemerDefaultMapping.m b/components/schemes/Shape/examples/supplemental/MDCChipViewShapeThemerDefaultMapping.m deleted file mode 100644 index f551144d48e..00000000000 --- a/components/schemes/Shape/examples/supplemental/MDCChipViewShapeThemerDefaultMapping.m +++ /dev/null @@ -1,29 +0,0 @@ -// 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 "MDCChipViewShapeThemerDefaultMapping.h" - -@implementation MDCChipViewShapeThemerDefaultMapping - -+ (void)applyShapeScheme:(nonnull id)shapeScheme - toChipView:(nonnull MDCChipView *)chipView { - MDCRectangleShapeGenerator *rectangleShape = [[MDCRectangleShapeGenerator alloc] init]; - rectangleShape.topLeftCorner = shapeScheme.smallComponentShape.topLeftCorner; - rectangleShape.topRightCorner = shapeScheme.smallComponentShape.topRightCorner; - rectangleShape.bottomLeftCorner = shapeScheme.smallComponentShape.bottomLeftCorner; - rectangleShape.bottomRightCorner = shapeScheme.smallComponentShape.bottomRightCorner; - chipView.shapeGenerator = rectangleShape; -} - -@end diff --git a/demos/supplemental/RemoteImageServiceForMDCDemos.podspec b/demos/supplemental/RemoteImageServiceForMDCDemos.podspec index c3a99b9ad12..92dd1087fa0 100644 --- a/demos/supplemental/RemoteImageServiceForMDCDemos.podspec +++ b/demos/supplemental/RemoteImageServiceForMDCDemos.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RemoteImageServiceForMDCDemos" - s.version = "94.5.0" + s.version = "95.0.0" s.summary = "A helper image class for the MDC demos." s.description = "This spec is made for use in the MDC demos. It gets images via url." s.homepage = "https://github.com/material-components/material-components-ios"