Update ActivityIndicator Color Themer
MODIFY
MaterialComponents.podspec
MaterialComponents.podspec
@@ -56,7 +56,7 @@ Pod::Spec.new do |mdc|
extension.source_files = "components/ActivityIndicator/src/#{extension.base_name}/*.{h,m}"
extension.dependency "MaterialComponents/ActivityIndicator"
- extension.dependency "MaterialComponents/Themes"
+ extension.dependency "MaterialComponents/schemes/Color"
end
end

MODIFY
components/ActivityIndicator/BUILD
components/ActivityIndicator/BUILD
@@ -58,7 +58,7 @@ mdc_objc_library(
],
deps = [
":ActivityIndicator",
- "//components/Themes",
+ "//components/Schemes/Color",
],
visibility = ["//visibility:public"],
)

MODIFY
components/ActivityIndicator/src/ColorThemer/MDCActivityIndicatorColorThemer.h
components/ActivityIndicator/src/ColorThemer/MDCActivityIndicatorColorThemer.h
limitations under the License.
*/
-#import "MaterialThemes.h"
+#import "MaterialColorScheme.h"
#import "MaterialActivityIndicator.h"
/**
*/
@interface MDCActivityIndicatorColorThemer : NSObject
+/**
+ Applies a color scheme's properties to an MDCActivityIndicator.
+
+ @param colorScheme The color scheme to apply to MDCActivityIndicator.
+ @param activityIndicator An MDCActivityIndicator instance to which the color scheme should be
+ applied.
+ */
++ (void)applySemanticColorScheme:(nonnull id<MDCColorScheming>)colorScheme
+ toActivityIndicator:(nonnull MDCActivityIndicator *)activityIndicator;
+
+#pragma mark - Soon to be deprecated
+
/**
Applies a color scheme to theme a MDCActivityIndicator. Use a UIAppearance proxy to apply a color
scheme to all instances of MDCActivityIndicator.
+ This method will soon be deprecated. Consider using +applySemanticColorScheme:toActivityIndicator:
+ instead.
+
@param colorScheme The color scheme to apply to MDCActivityIndicator.
@param activityIndicator A MDCActivityIndicator instance to apply a color scheme.
*/

MODIFY
components/ActivityIndicator/src/ColorThemer/MDCActivityIndicatorColorThemer.m
components/ActivityIndicator/src/ColorThemer/MDCActivityIndicatorColorThemer.m
@implementation MDCActivityIndicatorColorThemer
++ (void)applySemanticColorScheme:(nonnull id<MDCColorScheming>)colorScheme
+ toActivityIndicator:(nonnull MDCActivityIndicator *)activityIndicator {
+ activityIndicator.cycleColors = @[ colorScheme.primaryColor ];
+}
+
+ (void)applyColorScheme:(id<MDCColorScheme>)colorScheme
toActivityIndicator:(MDCActivityIndicator *)activityIndicator {
activityIndicator.cycleColors = @[ colorScheme.primaryColor ];

ADD
components/ActivityIndicator/tests/unit/ActivityIndicatorColorThemerTests.swift
+/*
+ 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 XCTest
+import MaterialComponents.MaterialActivityIndicator
+import MaterialComponents.MDCActivityIndicatorColorThemer
+
+class ActivityIndicatorColorThemerTests: XCTestCase {
+
+ func testColorThemerChangesTheBackgroundColor() {
+ // Given
+ let colorScheme = MDCSemanticColorScheme()
+ let activityIndicator = MDCActivityIndicator()
+ colorScheme.primaryColor = .red
+ activityIndicator.cycleColors = [ .white ]
+
+ // When
+ MDCActivityIndicatorColorThemer.applySemanticColorScheme(colorScheme, to: activityIndicator)
+
+ // Then
+ XCTAssertEqual(activityIndicator.cycleColors, [ colorScheme.primaryColor ])
+ }
+}

Update ActivityIndicator Color Themer (#3259)