BottomNavigationBar Typography Implementation,
Tests and example added.
MODIFY
MaterialComponents.podspec
MaterialComponents.podspec
@@ -142,6 +142,13 @@ Pod::Spec.new do |mdc|
extension.dependency "MaterialComponents/BottomNavigation"
extension.dependency "MaterialComponents/Themes"
end
+ component.subspec "TypographyThemer" do |extension|
+ extension.ios.deployment_target = '8.0'
+ extension.public_header_files = "components/BottomNavigation/src/TypographyThemer/*.h"
+ extension.source_files = "components/BottomNavigation/src/TypographyThemer/*.{h,m}"
+ extension.dependency "MaterialComponents/BottomNavigation"
+ extension.dependency "MaterialComponents/schemes/Typography"
+ end
end
mdc.subspec "BottomSheet" do |component|

MODIFY
components/BottomNavigation/BUILD
components/BottomNavigation/BUILD
@@ -63,6 +63,22 @@ mdc_objc_library(
visibility = ["//visibility:public"],
)
+
+mdc_objc_library(
+ name = "TypographyThemer",
+ srcs = native.glob(["src/TypographyThemer/*.m"]),
+ hdrs = native.glob(["src/TypographyThemer/*.h"]),
+ includes = ["src/TypographyThemer"],
+ sdk_frameworks = [
+ "Foundation",
+ ],
+ deps = [
+ ":BottomNavigation",
+ "//components/schemes/Typography",
+ ],
+ visibility = ["//visibility:public"],
+)
+
mdc_objc_library(
name = "private",
hdrs = native.glob(["src/private/*.h"]),
@@ -84,6 +100,7 @@ mdc_objc_library(
deps = [
":BottomNavigation",
":ColorThemer",
+ ":TypographyThemer",
":private",
],
visibility = ["//visibility:private"],

MODIFY
components/BottomNavigation/examples/BottomNavigationTypicalUseExample.m
components/BottomNavigation/examples/BottomNavigationTypicalUseExample.m
#import "MaterialPalettes.h"
#import "MaterialThemes.h"
#import "MDCBottomNavigationBarColorThemer.h"
+#import "MDCBottomNavigationBarTypographyThemer.h"
@interface BottomNavigationTypicalUseExample () <MDCBottomNavigationBarDelegate>
_bottomNavBar.titleVisibility = MDCBottomNavigationBarTitleVisibilitySelected;
_bottomNavBar.alignment = MDCBottomNavigationBarAlignmentJustifiedAdjacentTitles;
_bottomNavBar.delegate = self;
+ MDCTypographyScheme *typographyScheme = [[MDCTypographyScheme alloc] init];
+ [MDCBottomNavigationBarTypographyThemer applyTypographyScheme:typographyScheme
+ toBottomNavigationBar:_bottomNavBar];
[self.view addSubview:_bottomNavBar];
UITabBarItem *tabBarItem1 =

ADD
components/BottomNavigation/src/TypographyThemer/MDCBottomNavigationBarTypographyThemer.h
+/*
+ Copyright 2018-present the Material Components for iOS authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#import <UIKit/UIKit.h>
+
+#import "MaterialBottomNavigation.h"
+#import "MaterialTypographyScheme.h"
+
+
+/**
+ Applies a Typography scheme to an MDCBottomNavigationBar.
+ */
+@interface MDCBottomNavigationBarTypographyThemer : NSObject
+
+/**
+ Applies a typography scheme to theme an MDCBottomNavigationBar.
+
+ @param typographyScheme The typography scheme to apply to an MDCBottomNavigationBar.
+ @param bottomNavigationBar An MDCBottomNavigationBar instance to apply a typography scheme to.
+ */
++ (void)applyTypographyScheme:(nonnull id<MDCTypographyScheming>)typographyScheme
+ toBottomNavigationBar:(nonnull MDCBottomNavigationBar *)bottomNavigationBar;
+
+@end

ADD
components/BottomNavigation/src/TypographyThemer/MDCBottomNavigationBarTypographyThemer.m
+/*
+ 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 "MDCBottomNavigationBarTypographyThemer.h"
+
+@implementation MDCBottomNavigationBarTypographyThemer
+
++ (void)applyTypographyScheme:(nonnull id<MDCTypographyScheming>)typographyScheme
+ toBottomNavigationBar:(nonnull MDCBottomNavigationBar *)bottomNavigationBar {
+ bottomNavigationBar.itemTitleFont = typographyScheme.caption;
+}
+
+@end

ADD
components/BottomNavigation/tests/unit/BottomNavigationTypographyThemerTests.m
+/*
+ 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/XCTest.h>
+#import "MDCBottomNavigationBarTypographyThemer.h"
+#import "MaterialBottomNavigation.h"
+
+@interface BottomNavigationTypographyThemerTests : XCTestCase
+
+@end
+
+@implementation BottomNavigationTypographyThemerTests
+
+- (void)testTypogrpahyThemer {
+ MDCTypographyScheme *typographyScheme = [[MDCTypographyScheme alloc] init];
+ MDCBottomNavigationBar *bottomBar = [[MDCBottomNavigationBar alloc] initWithFrame:CGRectZero];
+ UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:@"1" image:nil tag:0];
+ UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:@"2" image:nil tag:0];
+ bottomBar.itemTitleFont = [UIFont systemFontOfSize:31];
+ bottomBar.items = @[item1, item2];
+
+ [MDCBottomNavigationBarTypographyThemer applyTypographyScheme:typographyScheme
+ toBottomNavigationBar:bottomBar];
+
+ XCTAssertEqual(bottomBar.itemTitleFont, typographyScheme.caption);
+}
+
+@end

BottomNavigationBar Typography Implementation, (#3311)

Tests and example added.