Skip to content

Commit 372d6b2

Browse files
author
Robert Moore
authored
No longer using -init for Color Scheme. (material-components#5734)
{MDC iOS} No longer using `-init` for Color Scheme. Based on the discussions in go/mdc-ios-theming, we should not use the `-init` default initializer. Instead, we should use an explicit set of defaults. Search regex: '\[\[MDCSemanticColorScheme alloc\] init\]'
1 parent d90bf4c commit 372d6b2

File tree

110 files changed

+220
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+220
-129
lines changed

components/ActionSheet/examples/ActionSheetTypicalUse.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ - (instancetype)init {
3333
self = [super init];
3434
if (self) {
3535
self.title = @"Action Sheet";
36-
_colorScheme = [[MDCSemanticColorScheme alloc] init];
36+
_colorScheme =
37+
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
3738
_typographyScheme = [[MDCTypographyScheme alloc] init];
3839
_showButton = [[MDCButton alloc] init];
3940
_buttonScheme = [[MDCButtonScheme alloc] init];

components/ActionSheet/src/ActionSheetThemer/MDCActionSheetScheme.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ @implementation MDCActionSheetScheme
1919
- (instancetype)init {
2020
self = [super init];
2121
if (self) {
22-
_colorScheme = [[MDCSemanticColorScheme alloc] init];
22+
_colorScheme =
23+
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
2324
_typographyScheme = [[MDCTypographyScheme alloc] init];
2425
}
2526
return self;

components/ActionSheet/tests/unit/MDCActionSheetThemeTest.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ - (void)setUp {
4848
[super setUp];
4949

5050
self.actionSheet = [[MDCActionSheetController alloc] init];
51-
self.colorScheme = [[MDCSemanticColorScheme alloc] init];
51+
self.colorScheme =
52+
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
5253
UIColor *surface = UIColor.blueColor;
5354
UIColor *onSurface = UIColor.redColor;
5455
self.colorScheme.surfaceColor = surface;
@@ -74,7 +75,8 @@ - (void)testDefaultScheme {
7475
// Given
7576
MDCActionSheetScheme *defaultScheme = [[MDCActionSheetScheme alloc] init];
7677
MDCTypographyScheme *defaultTypographyScheme = [[MDCTypographyScheme alloc] init];
77-
MDCSemanticColorScheme *defaultColorScheme = [[MDCSemanticColorScheme alloc] init];
78+
MDCSemanticColorScheme *defaultColorScheme =
79+
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
7880

7981
// Then
8082
XCTAssertEqualObjects(defaultScheme.typographyScheme.subtitle1,

components/ActivityIndicator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ MDCActivityIndicatorColorThemer.applySemanticColorScheme(colorScheme, to: activi
242242
#import "MaterialActivityIndicator+ColorThemer.h"
243243

244244
// Step 2: Create or get a color scheme
245-
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
245+
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
246246

247247
// Step 3: Apply the color scheme to your component
248248
[MDCActivityIndicatorColorThemer applySemanticColorScheme:colorScheme

components/ActivityIndicator/docs/color-theming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ MDCActivityIndicatorColorThemer.applySemanticColorScheme(colorScheme, to: activi
3030
#import "MaterialActivityIndicator+ColorThemer.h"
3131

3232
// Step 2: Create or get a color scheme
33-
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
33+
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
3434

3535
// Step 3: Apply the color scheme to your component
3636
[MDCActivityIndicatorColorThemer applySemanticColorScheme:colorScheme

components/ActivityIndicator/examples/ActivityIndicatorExample.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ - (id)init {
3333
self = [super init];
3434
if (self) {
3535
self.title = @"Activity Indicator";
36-
self.colorScheme = [[MDCSemanticColorScheme alloc] init];
36+
self.colorScheme =
37+
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
3738
}
3839
return self;
3940
}

components/ActivityIndicator/examples/ActivityIndicatorTransitionExample.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ - (id)init {
4242
self = [super init];
4343
if (self) {
4444
self.title = @"Activity Indicator Transition";
45-
self.colorScheme = [[MDCSemanticColorScheme alloc] init];
45+
self.colorScheme =
46+
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
4647
self.typographyScheme = [[MDCTypographyScheme alloc] init];
4748
}
4849
return self;

components/AppBar/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ MDCAppBarColorThemer.applySemanticColorScheme(colorScheme, to: component)
668668
#import "MaterialAppBar+ColorThemer.h"
669669

670670
// Step 2: Create or get a color scheme
671-
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
671+
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
672672

673673
// Step 3: Apply the color scheme to your component
674674
[MDCAppBarColorThemer applySemanticColorScheme:colorScheme

components/AppBar/docs/color-theming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ MDCAppBarColorThemer.applySemanticColorScheme(colorScheme, to: component)
2828
#import "MaterialAppBar+ColorThemer.h"
2929

3030
// Step 2: Create or get a color scheme
31-
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] init];
31+
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
3232

3333
// Step 3: Apply the color scheme to your component
3434
[MDCAppBarColorThemer applySemanticColorScheme:colorScheme

components/AppBar/examples/AppBarImageryExample.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ - (void)dealloc {
3232
- (id)init {
3333
self = [super init];
3434
if (self) {
35-
_colorScheme = [[MDCSemanticColorScheme alloc] init];
35+
_colorScheme =
36+
[[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];
3637

3738
_appBarViewController = [[MDCAppBarViewController alloc] init];
3839

0 commit comments

Comments
 (0)