Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tabs] Implementing TabBar Typography Themer. (#3278)
* Implementing TabBar Typography Themer. * add typographyScheme to a tabbar example. * couple of nits.
- Loading branch information
1 parent
42de89c
commit 207e59d
Showing
7 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
components/Tabs/src/TypographyThemer/MDCTabBarTypographyThemer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
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 "MaterialTabs.h" | ||
#import "MaterialTypographyScheme.h" | ||
|
||
/** | ||
Used to apply a typography scheme to theme MDCTabBar. | ||
*/ | ||
@interface MDCTabBarTypographyThemer : NSObject | ||
|
||
/** | ||
Applies a typography scheme to theme a MDCTabBar. | ||
@param typographyScheme The typography scheme to apply to MDCTabBar. | ||
@param tabBar A MDCTabBar instance to apply a color scheme. | ||
*/ | ||
+ (void)applyTypographyScheme:(nonnull id<MDCTypographyScheming>)typographyScheme | ||
toTabBar:(nonnull MDCTabBar *)tabBar; | ||
|
||
@end |
27 changes: 27 additions & 0 deletions
27
components/Tabs/src/TypographyThemer/MDCTabBarTypographyThemer.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
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 "MDCTabBarTypographyThemer.h" | ||
|
||
@implementation MDCTabBarTypographyThemer | ||
|
||
+ (void)applyTypographyScheme:(nonnull id<MDCTypographyScheming>)typographyScheme | ||
toTabBar:(nonnull MDCTabBar *)tabBar { | ||
tabBar.selectedItemTitleFont = typographyScheme.button; | ||
tabBar.unselectedItemTitleFont = typographyScheme.button; | ||
} | ||
|
||
@end |
36 changes: 36 additions & 0 deletions
36
components/Tabs/tests/unit/MDCTabBarTypographyThemerTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
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 "MaterialTabs.h" | ||
#import "MDCTabBarTypographyThemer.h" | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
@interface MDCTabBarTypographyThemerTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation MDCTabBarTypographyThemerTests | ||
|
||
- (void)testTabBarFontThemerApplyFontSchemeProperly { | ||
MDCTypographyScheme *typographyScheme = [[MDCTypographyScheme alloc] init]; | ||
MDCTabBar *tabBar = [[MDCTabBar alloc] init]; | ||
[MDCTabBarTypographyThemer applyTypographyScheme:typographyScheme toTabBar:tabBar]; | ||
XCTAssertEqualObjects(tabBar.selectedItemTitleFont, typographyScheme.button); | ||
XCTAssertEqualObjects(tabBar.unselectedItemTitleFont, typographyScheme.button); | ||
} | ||
|
||
@end |