From fdfeaf6de155a82ae87f607b1bdcfec213b6bb4b Mon Sep 17 00:00:00 2001 From: Wenyu Zhang Date: Fri, 22 Mar 2024 14:24:53 -0700 Subject: [PATCH] Delete TabBar Theming. PiperOrigin-RevId: 618287193 --- .../examples/BottomNavigationBarExample.m | 137 ----- components/Tabs/examples/TabBarIconExample.m | 184 ------- .../Tabs/examples/TabBarIconExample.swift | 142 ------ .../TabBarIndicatorTemplateExample.swift | 186 ------- .../examples/TabBarInterfaceBuilderExample.m | 121 ----- .../Tabs/examples/TabBarTextOnlyExample.m | 158 ------ .../examples/TabBarViewControllerExample.m | 49 -- ...BarViewControllerInterfaceBuilderExample.m | 62 --- .../TabBarIconExampleSupplemental.h | 44 -- .../TabBarIconExampleSupplemental.m | 282 ---------- .../TabBarIconExampleSupplemental.swift | 300 ----------- ...IndicatorTemplateExampleSupplemental.swift | 134 ----- .../TabBarTextOnlyExampleSupplemental.h | 40 -- .../TabBarTextOnlyExampleSupplemental.m | 127 ----- .../TabBarViewControllerExampleSupplemental.h | 52 -- .../TabBarViewControllerExampleSupplemental.m | 213 -------- .../src/Theming/MDCTabBar+MaterialTheming.h | 38 -- .../src/Theming/MDCTabBar+MaterialTheming.m | 75 --- .../Tabs/src/Theming/MaterialTabs+Theming.h | 15 - .../MDCTabBarDynamicColorSnapshotTests.m | 183 ------- .../MDCTabBarExtendedAlignmentSnapshotTests.m | 482 ------------------ .../MDCTabBarSizeClassDelegateSnapshotTests.m | 409 --------------- .../MDCTabBar_MaterialThemingSnapshotTests.m | 131 ----- components/Tabs/tests/unit/TabsThemingTests.m | 185 ------- 24 files changed, 3749 deletions(-) delete mode 100644 components/Tabs/examples/BottomNavigationBarExample.m delete mode 100644 components/Tabs/examples/TabBarIconExample.m delete mode 100644 components/Tabs/examples/TabBarIconExample.swift delete mode 100644 components/Tabs/examples/TabBarIndicatorTemplateExample.swift delete mode 100644 components/Tabs/examples/TabBarInterfaceBuilderExample.m delete mode 100644 components/Tabs/examples/TabBarTextOnlyExample.m delete mode 100644 components/Tabs/examples/TabBarViewControllerExample.m delete mode 100644 components/Tabs/examples/TabBarViewControllerInterfaceBuilderExample.m delete mode 100644 components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.h delete mode 100644 components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.m delete mode 100644 components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.swift delete mode 100644 components/Tabs/examples/supplemental/TabBarIndicatorTemplateExampleSupplemental.swift delete mode 100644 components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.h delete mode 100644 components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.m delete mode 100644 components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.h delete mode 100644 components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.m delete mode 100644 components/Tabs/src/Theming/MDCTabBar+MaterialTheming.h delete mode 100644 components/Tabs/src/Theming/MDCTabBar+MaterialTheming.m delete mode 100644 components/Tabs/src/Theming/MaterialTabs+Theming.h delete mode 100644 components/Tabs/tests/snapshot/MDCTabBarDynamicColorSnapshotTests.m delete mode 100644 components/Tabs/tests/snapshot/MDCTabBarExtendedAlignmentSnapshotTests.m delete mode 100644 components/Tabs/tests/snapshot/MDCTabBarSizeClassDelegateSnapshotTests.m delete mode 100644 components/Tabs/tests/snapshot/Theming/MDCTabBar_MaterialThemingSnapshotTests.m delete mode 100644 components/Tabs/tests/unit/TabsThemingTests.m diff --git a/components/Tabs/examples/BottomNavigationBarExample.m b/components/Tabs/examples/BottomNavigationBarExample.m deleted file mode 100644 index da3890ea648..00000000000 --- a/components/Tabs/examples/BottomNavigationBarExample.m +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2016-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 "MaterialContainerScheme.h" -#import "MaterialTabs+Theming.h" -#import "MaterialTabs.h" - -@interface BottomNavigationBarExample : UIViewController -@property(nonatomic, strong) MDCContainerScheme *containerScheme; -@end - -@implementation BottomNavigationBarExample { - MDCTabBar *_bottomNavigationBar; - NSArray *_colors; -} - -- (id)init { - self = [super init]; - if (self) { - _containerScheme = [[MDCContainerScheme alloc] init]; - } - return self; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - _bottomNavigationBar = [[MDCTabBar alloc] initWithFrame:CGRectZero]; - _bottomNavigationBar.translatesAutoresizingMaskIntoConstraints = NO; - _bottomNavigationBar.delegate = self; - [_bottomNavigationBar applyPrimaryThemeWithScheme:self.containerScheme]; - - _bottomNavigationBar.inkColor = [UIColor colorWithRed:0 - green:(CGFloat)0.5 - blue:0 - alpha:(CGFloat)0.15]; - - NSBundle *bundle = [NSBundle bundleForClass:[BottomNavigationBarExample class]]; - UIImage *infoImage = [UIImage imageNamed:@"TabBarDemo_ic_info" - inBundle:bundle - compatibleWithTraitCollection:nil]; - UIImage *starImage = [UIImage imageNamed:@"TabBarDemo_ic_star" - inBundle:bundle - compatibleWithTraitCollection:nil]; - _bottomNavigationBar.items = @[ - [[UITabBarItem alloc] initWithTitle:@"Red" image:infoImage tag:0], - [[UITabBarItem alloc] initWithTitle:@"Blue" image:starImage tag:0] - ]; - - _colors = @[ - [UIColor colorWithRed:0.5 green:0 blue:0 alpha:1], [UIColor colorWithRed:0 - green:0 - blue:0.5 - alpha:1] - ]; - - [self.view addSubview:_bottomNavigationBar]; - [self updateDisplay]; - - [NSLayoutConstraint constraintWithItem:_bottomNavigationBar - attribute:NSLayoutAttributeBottom - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeBottom - multiplier:1 - constant:0] - .active = YES; - [NSLayoutConstraint constraintWithItem:_bottomNavigationBar - attribute:NSLayoutAttributeLeft - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeLeft - multiplier:1 - constant:0] - .active = YES; - [NSLayoutConstraint constraintWithItem:_bottomNavigationBar - attribute:NSLayoutAttributeRight - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeRight - multiplier:1 - constant:0] - .active = YES; -} - -#pragma mark - MDCTabBarDelegate - -- (void)tabBar:(MDCTabBar *)tabBar didSelectItem:(UITabBarItem *)item { - [self updateDisplay]; -} - -#pragma mark - UIBarPositioningDelegate - -- (UIBarPosition)positionForBar:(id)bar { - return UIBarPositionBottom; -} - -#pragma mark - Private - -- (void)updateDisplay { - UITabBarItem *selectedItem = _bottomNavigationBar.selectedItem; - if (!selectedItem) { - return; - } - - NSUInteger selectedIndex = [_bottomNavigationBar.items indexOfObject:selectedItem]; - if (selectedIndex == NSNotFound) { - return; - } - - self.view.backgroundColor = _colors[selectedIndex]; -} - -@end - -@implementation BottomNavigationBarExample (CatalogByConvention) - -+ (NSDictionary *)catalogMetadata { - return @{ - @"breadcrumbs" : @[ @"Tab Bar", @"Bottom Navigation" ], - @"primaryDemo" : @NO, - @"presentable" : @NO, - }; -} - -@end diff --git a/components/Tabs/examples/TabBarIconExample.m b/components/Tabs/examples/TabBarIconExample.m deleted file mode 100644 index 86309d6e496..00000000000 --- a/components/Tabs/examples/TabBarIconExample.m +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2016-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 "MDCAppBarColorThemer.h" -#import "MDCAppBarViewController.h" -#import "MDCButton.h" -#import "MDCHeaderStackView.h" -#import "TabBarIconExampleSupplemental.h" - -#import "MDCTabBar.h" -#import "MDCTabBarAlignment.h" -#import "MDCTabBarItemAppearance.h" -#import "MDCTabBar+MaterialTheming.h" -#import "MDCSemanticColorScheme.h" -#import "MDCContainerScheme.h" - -@interface TabBarIconExample () -@property(nonatomic, strong) UIBarButtonItem *addStarButtonItem; -@end - -@implementation TabBarIconExample - -- (id)init { - self = [super init]; - if (self) { - _containerScheme = [[MDCContainerScheme alloc] init]; - } - return self; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setupExampleViews]; - - [self loadTabBar]; - - self.addStarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Add" - style:UIBarButtonItemStylePlain - target:self - action:@selector(incrementDidTouch:)]; -} - -#pragma mark - Action - -- (void)incrementDidTouch:(id)sender { - [self incrementStarBadge]; - - [self addStarCentered:NO]; -} - -- (void)incrementStarBadge { - // Increment numeric badge value. - UITabBarItem *starItem = self.tabBar.items[1]; - NSString *badgeValue = starItem.badgeValue; - if (badgeValue) { - NSInteger badgeNumber = badgeValue.integerValue; - if (badgeNumber > 0) { - // Update badge value directly - the cell should update immediately. - starItem.badgeValue = [NSNumberFormatter localizedStringFromNumber:@(badgeNumber + 1) - numberStyle:NSNumberFormatterNoStyle]; - } - } -} - -#pragma mark - Private - -- (void)loadTabBar { - MDCTabBar *tabBar = [[MDCTabBar alloc] init]; - tabBar.delegate = self; - tabBar.alignment = MDCTabBarAlignmentCenterSelected; - - NSBundle *bundle = [NSBundle bundleForClass:[TabBarIconExample class]]; - UIImage *infoImage = [UIImage imageNamed:@"TabBarDemo_ic_info" - inBundle:bundle - compatibleWithTraitCollection:nil]; - UIImage *starImage = [UIImage imageNamed:@"TabBarDemo_ic_star" - inBundle:bundle - compatibleWithTraitCollection:nil]; - tabBar.items = @[ - [[UITabBarItem alloc] initWithTitle:@"Info" image:infoImage tag:0], - [[UITabBarItem alloc] initWithTitle:@"Stars" image:starImage tag:0] - ]; - - // Give the second item a badge - [tabBar.items[1] setBadgeValue:@"1"]; - - [tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - - tabBar.inkColor = [[UIColor whiteColor] colorWithAlphaComponent:(CGFloat)0.1]; - tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - - self.tabBar = tabBar; - self.appBarViewController.headerStackView.bottomBar = self.tabBar; - [self.appBarViewController.headerStackView setNeedsLayout]; -} - -- (void)changeAlignment:(id)sender { - UIAlertController *sheet = - [UIAlertController alertControllerWithTitle:nil - message:nil - preferredStyle:UIAlertControllerStyleActionSheet]; - sheet.popoverPresentationController.sourceView = self.alignmentButton; - sheet.popoverPresentationController.sourceRect = self.alignmentButton.bounds; - [sheet addAction:[UIAlertAction actionWithTitle:@"Leading" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self setAlignment:MDCTabBarAlignmentLeading]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Center" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self setAlignment:MDCTabBarAlignmentCenter]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Justified" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self setAlignment:MDCTabBarAlignmentJustified]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Selected Center" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self setAlignment:MDCTabBarAlignmentCenterSelected]; - }]]; - [self presentViewController:sheet animated:YES completion:nil]; -} - -- (void)setAlignment:(MDCTabBarAlignment)alignment { - [self.tabBar setAlignment:alignment animated:YES]; -} - -#pragma mark - MDCTabBarDelegate - -- (void)tabBar:(MDCTabBar *)tabBar didSelectItem:(UITabBarItem *)item { - NSUInteger index = [tabBar.items indexOfObject:item]; - NSAssert(index != NSNotFound, @"The MDCTabBar does not contain the expected UITabBarItem."); - - [self.scrollView setContentOffset:CGPointMake(index * CGRectGetWidth(self.view.bounds), 0) - animated:YES]; - if (index == 0) { - self.navigationItem.rightBarButtonItem = nil; - } else { - self.navigationItem.rightBarButtonItem = self.addStarButtonItem; - } -} - -@end - -@implementation TabBarIconExample (SnapshotTestingByConvention) - -- (void)testDefaults { - // Given - MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init]; - self.containerScheme = containerScheme; - - // When - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; -} - -- (void)testDynamic201907ColorScheme { - // Given - MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init]; - containerScheme.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201907]; - self.containerScheme = containerScheme; - - // When - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - [MDCAppBarColorThemer applyColorScheme:self.containerScheme.colorScheme - toAppBarViewController:self.appBarViewController]; -} - -@end diff --git a/components/Tabs/examples/TabBarIconExample.swift b/components/Tabs/examples/TabBarIconExample.swift deleted file mode 100644 index 55832cd8b38..00000000000 --- a/components/Tabs/examples/TabBarIconExample.swift +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2016-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 -import MaterialComponents.MaterialAppBar -import MaterialComponents.MaterialButtons -import MaterialComponents.MaterialPalettes -import MaterialComponents.MaterialTabs -import MaterialComponents.MaterialTabs_Theming -import MaterialComponents.MaterialColorScheme -import MaterialComponents.MaterialTypographyScheme - -class TabBarIconSwiftExample: UIViewController { - - // MARK: Properties - var alignment: MDCTabBarAlignment { - get { - return tabBar.alignment - } - set(newAlignment) { - tabBar.setAlignment(newAlignment, animated: true) - } - } - - lazy var alignmentButton: MDCButton = self.setupAlignmentButton() - lazy var appBarViewController: MDCAppBarViewController = self.setupAppBar() - lazy var scrollView: UIScrollView = self.setupScrollView() - lazy var starPage: UIView = self.setupStarPage() - @objc var containerScheme = MDCContainerScheme() - - lazy var tabBar: MDCTabBar = { - let tabBar = MDCTabBar() - tabBar.delegate = self - tabBar.alignment = .centerSelected - - let bundle = Bundle(for: TabBarIconSwiftExample.self) - let info = UIImage.init(named: "TabBarDemo_ic_info", in: bundle, compatibleWith: nil) - let star = UIImage.init(named: "TabBarDemo_ic_star", in: bundle, compatibleWith: nil) - - tabBar.items = [ - UITabBarItem(title: "Info", image: info, tag: 0), - UITabBarItem(title: "Stars", image: star, tag: 0), - ] - tabBar.items[1].badgeValue = "1" - - tabBar.applyPrimaryTheme(withScheme: containerScheme) - - let blue = MDCPalette.blue.tint500 - tabBar.inkColor = blue - tabBar.itemAppearance = .titledImages - - return tabBar - }() - - // MARK: Methods - override func viewDidLoad() { - super.viewDidLoad() - - setupExampleViews() - - alignmentButton.addTarget( - self, - action: #selector(changeAlignmentDidTouch(sender:)), - for: .touchUpInside) - } - - @objc func changeAlignmentDidTouch(sender: UIButton) { - let sheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) - sheet.popoverPresentationController?.sourceView = self.alignmentButton - sheet.popoverPresentationController?.sourceRect = self.alignmentButton.bounds - sheet.addAction( - UIAlertAction( - title: "Leading", style: .default, - handler: { _ in - self.alignment = .leading - })) - sheet.addAction( - UIAlertAction( - title: "Center", style: .default, - handler: { _ in - self.alignment = .center - })) - sheet.addAction( - UIAlertAction( - title: "Justified", style: .default, - handler: { _ in - self.alignment = .justified - })) - sheet.addAction( - UIAlertAction( - title: "Selected Center", style: .default, - handler: { _ in - self.alignment = .centerSelected - })) - present(sheet, animated: true, completion: nil) - } - - func incrementStarBadge() { - let starItem = tabBar.items[1] - guard let badgeValue = starItem.badgeValue, - let badgeNumber = Int(badgeValue), badgeNumber > 0 - else { - return - } - - starItem.badgeValue = NumberFormatter.localizedString( - from: (badgeNumber + 1) as NSNumber, - number: .none) - } - - // MARK: Action - @objc func incrementDidTouch(sender: UIBarButtonItem) { - incrementStarBadge() - - addStar(centered: false) - } - -} - -// MARK: Tab Bar delegate -extension TabBarIconSwiftExample: MDCTabBarDelegate { - func tabBar(_ tabBar: MDCTabBar, didSelect item: UITabBarItem) { - guard let index = tabBar.items.index(of: item) else { - fatalError("MDCTabBarDelegate given selected item not found in tabBar.items") - } - - scrollView.setContentOffset( - CGPoint(x: CGFloat(index) * view.bounds.width, y: 0), - animated: true) - } -} diff --git a/components/Tabs/examples/TabBarIndicatorTemplateExample.swift b/components/Tabs/examples/TabBarIndicatorTemplateExample.swift deleted file mode 100644 index 3187e0b7659..00000000000 --- a/components/Tabs/examples/TabBarIndicatorTemplateExample.swift +++ /dev/null @@ -1,186 +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 CoreGraphics -import UIKit -import MaterialComponents.MaterialAppBar_ColorThemer -import MaterialComponents.MaterialAppBar_TypographyThemer -import MaterialComponents.MaterialButtons -import MaterialComponents.MaterialTabs -import MaterialComponents.MaterialTabs_Theming -import MaterialComponents.MaterialContainerScheme - -class TabBarIndicatorTemplateExample: UIViewController { - - // MARK: Properties - var alignment: MDCTabBarAlignment { - get { - return tabBar.alignment - } - set(newAlignment) { - tabBar.setAlignment(newAlignment, animated: true) - } - } - - var itemAppearance: MDCTabBarItemAppearance { - get { - return tabBar.itemAppearance - } - set { - tabBar.itemAppearance = newValue - - // itemAppearance affects the height of the tab bar. - appBarViewController.headerStackView.setNeedsLayout() - } - } - - lazy var alignmentButton: MDCButton = self.makeAlignmentButton() - lazy var appearanceButton: MDCButton = self.makeAppearanceButton() - lazy var appBarViewController: MDCAppBarViewController = self.makeAppBar() - @objc var containerScheme = MDCContainerScheme() - - lazy var tabBar: MDCTabBar = { - let tabBar = MDCTabBar() - tabBar.alignment = .justified - - tabBar.applyPrimaryTheme(withScheme: containerScheme) - - let bundle = Bundle(for: TabBarIndicatorTemplateExample.self) - let info = UIImage.init(named: "TabBarDemo_ic_info", in: bundle, compatibleWith: nil) - let star = UIImage.init(named: "TabBarDemo_ic_star", in: bundle, compatibleWith: nil) - tabBar.items = [ - UITabBarItem(title: "Fly", image: info, tag: 0), - UITabBarItem(title: "Sleep", image: star, tag: 0), - UITabBarItem(title: "Eat", image: info, tag: 0), - ] - - // Set lighter ink so the indicator animation is more visible. - tabBar.inkColor = UIColor.white.withAlphaComponent(0.15) - - tabBar.itemAppearance = .titles - - // Configure custom title fonts - tabBar.selectedItemTitleFont = UIFont.boldSystemFont(ofSize: 12) - tabBar.unselectedItemTitleFont = UIFont.systemFont(ofSize: 12) - - // Configure custom indicator template - tabBar.selectionIndicatorTemplate = IndicatorTemplate() - return tabBar - }() - - // MARK: Methods - override func viewDidLoad() { - super.viewDidLoad() - - setupExampleViews() - - alignmentButton.addTarget( - self, - action: #selector(changeAlignmentDidTouch(sender:)), - for: .touchUpInside) - appearanceButton.addTarget( - self, - action: #selector(changeAppearance), - for: .touchUpInside) - - MDCAppBarColorThemer.applyColorScheme( - containerScheme.colorScheme, to: self.appBarViewController) - MDCAppBarTypographyThemer.applyTypographyScheme( - containerScheme.typographyScheme, - to: self.appBarViewController) - } - - @objc func changeAlignmentDidTouch(sender: UIButton) { - let sheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) - sheet.popoverPresentationController?.sourceView = self.alignmentButton - sheet.popoverPresentationController?.sourceRect = self.alignmentButton.bounds - sheet.addAction( - UIAlertAction( - title: "Leading", style: .default, - handler: { _ in - self.alignment = .leading - })) - sheet.addAction( - UIAlertAction( - title: "Center", style: .default, - handler: { _ in - self.alignment = .center - })) - sheet.addAction( - UIAlertAction( - title: "Justified", style: .default, - handler: { _ in - self.alignment = .justified - })) - sheet.addAction( - UIAlertAction( - title: "Selected Center", style: .default, - handler: { _ in - self.alignment = .centerSelected - })) - present(sheet, animated: true, completion: nil) - } - - @objc func changeAppearance(fromSender sender: UIButton) { - let sheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) - sheet.popoverPresentationController?.sourceView = self.appearanceButton - sheet.popoverPresentationController?.sourceRect = self.appearanceButton.bounds - sheet.addAction( - UIAlertAction( - title: "Titles", style: .default, - handler: { _ in - self.itemAppearance = .titles - })) - sheet.addAction( - UIAlertAction( - title: "Images", style: .default, - handler: { _ in - self.itemAppearance = .images - })) - sheet.addAction( - UIAlertAction( - title: "Titled Images", style: .default, - handler: { _ in - self.itemAppearance = .titledImages - })) - present(sheet, animated: true, completion: nil) - } - - // MARK: Private - - class IndicatorTemplate: NSObject, MDCTabBarIndicatorTemplate { - func indicatorAttributes( - for context: MDCTabBarIndicatorContext - ) -> MDCTabBarIndicatorAttributes { - let attributes = MDCTabBarIndicatorAttributes() - // Outset frame, round corners, and stroke. - let indicatorFrame = context.contentFrame.insetBy(dx: -8, dy: -4) - let path = UIBezierPath(roundedRect: indicatorFrame, cornerRadius: 4) - attributes.path = path.stroked(withWidth: 2) - return attributes - } - } -} - -extension UIBezierPath { - /// Returns a copy of the path, stroked with the given line width. - func stroked(withWidth width: CGFloat) -> UIBezierPath { - let strokedPath = cgPath.copy( - strokingWithWidth: width, - lineCap: .butt, - lineJoin: .miter, - miterLimit: 0) - return UIBezierPath(cgPath: strokedPath) - } -} diff --git a/components/Tabs/examples/TabBarInterfaceBuilderExample.m b/components/Tabs/examples/TabBarInterfaceBuilderExample.m deleted file mode 100644 index a9d0303f6f7..00000000000 --- a/components/Tabs/examples/TabBarInterfaceBuilderExample.m +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2016-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 "MaterialContainerScheme.h" -#import "MaterialPalettes.h" -#import "MaterialTabs+Theming.h" -#import "MaterialTabs.h" - -@interface TabBarInterfaceBuilderExample : UIViewController - -@property(weak, nonatomic) IBOutlet MDCTabBar *tabBar; -@property(nonatomic) NSArray *colors; -@property(nonatomic, strong) MDCContainerScheme *containerScheme; - -@end - -@implementation TabBarInterfaceBuilderExample - -- (id)initWithCoder:(NSCoder *)aDecoder { - self = [super initWithCoder:aDecoder]; - if (self) { - _containerScheme = [[MDCContainerScheme alloc] init]; - } - return self; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.tabBar.items = @[ - [[UITabBarItem alloc] initWithTitle:@"Blue" image:nil tag:0], - [[UITabBarItem alloc] initWithTitle:@"Pink" image:nil tag:1], - [[UITabBarItem alloc] initWithTitle:@"Red" image:nil tag:2], - [[UITabBarItem alloc] initWithTitle:@"Green" image:nil tag:3] - ]; - - self.colors = @[ - MDCPalette.bluePalette.tint500, MDCPalette.pinkPalette.tint500, MDCPalette.redPalette.tint500, - MDCPalette.greenPalette.tint500 - ]; - - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - - self.view.backgroundColor = self.colors[0]; -} - -#pragma mark MDCTabBarDelegate - -- (void)tabBar:(MDCTabBar *)tabBar didSelectItem:(UITabBarItem *)item { - self.view.backgroundColor = self.colors[item.tag]; -} - -#pragma mark Target / Action - -- (IBAction)alignmentButtonDidTouch:(UIButton *)sender { - UIAlertController *sheet = - [UIAlertController alertControllerWithTitle:nil - message:nil - preferredStyle:UIAlertControllerStyleActionSheet]; - sheet.popoverPresentationController.sourceView = sender; - sheet.popoverPresentationController.sourceRect = sender.bounds; - [sheet addAction:[UIAlertAction actionWithTitle:@"Leading" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self.tabBar setAlignment:MDCTabBarAlignmentLeading]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Center" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self.tabBar setAlignment:MDCTabBarAlignmentCenter]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Justified" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self.tabBar setAlignment:MDCTabBarAlignmentJustified]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Selected Center" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self.tabBar - setAlignment:MDCTabBarAlignmentCenterSelected]; - }]]; - [self presentViewController:sheet animated:YES completion:nil]; -} - -@end - -@implementation TabBarInterfaceBuilderExample (Supplemental) - -- (UIStatusBarStyle)preferredStatusBarStyle { - // Ensure that our status bar is white. - return UIStatusBarStyleLightContent; -} - -@end - -@implementation TabBarInterfaceBuilderExample (CatalogByConvention) - -+ (NSDictionary *)catalogMetadata { - return @{ - @"breadcrumbs" : @[ @"Tab Bar", @"Interface Builder" ], - @"primaryDemo" : @NO, - @"presentable" : @NO, - @"storyboardName" : @"TabBarInterfaceBuilderExample" - }; -} - -@end diff --git a/components/Tabs/examples/TabBarTextOnlyExample.m b/components/Tabs/examples/TabBarTextOnlyExample.m deleted file mode 100644 index 6d54637d65b..00000000000 --- a/components/Tabs/examples/TabBarTextOnlyExample.m +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2016-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 "MDCAppBarViewController.h" -#import "MDCCollectionViewController.h" -#import "MDCHeaderStackView.h" -#import "TabBarTextOnlyExampleSupplemental.h" -#import "MDCTabBar.h" -#import "MDCTabBarAlignment.h" -#import "MDCTabBarDisplayDelegate.h" -#import "MDCTabBar+MaterialTheming.h" -#import "MDCContainerScheme.h" - -@implementation TabBarTextOnlyExample - -- (id)initWithCollectionViewLayout:(UICollectionViewLayout *)layout { - self = [super initWithCollectionViewLayout:layout]; - if (self) { - _containerScheme = [[MDCContainerScheme alloc] init]; - [self setupExampleViews:@[ - @"Change Alignment", @"Toggle Case", @"Clear Selection", @"Select First", @"Select Last" - ]]; - } - return self; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - [self loadTabBar]; - self.appBarViewController.headerStackView.bottomBar = self.tabBar; -} - -#pragma mark - Action - -- (void)toggleCase:(id)sender { - self.tabBar.displaysUppercaseTitles = !self.tabBar.displaysUppercaseTitles; -} - -- (void)clearSelection:(id)sender { - self.tabBar.selectedItem = nil; -} - -#pragma mark - Private - -- (void)loadTabBar { - const CGRect bounds = self.view.bounds; - - // Long tab bar with lots of items of varying length. Also demonstrates configurable accent color. - self.tabBar = [[MDCTabBar alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(bounds) - 20, 0)]; - self.tabBar.items = @[ - [[UITabBarItem alloc] initWithTitle:@"This Is" image:nil tag:0], - [[UITabBarItem alloc] initWithTitle:@"A" image:nil tag:0], - [[UITabBarItem alloc] initWithTitle:@"Tab Bar" image:nil tag:0], - [[UITabBarItem alloc] initWithTitle:@"With" image:nil tag:0], - [[UITabBarItem alloc] initWithTitle:@"A Variety of Titles of Varying Length That Might Be Long" - image:nil - tag:0], - ]; - - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - - self.tabBar.autoresizingMask = - UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; - [self.tabBar sizeToFit]; - - self.tabBar.displayDelegate = self; -} - -- (void)changeAlignment:(id)sender { - UIAlertController *sheet = - [UIAlertController alertControllerWithTitle:nil - message:nil - preferredStyle:UIAlertControllerStyleActionSheet]; - sheet.popoverPresentationController.sourceView = (UICollectionViewCell *)sender; - sheet.popoverPresentationController.sourceRect = ((UICollectionViewCell *)sender).bounds; - [sheet addAction:[UIAlertAction actionWithTitle:@"Leading" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self setAlignment:MDCTabBarAlignmentLeading]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Center" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self setAlignment:MDCTabBarAlignmentCenter]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Justified" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self setAlignment:MDCTabBarAlignmentJustified]; - }]]; - [sheet addAction:[UIAlertAction actionWithTitle:@"Selected Center" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self setAlignment:MDCTabBarAlignmentCenterSelected]; - }]]; - [self presentViewController:sheet animated:YES completion:nil]; -} - -- (void)setAlignment:(MDCTabBarAlignment)alignment { - [self.tabBar setAlignment:alignment animated:YES]; -} - -#pragma mark - Options in Collection View - -- (void)collectionView:(UICollectionView *)collectionView - didSelectItemAtIndexPath:(NSIndexPath *)indexPath { - [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; - switch (indexPath.row) { - case 0: - [self changeAlignment:[collectionView cellForItemAtIndexPath:indexPath]]; - break; - - case 1: - [self toggleCase:collectionView]; - break; - - case 2: - [self clearSelection:collectionView]; - break; - - case 3: - [self.tabBar setSelectedItem:self.tabBar.items.firstObject animated:YES]; - break; - - case 4: - [self.tabBar setSelectedItem:self.tabBar.items.lastObject animated:YES]; - break; - - default: - // Unsupported - break; - } -} - -#pragma mark - MDCTabBarDisplayDelegate - -- (void)tabBar:(MDCTabBar *)tabBar willDisplayItem:(UITabBarItem *)item { - NSLog(@"Will display item: %@", item.title); -} - -- (void)tabBar:(MDCTabBar *)tabBar didEndDisplayingItem:(nonnull UITabBarItem *)item { - NSLog(@"Did end displaying item: %@", item.title); -} - -@end diff --git a/components/Tabs/examples/TabBarViewControllerExample.m b/components/Tabs/examples/TabBarViewControllerExample.m deleted file mode 100644 index c3368473884..00000000000 --- a/components/Tabs/examples/TabBarViewControllerExample.m +++ /dev/null @@ -1,49 +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 - -#import "TabBarViewControllerExampleSupplemental.h" -#import "MDCTabBar.h" -#import "MDCTabBar+MaterialTheming.h" -#import "MDCContainerScheme.h" - -@implementation TabBarViewControllerExample - -- (id)init { - self = [super init]; - if (self) { - _containerScheme = [[MDCContainerScheme alloc] init]; - } - return self; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - self.view.backgroundColor = UIColor.whiteColor; - [self setupTabBarColors]; - [self loadTabBar]; -} - -#pragma mark - Private - -- (void)loadTabBar { - NSArray *viewControllers = [self constructExampleViewControllers]; - self.viewControllers = viewControllers; - self.selectedViewController = self.viewControllers.firstObject; - self.tabBar.enableRippleBehavior = YES; - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; -} - -@end diff --git a/components/Tabs/examples/TabBarViewControllerInterfaceBuilderExample.m b/components/Tabs/examples/TabBarViewControllerInterfaceBuilderExample.m deleted file mode 100644 index 6c0921e9e45..00000000000 --- a/components/Tabs/examples/TabBarViewControllerInterfaceBuilderExample.m +++ /dev/null @@ -1,62 +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 - -#import "MaterialContainerScheme.h" -#import "MaterialTabs+Theming.h" -#import "MaterialTabs.h" - -@interface TabBarViewControllerInterfaceBuilderExample : MDCTabBarViewController -@property(nonatomic, strong) id containerScheme; -@end - -@implementation TabBarViewControllerInterfaceBuilderExample - -- (id)init { - self = [super init]; - if (self) { - self.containerScheme = [[MDCContainerScheme alloc] init]; - } - return self; -} - -- (void)awakeFromNib { - [super awakeFromNib]; - self.viewControllers = @[ - [self.storyboard instantiateViewControllerWithIdentifier:@"red"], - [self.storyboard instantiateViewControllerWithIdentifier:@"blue"], - [self.storyboard instantiateViewControllerWithIdentifier:@"green"], - ]; - if (!self.containerScheme) { - self.containerScheme = [[MDCContainerScheme alloc] init]; - } - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - self.selectedViewController = self.viewControllers.firstObject; -} - -@end - -@implementation TabBarViewControllerInterfaceBuilderExample (CatalogByConvention) - -+ (NSDictionary *)catalogMetadata { - return @{ - @"breadcrumbs" : @[ @"Tab Bar", @"TabBarViewController Interface Builder" ], - @"primaryDemo" : @NO, - @"presentable" : @NO, - @"storyboardName" : @"TabBarViewControllerInterfaceBuilderExample" - }; -} - -@end diff --git a/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.h b/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.h deleted file mode 100644 index 856ad1e587b..00000000000 --- a/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.h +++ /dev/null @@ -1,44 +0,0 @@ -/*Copyright 2016-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. - */ -/* IMPORTANT: - This file contains supplemental code used to populate the examples with dummy data and/or - instructions. It is not necessary to import this file to use Material Components for iOS. - */ - -#import - -#import "MaterialAppBar.h" -#import "MaterialButtons.h" -#import "MaterialColorScheme.h" -#import "MaterialContainerScheme.h" -#import "MaterialTabs.h" -#import "MaterialTypographyScheme.h" - -@interface TabBarIconExample : UIViewController - -@property(nonatomic, nullable) MDCTabBar *tabBar; -@property(nonatomic, nullable) MDCButton *alignmentButton; -@property(nonatomic, nullable) MDCAppBarViewController *appBarViewController; -@property(nonatomic, nullable) MDCContainerScheme *containerScheme; -@property(nonatomic, nullable) UIScrollView *scrollView; -@property(nonatomic, nullable) UIView *starPage; -@end - -@interface TabBarIconExample (Supplemental) - -- (void)setupExampleViews; -- (void)addStarCentered:(BOOL)centered; - -@end diff --git a/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.m b/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.m deleted file mode 100644 index 3375678fdb8..00000000000 --- a/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.m +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright 2016-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. -/* IMPORTANT: - This file contains supplemental code used to populate the examples with dummy data and/or - instructions. It is not necessary to import this file to use Material Components for iOS. - */ - -#import "TabBarIconExampleSupplemental.h" - -#import "MaterialAppBar+ColorThemer.h" -#import "MaterialAppBar+TypographyThemer.h" -#import "MaterialButtons+ButtonThemer.h" -#import "MaterialPalettes.h" -#import "MaterialTabs+TypographyThemer.h" - -// Exposing selectors defined in the main example class -@interface TabBarIconExample () -- (void)changeAlignment:(id)sender; -- (void)incrementDidTouch:(id)sender; -@end - -@implementation TabBarIconExample (Supplemental) - -- (void)setupExampleViews { - [self setupAppBar]; - - [self setupScrollView]; - [self setupScrollingContent]; - - [self setupAlignmentButton]; - - [MDCTabBarTypographyThemer applyTypographyScheme:self.containerScheme.typographyScheme - toTabBar:self.tabBar]; -} - -- (void)setupAlignmentButton { - self.alignmentButton = [[MDCButton alloc] init]; - - MDCButtonScheme *buttonScheme = [[MDCButtonScheme alloc] init]; - buttonScheme.colorScheme = self.containerScheme.colorScheme; - buttonScheme.typographyScheme = self.containerScheme.typographyScheme; - [MDCContainedButtonThemer applyScheme:buttonScheme toButton:self.alignmentButton]; - - [self.view addSubview:self.alignmentButton]; - - self.alignmentButton.translatesAutoresizingMaskIntoConstraints = NO; - [NSLayoutConstraint constraintWithItem:self.alignmentButton - attribute:NSLayoutAttributeCenterX - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeCenterX - multiplier:1 - constant:0] - .active = YES; - [NSLayoutConstraint constraintWithItem:self.alignmentButton - attribute:NSLayoutAttributeBottom - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeBottom - multiplier:1.0 - constant:-40] - .active = YES; - - [self.alignmentButton setTitle:@"Change Alignment" forState:UIControlStateNormal]; - [self.alignmentButton addTarget:self - action:@selector(changeAlignment:) - forControlEvents:UIControlEventTouchUpInside]; -} - -- (void)setupAppBar { - self.view.backgroundColor = [UIColor whiteColor]; - - self.appBarViewController = [[MDCAppBarViewController alloc] init]; - [self addChildViewController:self.appBarViewController]; - - self.appBarViewController.headerView.tintColor = [UIColor whiteColor]; - self.appBarViewController.headerView.minMaxHeightIncludesSafeArea = NO; - self.appBarViewController.headerView.minimumHeight = 56 + 72; - - [self.view addSubview:self.appBarViewController.view]; - [self.appBarViewController didMoveToParentViewController:self]; - - [MDCAppBarColorThemer applyColorScheme:self.containerScheme.colorScheme - toAppBarViewController:self.appBarViewController]; - [MDCAppBarTypographyThemer applyTypographyScheme:self.containerScheme.typographyScheme - toAppBarViewController:self.appBarViewController]; -} - -- (void)setupScrollView { - self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; - self.scrollView.translatesAutoresizingMaskIntoConstraints = NO; - self.scrollView.pagingEnabled = YES; - self.scrollView.scrollEnabled = NO; - [self.view addSubview:self.scrollView]; - - NSDictionary *viewsScrollView = - @{@"scrollView" : self.scrollView, @"header" : self.appBarViewController.headerStackView}; - [NSLayoutConstraint - activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[header][scrollView]|" - options:0 - metrics:nil - views:viewsScrollView]]; - [NSLayoutConstraint - activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[scrollView]|" - options:0 - metrics:nil - views:viewsScrollView]]; -} - -- (void)setupScrollingContent { - // The scrollView will have two UIViews (pages.) One has a label with text (infoLabel); we call - // this infoPage. Another has 1+ star images; we call this self.starPage. Tapping on the 'INFO' - // tab will show the infoPage and tapping on the 'STARS' tab will show the self.starPage. - - // Create the first view and its content. Then add to scrollView. - UIView *infoPage = [[UIView alloc] initWithFrame:CGRectZero]; - infoPage.translatesAutoresizingMaskIntoConstraints = NO; - [self.scrollView addSubview:infoPage]; - infoPage.backgroundColor = [UIColor whiteColor]; - - UILabel *infoLabel = [[UILabel alloc] initWithFrame:CGRectZero]; - infoLabel.translatesAutoresizingMaskIntoConstraints = NO; - infoLabel.textColor = [MDCPalette.greyPalette.tint600 colorWithAlphaComponent:(CGFloat)0.87]; - infoLabel.numberOfLines = 0; - infoLabel.text = - @"Tabs enable content organization at a high level, such as switching between views"; - [infoPage addSubview:infoLabel]; - - [NSLayoutConstraint constraintWithItem:infoLabel - attribute:NSLayoutAttributeCenterX - relatedBy:NSLayoutRelationEqual - toItem:infoPage - attribute:NSLayoutAttributeCenterX - multiplier:1 - constant:0] - .active = YES; - [NSLayoutConstraint constraintWithItem:infoLabel - attribute:NSLayoutAttributeCenterY - relatedBy:NSLayoutRelationEqual - toItem:infoPage - attribute:NSLayoutAttributeCenterY - multiplier:1 - constant:-50] - .active = YES; - - [NSLayoutConstraint - activateConstraints:[NSLayoutConstraint - constraintsWithVisualFormat:@"H:|-50-[infoLabel]-50-|" - options:0 - metrics:nil - views:@{@"infoLabel" : infoLabel}]]; - - // Create the second view and its content. Then add to scrollView. - self.starPage = [[UIView alloc] initWithFrame:CGRectZero]; - self.starPage.translatesAutoresizingMaskIntoConstraints = NO; - [self.scrollView addSubview:self.starPage]; - self.starPage.backgroundColor = MDCPalette.lightBluePalette.tint200; - [self addStarCentered:YES]; - - // Layout the views to be equal height and width to each other and self.view, hug the edges of the - // scrollView and meet in the middle. - - [NSLayoutConstraint constraintWithItem:infoPage - attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:self.view - attribute:NSLayoutAttributeWidth - multiplier:1 - constant:0] - .active = YES; - [NSLayoutConstraint constraintWithItem:infoPage - attribute:NSLayoutAttributeHeight - relatedBy:NSLayoutRelationEqual - toItem:self.scrollView - attribute:NSLayoutAttributeHeight - multiplier:1 - constant:0] - .active = YES; - - [NSLayoutConstraint constraintWithItem:self.starPage - attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:infoPage - attribute:NSLayoutAttributeWidth - multiplier:1 - constant:0] - .active = YES; - - NSDictionary *viewsPages = @{@"infoPage" : infoPage, @"starPage" : self.starPage}; - - [NSLayoutConstraint - activateConstraints:[NSLayoutConstraint - constraintsWithVisualFormat:@"H:|[infoPage][starPage]|" - options:NSLayoutFormatAlignAllTop | - NSLayoutFormatAlignAllBottom - metrics:nil - views:viewsPages]]; - [NSLayoutConstraint - activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[infoPage]|" - options:0 - metrics:nil - views:viewsPages]]; -} - -- (void)addStarCentered:(BOOL)centered { - UIImage *starImage = [UIImage imageNamed:@"TabBarDemo_ic_star" - inBundle:[NSBundle bundleForClass:[TabBarIconExample class]] - compatibleWithTraitCollection:nil]; - - UIImageView *starView = [[UIImageView alloc] initWithImage:starImage]; - starView.translatesAutoresizingMaskIntoConstraints = NO; - [self.starPage addSubview:starView]; - [starView sizeToFit]; - - CGFloat x = centered ? 1 : (CGFloat)((arc4random_uniform(199) + 1) / 100.0); // 0 < x <=2 - CGFloat y = centered ? 1 : (CGFloat)((arc4random_uniform(199) + 1) / 100.0); // 0 < y <=2 - - [NSLayoutConstraint constraintWithItem:starView - attribute:NSLayoutAttributeCenterX - relatedBy:NSLayoutRelationEqual - toItem:self.starPage - attribute:NSLayoutAttributeCenterX - multiplier:x - constant:0] - .active = YES; - [NSLayoutConstraint constraintWithItem:starView - attribute:NSLayoutAttributeCenterY - relatedBy:NSLayoutRelationEqual - toItem:self.starPage - attribute:NSLayoutAttributeCenterY - multiplier:y - constant:0] - .active = YES; -} - -- (UIViewController *)childViewControllerForStatusBarStyle { - return self.appBarViewController; -} - -- (UIStatusBarStyle)preferredStatusBarStyle { - // Ensure that our status bar is white. - return UIStatusBarStyleLightContent; -} - -- (void)viewWillTransitionToSize:(CGSize)size - withTransitionCoordinator:(id)coordinator { - [coordinator - animateAlongsideTransition:^( - __unused id _Nonnull context) { - // Update the scrollView position so that the selected view is entirely visible - [self tabBar:self.tabBar didSelectItem:self.tabBar.selectedItem]; - } - completion:nil]; - [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; -} - -@end - -@implementation TabBarIconExample (CatalogByConvention) - -+ (NSDictionary *)catalogMetadata { - return @{ - @"breadcrumbs" : @[ @"Tab Bar", @"Tabs with Icons" ], - @"description" : @"Tabs organize content across different screens, data sets, and " - @"other interactions.", - @"primaryDemo" : @YES, - @"presentable" : @YES, - }; -} - -@end diff --git a/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.swift b/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.swift deleted file mode 100644 index 6b893639686..00000000000 --- a/components/Tabs/examples/supplemental/TabBarIconExampleSupplemental.swift +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2016-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. - -// swiftlint:disable function_body_length -// swiftlint:disable line_length - -import UIKit -import MaterialComponents.MaterialAppBar -import MaterialComponents.MaterialAppBar_ColorThemer -import MaterialComponents.MaterialAppBar_TypographyThemer -import MaterialComponents.MaterialButtons_ButtonThemer -import MaterialComponents.MaterialButtons -import MaterialComponents.MaterialPalettes - -extension TabBarIconSwiftExample { - - func setupAlignmentButton() -> MDCButton { - let alignmentButton = MDCButton() - - let buttonScheme = MDCButtonScheme() - buttonScheme.colorScheme = containerScheme.colorScheme - buttonScheme.typographyScheme = containerScheme.typographyScheme - MDCContainedButtonThemer.applyScheme(buttonScheme, to: alignmentButton) - - alignmentButton.setTitle("Change Alignment", for: .normal) - alignmentButton.setTitleColor(.white, for: .normal) - - self.view.addSubview(alignmentButton) - alignmentButton.translatesAutoresizingMaskIntoConstraints = false - - NSLayoutConstraint( - item: alignmentButton, - attribute: .centerX, - relatedBy: .equal, - toItem: self.view, - attribute: .centerX, - multiplier: 1, - constant: 0 - ).isActive = true - NSLayoutConstraint( - item: alignmentButton, - attribute: .bottom, - relatedBy: .equal, - toItem: self.view, - attribute: .bottom, - multiplier: 1, - constant: -40 - ).isActive = true - - return alignmentButton - } - - func setupAppBar() -> MDCAppBarViewController { - let appBarViewController = MDCAppBarViewController() - - self.addChild(appBarViewController) - appBarViewController.headerView.minMaxHeightIncludesSafeArea = false - appBarViewController.headerView.minimumHeight = 56 + 72 - appBarViewController.headerView.tintColor = MDCPalette.blue.tint500 - MDCAppBarColorThemer.applyColorScheme(containerScheme.colorScheme, to: appBarViewController) - MDCAppBarTypographyThemer.applyTypographyScheme( - containerScheme.typographyScheme, to: appBarViewController) - - appBarViewController.headerStackView.bottomBar = self.tabBar - appBarViewController.headerStackView.setNeedsLayout() - return appBarViewController - } - - func setupExampleViews() { - view.backgroundColor = UIColor.white - - view.addSubview(appBarViewController.view) - appBarViewController.didMove(toParent: self) - - let badgeIncrementItem = UIBarButtonItem( - title: "Add", - style: .plain, - target: self, - action: #selector(incrementDidTouch(sender:))) - - self.navigationItem.rightBarButtonItem = badgeIncrementItem - - setupScrollingContent() - } - - func setupScrollView() -> UIScrollView { - let scrollView = UIScrollView(frame: CGRect()) - scrollView.translatesAutoresizingMaskIntoConstraints = false - scrollView.isPagingEnabled = false - scrollView.isScrollEnabled = false - self.view.addSubview(scrollView) - - scrollView.backgroundColor = UIColor.red - - let views: [String: UIView] = [ - "scrollView": scrollView, - "header": self.appBarViewController.headerStackView, - ] - NSLayoutConstraint.activate( - NSLayoutConstraint.constraints( - withVisualFormat: "V:[header][scrollView]|", - options: [], - metrics: nil, - views: views)) - NSLayoutConstraint.activate( - NSLayoutConstraint.constraints( - withVisualFormat: "H:|[scrollView]|", - options: [], - metrics: nil, - views: views)) - - return scrollView - } - - func setupScrollingContent() { - // The scrollView will have two UIViews (pages.) One has a label with text (infoLabel); we call - // this infoPage. Another has 1+ star images; we call this self.starPage. Tapping on the 'INFO' - // tab will show the infoPage and tapping on the 'STARS' tab will show the self.starPage. - - // Create the first view and its content. Then add to scrollView. - - let infoPage = UIView(frame: CGRect()) - infoPage.translatesAutoresizingMaskIntoConstraints = false - infoPage.backgroundColor = MDCPalette.lightBlue.tint300 - scrollView.addSubview(infoPage) - - let infoLabel = UILabel(frame: CGRect()) - infoLabel.translatesAutoresizingMaskIntoConstraints = false - infoLabel.textColor = UIColor.white - infoLabel.numberOfLines = 0 - infoLabel.text = - "Tabs enable content organization at a high level," - + " such as switching between views" - infoPage.addSubview(infoLabel) - - // Layout the views to be equal height and width to each other and self.view, - // hug the edges of the scrollView and meet in the middle. - - NSLayoutConstraint( - item: infoLabel, - attribute: .centerX, - relatedBy: .equal, - toItem: infoPage, - attribute: .centerX, - multiplier: 1, - constant: 0 - ).isActive = true - NSLayoutConstraint( - item: infoLabel, - attribute: .centerY, - relatedBy: .equal, - toItem: infoPage, - attribute: .centerY, - multiplier: 1, - constant: -50 - ).isActive = true - - NSLayoutConstraint.activate( - NSLayoutConstraint.constraints( - withVisualFormat: "H:|-50-[infoLabel]-50-|", - options: [], - metrics: nil, - views: ["infoLabel": infoLabel])) - NSLayoutConstraint( - item: infoPage, - attribute: .width, - relatedBy: .equal, - toItem: self.view, - attribute: .width, - multiplier: 1, - constant: 0 - ).isActive = true - NSLayoutConstraint( - item: infoPage, - attribute: .height, - relatedBy: .equal, - toItem: self.scrollView, - attribute: .height, - multiplier: 1, - constant: 0 - ).isActive = true - - NSLayoutConstraint( - item: self.starPage, - attribute: .width, - relatedBy: .equal, - toItem: infoPage, - attribute: .width, - multiplier: 1, - constant: 0 - ).isActive = true - - let views = ["infoPage": infoPage, "starPage": self.starPage] - - NSLayoutConstraint.activate( - NSLayoutConstraint.constraints( - withVisualFormat: "H:|[infoPage][starPage]|", - options: [ - .alignAllTop, - .alignAllBottom, - ], - metrics: nil, - views: views)) - NSLayoutConstraint.activate( - NSLayoutConstraint.constraints( - withVisualFormat: "V:|[infoPage]|", - options: [], - metrics: nil, - views: views)) - - addStar(centered: true) - } - - func setupStarPage() -> UIView { - let starPage = UIView(frame: CGRect()) - starPage.translatesAutoresizingMaskIntoConstraints = false - starPage.backgroundColor = MDCPalette.lightBlue.tint200 - self.scrollView.addSubview(starPage) - - return starPage - } - - func addStar(centered: Bool) { - let starImage = UIImage( - named: "TabBarDemo_ic_star", - in: Bundle(for: TabBarIconSwiftExample.self), - compatibleWith: nil) - let starView = UIImageView(image: starImage) - starView.translatesAutoresizingMaskIntoConstraints = false - starPage.addSubview(starView) - starView.sizeToFit() - - let x = centered ? 1.0 : (CGFloat(arc4random_uniform(199) + 1) / 100.0) // 0 < x <=2 - let y = centered ? 1.0 : (CGFloat(arc4random_uniform(199) + 1) / 100.0) // 0 < y <=2 - - NSLayoutConstraint( - item: starView, - attribute: .centerX, - relatedBy: .equal, - toItem: starPage, - attribute: .centerX, - multiplier: x, - constant: 0 - ).isActive = true - NSLayoutConstraint( - item: starView, - attribute: .centerY, - relatedBy: .equal, - toItem: self.starPage, - attribute: .centerY, - multiplier: y, - constant: 0 - ).isActive = true - } -} - -extension TabBarIconSwiftExample { - override var childForStatusBarStyle: UIViewController? { - return appBarViewController - } - - override func viewWillTransition( - to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator - ) { - coordinator.animate( - alongsideTransition: { (_) in - if let selectedItem = self.tabBar.selectedItem { - self.tabBar(self.tabBar, didSelect: selectedItem) - } - }, completion: nil) - super.viewWillTransition(to: size, with: coordinator) - } -} - -// MARK: - Catalog by convention -extension TabBarIconSwiftExample { - - @objc class func catalogMetadata() -> [String: Any] { - return [ - "breadcrumbs": ["Tab Bar", "Tabs with Icons (Swift)"], - "primaryDemo": false, - "presentable": false, - ] - } - - @objc func catalogShouldHideNavigation() -> Bool { - return true - } -} diff --git a/components/Tabs/examples/supplemental/TabBarIndicatorTemplateExampleSupplemental.swift b/components/Tabs/examples/supplemental/TabBarIndicatorTemplateExampleSupplemental.swift deleted file mode 100644 index c6d60099376..00000000000 --- a/components/Tabs/examples/supplemental/TabBarIndicatorTemplateExampleSupplemental.swift +++ /dev/null @@ -1,134 +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 UIKit -import MaterialComponents.MaterialAppBar -import MaterialComponents.MaterialButtons_ButtonThemer -import MaterialComponents.MaterialButtons - -extension TabBarIndicatorTemplateExample { - - private func themeButton(_ button: MDCButton) { - let buttonScheme = MDCButtonScheme() - buttonScheme.colorScheme = containerScheme.colorScheme - buttonScheme.typographyScheme = containerScheme.typographyScheme - MDCContainedButtonThemer.applyScheme(buttonScheme, to: button) - } - - func makeAlignmentButton() -> MDCButton { - let button = MDCButton() - themeButton(button) - button.setTitle("Change Alignment", for: .normal) - return button - } - - func makeAppearanceButton() -> MDCButton { - let button = MDCButton() - themeButton(button) - button.setTitle("Change Appearance", for: .normal) - return button - } - - func makeAppBar() -> MDCAppBarViewController { - let appBarViewController = MDCAppBarViewController() - - self.addChild(appBarViewController) - - // Give the tab bar enough height to accomodate all possible item appearances. - appBarViewController.headerView.minMaxHeightIncludesSafeArea = false - appBarViewController.headerView.minimumHeight = 128 - - appBarViewController.headerStackView.bottomBar = self.tabBar - appBarViewController.headerStackView.setNeedsLayout() - return appBarViewController - } - - func setupExampleViews() { - view.backgroundColor = UIColor.white - view.addSubview(appBarViewController.view) - appBarViewController.didMove(toParent: self) - - // Set up buttons - alignmentButton.translatesAutoresizingMaskIntoConstraints = false - appearanceButton.translatesAutoresizingMaskIntoConstraints = false - self.view.addSubview(alignmentButton) - self.view.addSubview(appearanceButton) - - // Buttons are laid out relative to the safe area, if available. - let alignmentGuide: Any - alignmentGuide = view.safeAreaLayoutGuide - - NSLayoutConstraint.activate([ - // Center alignment button - NSLayoutConstraint( - item: alignmentButton, - attribute: .centerX, - relatedBy: .equal, - toItem: self.view, - attribute: .centerX, - multiplier: 1, - constant: 0), - NSLayoutConstraint( - item: alignmentButton, - attribute: .bottom, - relatedBy: .equal, - toItem: alignmentGuide, - attribute: .bottom, - multiplier: 1, - constant: -40), - - // Place appearance button above - NSLayoutConstraint( - item: appearanceButton, - attribute: .centerX, - relatedBy: .equal, - toItem: self.view, - attribute: .centerX, - multiplier: 1, - constant: 0), - NSLayoutConstraint( - item: appearanceButton, - attribute: .bottom, - relatedBy: .equal, - toItem: alignmentButton, - attribute: .top, - multiplier: 1, - constant: -8), - ]) - - self.title = "Custom Selection Indicator" - } -} - -extension TabBarIndicatorTemplateExample { - override var childForStatusBarStyle: UIViewController? { - return appBarViewController - } -} - -// MARK: - Catalog by convention -extension TabBarIndicatorTemplateExample { - - @objc class func catalogMetadata() -> [String: Any] { - return [ - "breadcrumbs": ["Tab Bar", "Custom Selection Indicator"], - "primaryDemo": false, - "presentable": true, - ] - } - - @objc func catalogShouldHideNavigation() -> Bool { - return true - } -} diff --git a/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.h b/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.h deleted file mode 100644 index 8f7cebfcb39..00000000000 --- a/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.h +++ /dev/null @@ -1,40 +0,0 @@ -/*Copyright 2016-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. - */ -/* IMPORTANT: - This file contains supplemental code used to populate the examples with dummy data and/or - instructions. It is not necessary to import this file to use Material Components for iOS. - */ - -#import - -#import "MDCTabBarDisplayDelegate.h" -#import "MaterialAppBar.h" -#import "MaterialCollections.h" -#import "MaterialContainerScheme.h" -#import "MaterialTabs.h" - -@interface TabBarTextOnlyExample : MDCCollectionViewController - -@property(nonatomic, nullable) MDCAppBarViewController *appBarViewController; -@property(nonatomic, nullable) MDCContainerScheme *containerScheme; -@property(nonatomic, nullable) MDCTabBar *tabBar; -@property(nonatomic, nullable) NSArray *choices; -@end - -@interface TabBarTextOnlyExample (Supplemental) - -- (void)setupExampleViews:(nullable NSArray *)choices; - -@end diff --git a/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.m b/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.m deleted file mode 100644 index 2c19c0eacaf..00000000000 --- a/components/Tabs/examples/supplemental/TabBarTextOnlyExampleSupplemental.m +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2016-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. -/* IMPORTANT: - This file contains supplemental code used to populate the examples with dummy data and/or - instructions. It is not necessary to import this file to use Material Components for iOS. - */ - -#import "TabBarTextOnlyExampleSupplemental.h" - -static CGFloat const kAppBarMinHeight = 56; -static CGFloat const kTabBarHeight = 48; - -static NSString *const kReusableIdentifierItem = @"Cell"; - -@implementation TabBarTextOnlyExample (Supplemental) - -- (UIViewController *)childViewControllerForStatusBarStyle { - return self.appBarViewController; -} - -- (UIViewController *)childViewControllerForStatusBarHidden { - return self.appBarViewController; -} - -- (void)setupExampleViews:(NSArray *)choices { - self.choices = choices; - self.title = @"Text Tabs"; - - self.appBarViewController = [[MDCAppBarViewController alloc] init]; - [self addChildViewController:self.appBarViewController]; - - self.appBarViewController.headerView.trackingScrollView = self.collectionView; - self.appBarViewController.headerView.shiftBehavior = - MDCFlexibleHeaderShiftBehaviorEnabled; - - self.appBarViewController.navigationBar.tintColor = [UIColor whiteColor]; - self.appBarViewController.headerView.tintColor = [UIColor whiteColor]; - self.appBarViewController.headerView.minMaxHeightIncludesSafeArea = NO; - self.appBarViewController.headerView.minimumHeight = kTabBarHeight; - self.appBarViewController.headerView.maximumHeight = kAppBarMinHeight + kTabBarHeight; - - UIFont *font = [UIFont monospacedDigitSystemFontOfSize:14 weight:UIFontWeightRegular]; - - self.appBarViewController.navigationBar.titleTextAttributes = - @{NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : font}; - [self.view addSubview:self.appBarViewController.view]; - [self.appBarViewController didMoveToParentViewController:self]; - - [self.collectionView registerClass:[MDCCollectionViewTextCell class] - forCellWithReuseIdentifier:kReusableIdentifierItem]; -} - -#pragma mark - UICollectionView - -- (NSInteger)collectionView:(UICollectionView *)collectionView - numberOfItemsInSection:(NSInteger)section { - return self.choices.count; -} - -- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView - cellForItemAtIndexPath:(NSIndexPath *)indexPath { - MDCCollectionViewTextCell *cell = - [collectionView dequeueReusableCellWithReuseIdentifier:kReusableIdentifierItem - forIndexPath:indexPath]; - cell.textLabel.text = self.choices[indexPath.row]; - return cell; -} - -#pragma mark - UIScrollViewDelegate Forwarding. - -- (void)scrollViewDidScroll:(UIScrollView *)scrollView { - if (scrollView == self.appBarViewController.headerView.trackingScrollView) { - [self.appBarViewController.headerView trackingScrollViewDidScroll]; - } -} - -- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { - if (scrollView == self.appBarViewController.headerView.trackingScrollView) { - [self.appBarViewController.headerView trackingScrollViewDidEndDecelerating]; - } -} - -- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { - if (scrollView == self.appBarViewController.headerView.trackingScrollView) { - [self.appBarViewController.headerView - trackingScrollViewDidEndDraggingWillDecelerate:decelerate]; - } -} - -- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView - withVelocity:(CGPoint)velocity - targetContentOffset:(inout CGPoint *)targetContentOffset { - if (scrollView == self.appBarViewController.headerView.trackingScrollView) { - [self.appBarViewController.headerView - trackingScrollViewWillEndDraggingWithVelocity:velocity - targetContentOffset:targetContentOffset]; - } -} - -@end - -@implementation TabBarTextOnlyExample (CatalogByConvention) - -+ (NSDictionary *)catalogMetadata { - return @{ - @"breadcrumbs" : @[ @"Tab Bar", @"Text Tabs" ], - @"primaryDemo" : @NO, - @"presentable" : @NO, - }; -} - -- (BOOL)catalogShouldHideNavigation { - return YES; -} - -@end diff --git a/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.h b/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.h deleted file mode 100644 index 3300d274a18..00000000000 --- a/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.h +++ /dev/null @@ -1,52 +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. -/* IMPORTANT: - This file contains supplemental code used to populate the examples with dummy data and/or - instructions. It is not necessary to import this file to use Material Components for iOS. - */ - -#import - -#import "MaterialButtons+ButtonThemer.h" -#import "MaterialContainerScheme.h" -#import "MaterialTabs.h" -#import "MaterialTypographyScheme.h" - -typedef void (^MDCButtonActionBlock)(void); - -@interface TabBarViewControllerExample : MDCTabBarViewController -@property(nonatomic, strong, nullable) MDCContainerScheme *containerScheme; -@property(nonatomic, strong, nullable) MDCTypographyScheme *typographyScheme; -@end - -@interface TabBarViewControllerExample (Supplemental) - -- (void)setupTabBarColors; - -- (nonnull NSArray *)constructExampleViewControllers; - -@end - -@interface TBVCSampleViewController : UIViewController - -@property(nonatomic, nullable) MDCSemanticColorScheme *colorScheme; -@property(nonatomic, nullable) MDCTypographyScheme *typographyScheme; - -+ (nonnull instancetype)sampleWithTitle:(nonnull NSString *)title color:(nonnull UIColor *)color; - -- (void)setMDCButtonWithFrame:(CGRect)frame - buttonScheme:(nonnull id)buttonScheme - title:(nonnull NSString *)title - actionBlock:(nullable MDCButtonActionBlock)actionBlock; -@end diff --git a/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.m b/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.m deleted file mode 100644 index 9e4194e7222..00000000000 --- a/components/Tabs/examples/supplemental/TabBarViewControllerExampleSupplemental.m +++ /dev/null @@ -1,213 +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. -/* IMPORTANT: - This file contains supplemental code used to populate the examples with dummy data and/or - instructions. It is not necessary to import this file to use Material Components for iOS. - */ - -#import "TabBarViewControllerExampleSupplemental.h" - -#import "MaterialAppBar+ColorThemer.h" -#import "MaterialAppBar+TypographyThemer.h" -#import "MaterialAppBar.h" -#import "MaterialButtons.h" -#import "MaterialPalettes.h" - -@interface TBVCSampleView : UIView -@end - -@implementation TBVCSampleView - -// Draw a frame inset around our content area, to show that view are being resized correctly. -- (void)drawRect:(CGRect)rect { - [super drawRect:rect]; - // In this example, it happens to be the appBarViewController.headerView - UIView *header = self.subviews.firstObject; - CGRect bounds = self.bounds; - CGRect dontCare; - CGRectDivide(bounds, &dontCare, &bounds, header.bounds.size.height, CGRectMinYEdge); - bounds = CGRectInset(bounds, 4, 4); - [UIColor.whiteColor set]; - UIRectFrame(bounds); -} - -@end - -@interface TBVCSampleViewController () - -@property(nonatomic) MDCAppBarViewController *appBarViewController; -@property(nonatomic) UILabel *titleLabel; -@property(nonatomic) CGRect buttonFrame; // The desired frame of the button -@property(nonatomic) MDCButton *button; -@property(nonatomic, copy) MDCButtonActionBlock buttonActionBlock; - -@end - -@implementation TBVCSampleViewController - -- (void)loadView { - self.view = [[TBVCSampleView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.appBarViewController = [[MDCAppBarViewController alloc] init]; - - [self addChildViewController:self.appBarViewController]; - [self.view addSubview:self.appBarViewController.view]; - [self.appBarViewController didMoveToParentViewController:self]; -} - -- (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; - - [MDCAppBarColorThemer applyColorScheme:self.colorScheme - toAppBarViewController:self.appBarViewController]; - [MDCAppBarTypographyThemer applyTypographyScheme:self.typographyScheme - toAppBarViewController:self.appBarViewController]; -} - -- (void)viewDidLayoutSubviews { - [super viewDidLayoutSubviews]; - _titleLabel.center = self.view.center; - UIEdgeInsets safeAreaInsets = UIEdgeInsetsZero; - safeAreaInsets = self.view.safeAreaInsets; - CGRect buttonFrame = self.buttonFrame; - self.button.frame = CGRectOffset(buttonFrame, safeAreaInsets.left, safeAreaInsets.top); - [self.button sizeToFit]; - - [self.view setNeedsDisplay]; -} - -- (UIViewController *)childViewControllerForStatusBarStyle { - return self.appBarViewController; -} - -+ (nonnull instancetype)sampleWithTitle:(nonnull NSString *)title color:(nonnull UIColor *)color { - return [self sampleWithTitle:title color:color icon:nil]; -} - -+ (nonnull instancetype)sampleWithTitle:(nonnull NSString *)title - color:(nonnull UIColor *)color - icon:(nullable UIImage *)icon { - TBVCSampleViewController *sample = [[TBVCSampleViewController alloc] init]; - UILabel *titleLabel = [[UILabel alloc] init]; - titleLabel.text = title; - titleLabel.textColor = UIColor.whiteColor; - [titleLabel sizeToFit]; - TBVCSampleView *sampleView = (TBVCSampleView *)sample.view; - sample.titleLabel = titleLabel; - [sampleView addSubview:titleLabel]; - sampleView.backgroundColor = color; - sample.tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:icon tag:0]; - sample.title = title; - return sample; -} - -- (void)setMDCButtonWithFrame:(CGRect)frame - buttonScheme:(nonnull id)buttonScheme - title:(nonnull NSString *)title - actionBlock:(nullable MDCButtonActionBlock)actionBlock { - MDCButton *button = [[MDCButton alloc] initWithFrame:CGRectZero]; - [button setTitle:title forState:UIControlStateNormal]; - [MDCContainedButtonThemer applyScheme:buttonScheme toButton:button]; - [self.view addSubview:button]; - self.button = button; - self.buttonFrame = CGRectStandardize(frame); - self.buttonActionBlock = actionBlock; - [button addTarget:self - action:@selector(triggerButtonActionHandler) - forControlEvents:UIControlEventTouchUpInside]; -} - -- (void)triggerButtonActionHandler { - if (self.buttonActionBlock) { - self.buttonActionBlock(); - } -} - -@end - -@implementation TabBarViewControllerExample (Supplemental) - -- (void)setupTabBarColors { - self.tabBar.unselectedItemTintColor = MDCPalette.greyPalette.tint900; - self.tabBar.selectedItemTintColor = MDCPalette.bluePalette.tint500; -} - -- (nonnull NSArray *)constructExampleViewControllers { - NSBundle *bundle = [NSBundle bundleForClass:[TabBarViewControllerExample class]]; - MDCButtonScheme *buttonScheme = [[MDCButtonScheme alloc] init]; - buttonScheme.colorScheme = self.containerScheme.colorScheme; - buttonScheme.typographyScheme = self.containerScheme.typographyScheme; - - TBVCSampleViewController *child1 = [TBVCSampleViewController sampleWithTitle:@"One" - color:UIColor.redColor]; - - UIColor *blue = [UIColor colorWithRed:0x3A / 255.f green:0x56 / 255.f blue:0xFF / 255.f alpha:1]; - TBVCSampleViewController *child2 = [TBVCSampleViewController sampleWithTitle:@"Two" color:blue]; - __weak TabBarViewControllerExample *weakSelf = self; - [child2 setMDCButtonWithFrame:CGRectMake(10, 120, 300, 40) - buttonScheme:buttonScheme - title:@"Push and Hide Tab" - actionBlock:^{ - TabBarViewControllerExample *strongSelf = weakSelf; - TBVCSampleViewController *vc = - [TBVCSampleViewController sampleWithTitle:@"Push&Hide" - color:UIColor.grayColor]; - vc.colorScheme = strongSelf.containerScheme.colorScheme; - vc.typographyScheme = strongSelf.typographyScheme; - [strongSelf.navigationController pushViewController:vc animated:YES]; - }]; - - UIImage *starImage = [UIImage imageNamed:@"TabBarDemo_ic_star" - inBundle:bundle - compatibleWithTraitCollection:nil]; - TBVCSampleViewController *child3 = [TBVCSampleViewController sampleWithTitle:@"Three" - color:UIColor.blueColor - icon:starImage]; - [child3 setMDCButtonWithFrame:CGRectMake(10, 120, 300, 40) - buttonScheme:buttonScheme - title:@"Toggle Tab Bar" - actionBlock:^{ - TabBarViewControllerExample *strongSelf = weakSelf; - [strongSelf setTabBarHidden:!strongSelf.tabBarHidden animated:YES]; - }]; - - NSArray *viewControllers = @[ child1, child2, child3 ]; - for (TBVCSampleViewController *vc in viewControllers) { - vc.colorScheme = self.containerScheme.colorScheme; - vc.typographyScheme = self.typographyScheme; - } - return viewControllers; -} - -@end - -@implementation TabBarViewControllerExample (CatalogByConvention) - -+ (NSDictionary *)catalogMetadata { - return @{ - @"breadcrumbs" : @[ @"Tab Bar", @"TabBarViewController" ], - @"primaryDemo" : @NO, - @"presentable" : @NO, - }; -} - -- (BOOL)catalogShouldHideNavigation { - return YES; -} - -@end diff --git a/components/Tabs/src/Theming/MDCTabBar+MaterialTheming.h b/components/Tabs/src/Theming/MDCTabBar+MaterialTheming.h deleted file mode 100644 index d3c5abced3d..00000000000 --- a/components/Tabs/src/Theming/MDCTabBar+MaterialTheming.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2019-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 "MaterialContainerScheme.h" -#import "MaterialTabs.h" - -/** - This category is used to style MDCTabBar instances to a specific Material style which can be found - within the [Material Guidelines](https://material.io/design/components/tabs.html). - */ -@interface MDCTabBar (MaterialTheming) - -/** - Applies the Material Primary Theme to the receiver. - - @param scheme A container scheme used for theming. - */ -- (void)applyPrimaryThemeWithScheme:(nonnull id)scheme; - -/** - Applies the Material Surface Theme to the receiver. - - @param scheme A container scheme used for theming. - */ -- (void)applySurfaceThemeWithScheme:(nonnull id)scheme; - -@end diff --git a/components/Tabs/src/Theming/MDCTabBar+MaterialTheming.m b/components/Tabs/src/Theming/MDCTabBar+MaterialTheming.m deleted file mode 100644 index a54dbb5f51b..00000000000 --- a/components/Tabs/src/Theming/MDCTabBar+MaterialTheming.m +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2019-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 "MDCTabBar+MaterialTheming.h" - -#import -#import - -#import "MaterialColorScheme.h" -#import "MaterialTypographyScheme.h" - -static const CGFloat kPrimaryThemeUnselectedOpacity = (CGFloat)0.74; -static const CGFloat kSurfaceThemeUnselectedOpacity = (CGFloat)0.6; - -@implementation MDCTabBar (MaterialTheming) - -- (void)applyPrimaryThemeWithScheme:(nonnull id)scheme { - id colorScheme = scheme.colorScheme; - [self applyPrimaryThemeWithColorScheme:colorScheme]; - - id typographyScheme = scheme.typographyScheme; - [self applyThemeWithTypographyScheme:typographyScheme]; -} - -- (void)applySurfaceThemeWithScheme:(nonnull id)scheme { - id colorScheme = scheme.colorScheme; - [self applySurfaceThemeWithColorScheme:colorScheme]; - - id typographyScheme = scheme.typographyScheme; - [self applyThemeWithTypographyScheme:typographyScheme]; -} - -- (void)applyPrimaryThemeWithColorScheme:(id)colorScheme { - self.barTintColor = colorScheme.primaryColor; - self.tintColor = colorScheme.onPrimaryColor; - [self setTitleColor:colorScheme.onPrimaryColor forState:MDCTabBarItemStateSelected]; - [self setImageTintColor:colorScheme.onPrimaryColor forState:MDCTabBarItemStateSelected]; - UIColor *unselectedTitleColor = - [colorScheme.onPrimaryColor colorWithAlphaComponent:kPrimaryThemeUnselectedOpacity]; - UIColor *unselectedImageColor = - [colorScheme.onPrimaryColor colorWithAlphaComponent:kPrimaryThemeUnselectedOpacity]; - [self setTitleColor:unselectedTitleColor forState:MDCTabBarItemStateNormal]; - [self setImageTintColor:unselectedImageColor forState:MDCTabBarItemStateNormal]; -} - -- (void)applySurfaceThemeWithColorScheme:(id)colorScheme { - self.barTintColor = colorScheme.surfaceColor; - self.tintColor = colorScheme.primaryColor; - [self setTitleColor:colorScheme.primaryColor forState:MDCTabBarItemStateSelected]; - [self setImageTintColor:colorScheme.primaryColor forState:MDCTabBarItemStateSelected]; - UIColor *unselectedTitleColor = - [colorScheme.onSurfaceColor colorWithAlphaComponent:kSurfaceThemeUnselectedOpacity]; - UIColor *unselectedImageColor = - [colorScheme.onSurfaceColor colorWithAlphaComponent:kSurfaceThemeUnselectedOpacity]; - [self setTitleColor:unselectedTitleColor forState:MDCTabBarItemStateNormal]; - [self setImageTintColor:unselectedImageColor forState:MDCTabBarItemStateNormal]; -} - -- (void)applyThemeWithTypographyScheme:(id)typographyScheme { - self.selectedItemTitleFont = typographyScheme.button; - self.unselectedItemTitleFont = typographyScheme.button; -} - -@end diff --git a/components/Tabs/src/Theming/MaterialTabs+Theming.h b/components/Tabs/src/Theming/MaterialTabs+Theming.h deleted file mode 100644 index 618ea7c422b..00000000000 --- a/components/Tabs/src/Theming/MaterialTabs+Theming.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2019-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 "MDCTabBar+MaterialTheming.h" // IWYU pragma: keep diff --git a/components/Tabs/tests/snapshot/MDCTabBarDynamicColorSnapshotTests.m b/components/Tabs/tests/snapshot/MDCTabBarDynamicColorSnapshotTests.m deleted file mode 100644 index 66d3b23e012..00000000000 --- a/components/Tabs/tests/snapshot/MDCTabBarDynamicColorSnapshotTests.m +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright 2019-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 "MaterialSnapshot.h" - -#import "MaterialAvailability.h" -#import "MaterialTabs.h" -#import "MaterialTabs+Theming.h" -#import "MaterialColorScheme.h" -#import "MaterialContainerScheme.h" - -/** - An MDCTabBar subclass that allows the user to override the @c traitCollection property. - */ -@interface MDCTabBarWithCustomTraitCollection : MDCTabBar -@property(nonatomic, strong) UITraitCollection *traitCollectionOverride; -@end - -@implementation MDCTabBarWithCustomTraitCollection -- (UITraitCollection *)traitCollection { - return self.traitCollectionOverride ?: [super traitCollection]; -} -@end - -/** - A Snapshot test case for testing MDCTabBarWithCustomTraitCollection's dynamic color support. - */ -@interface MDCTabBarDynamicColorSnapshotTests : MDCSnapshotTestCase - -@property(nonatomic, strong) MDCContainerScheme *containerScheme; - -@property(nonatomic, strong) MDCTabBarWithCustomTraitCollection *tabBar; -@property(nonatomic, strong) UITabBarItem *item1; -@property(nonatomic, strong) UITabBarItem *item2; -@property(nonatomic, strong) UITabBarItem *item3; -@property(nonatomic, strong) UITabBarItem *item4; -@property(nonatomic, strong) UITabBarItem *item5; - -@end - -@implementation MDCTabBarDynamicColorSnapshotTests - -- (void)setUp { - [super setUp]; - - // Uncomment below to recreate all the goldens (or add the following line to the specific - // test you wish to recreate the golden for). - // self.recordMode = YES; - - self.tabBar = [[MDCTabBarWithCustomTraitCollection alloc] init]; - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - - CGSize imageSize = CGSizeMake(24, 24); - self.item1 = [[UITabBarItem alloc] - initWithTitle:@"Item 1" - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleCheckerboard] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:1]; - self.item1.badgeValue = @"1"; - - self.item2 = [[UITabBarItem alloc] - initWithTitle:@"Item 2" - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleDiagonalLines] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:2]; - self.item2.badgeValue = @"2"; - - self.item3 = [[UITabBarItem alloc] - initWithTitle:@"Item 3" - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleFramedX] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:3]; - self.item3.badgeValue = @"3"; - - self.item4 = [[UITabBarItem alloc] - initWithTitle:@"Item 4" - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleEllipses] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:4]; - self.item4.badgeValue = @"4"; - - self.containerScheme = [[MDCContainerScheme alloc] init]; - self.containerScheme.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201907]; - -#if MDC_AVAILABLE_SDK_IOS(13_0) - if (@available(iOS 13.0, *)) { - UIColor *dynamicOnPrimary = - [UIColor colorWithDynamicProvider:^(UITraitCollection *traitCollection) { - if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) { - return UIColor.greenColor; - } else { - return UIColor.yellowColor; - } - }]; - self.containerScheme.colorScheme.onPrimaryColor = dynamicOnPrimary; - - UIColor *dynamicBadgeColor = - [UIColor colorWithDynamicProvider:^(UITraitCollection *traitCollection) { - if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) { - return UIColor.redColor; - } else { - return UIColor.blueColor; - } - }]; - self.item1.badgeColor = dynamicBadgeColor; - self.item2.badgeColor = dynamicBadgeColor; - self.item3.badgeColor = dynamicBadgeColor; - self.item4.badgeColor = dynamicBadgeColor; - } -#endif // MDC_AVAILABLE_SDK_IOS(13_0) -} - -- (void)tearDown { - self.containerScheme = nil; - self.tabBar = nil; - self.item1 = nil; - self.item2 = nil; - self.item3 = nil; - self.item4 = nil; - - [super tearDown]; -} - -#pragma mark - Helpers - -- (void)generateSnapshotAndVerifyForView:(UIView *)view { - UIView *snapshotView = [view mdc_addToBackgroundView]; - [self snapshotVerifyView:snapshotView]; -} - -- (void)testColorSchemeDefaultsWithLightUserInterfaceStyle { -#if MDC_AVAILABLE_SDK_IOS(13_0) - if (@available(iOS 13.0, *)) { - // When - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - self.tabBar.items = @[ self.item1, self.item2, self.item3, self.item4 ]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // Then - UIView *snapshotView = [self.tabBar mdc_addToBackgroundView]; - [self snapshotVerifyViewForIOS13:snapshotView]; - } -#endif // MDC_AVAILABLE_SDK_IOS(13_0) -} - -- (void)testColorSchemeDefaultsWithDarkUserInterfaceStyle { -#if MDC_AVAILABLE_SDK_IOS(13_0) - if (@available(iOS 13.0, *)) { - // When - self.tabBar.traitCollectionOverride = - [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]; - self.tabBar.items = @[ self.item1, self.item2, self.item3, self.item4 ]; - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // Then - UIView *snapshotView = [self.tabBar mdc_addToBackgroundView]; - [self snapshotVerifyViewForIOS13:snapshotView]; - } -#endif // MDC_AVAILABLE_SDK_IOS(13_0) -} - -@end diff --git a/components/Tabs/tests/snapshot/MDCTabBarExtendedAlignmentSnapshotTests.m b/components/Tabs/tests/snapshot/MDCTabBarExtendedAlignmentSnapshotTests.m deleted file mode 100644 index 3806b5d5da7..00000000000 --- a/components/Tabs/tests/snapshot/MDCTabBarExtendedAlignmentSnapshotTests.m +++ /dev/null @@ -1,482 +0,0 @@ -// Copyright 2019-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 "MaterialSnapshot.h" - -#import "MDCTabBarExtendedAlignment.h" -#import "MaterialTabs.h" -#import "MaterialTabs+Theming.h" -#import "MaterialContainerScheme.h" - -static NSString *const kItemTitleShort1Latin = @"Quando"; -static NSString *const kItemTitleShort2Latin = @"No"; -static NSString *const kItemTitleShort3Latin = @"Facer"; - -static NSString *const kItemTitleLong1Latin = - @"Quando volumus maluisset cum ei, ad zril quodsi cum."; -static NSString *const kItemTitleLong2Latin = @"No quis modo nam, sea ea dicit tollit."; -static NSString *const kItemTitleLong3Latin = - @"Facer maluisset torquatos ad has, ad vix audiam assueverit mediocritatem."; - -static NSString *const kItemTitleShort1Arabic = @"عل"; -static NSString *const kItemTitleShort2Arabic = @"قد"; -static NSString *const kItemTitleShort3Arabic = @"وتم"; - -static NSString *const kItemTitleLong1Arabic = - @"عل أخذ استطاعوا الانجليزية. قد وحتّى بزمام التبرعات مكن."; -static NSString *const kItemTitleLong2Arabic = - @"وتم عل والقرى إتفاقية, عن هذا وباءت الغالي وفرنسا."; -static NSString *const kItemTitleLong3Arabic = @"تحت أي قدما وإقامة. ودول بشرية اليابانية لان ما."; - -/** Snapshot tests for MDCTabBar rendering .*/ -@interface MDCTabBarExtendedAlignmentSnapshotTests : MDCSnapshotTestCase - -/** The view being tested. */ -@property(nonatomic, strong) MDCTabBar *tabBar; -@property(nonatomic, strong) UITabBarItem *item1; -@property(nonatomic, strong) UITabBarItem *item2; -@property(nonatomic, strong) UITabBarItem *item3; -@property(nonatomic, strong) UITabBarItem *item4; -@property(nonatomic, strong) UITabBarItem *item5; -@end - -@implementation MDCTabBarExtendedAlignmentSnapshotTests - -- (void)setUp { - [super setUp]; - - // Uncomment below to recreate all the goldens (or add the following line to the specific - // test you wish to recreate the golden for). - // self.recordMode = YES; - - CGSize imageSize = CGSizeMake(24, 24); - self.tabBar = [[MDCTabBar alloc] init]; - self.item1 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort1Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleCheckerboard] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:1]; - self.item2 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort2Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleDiagonalLines] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:2]; - self.item3 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort3Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleFramedX] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:3]; - self.item3.badgeValue = kItemTitleShort1Latin; - self.item4 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort1Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleEllipses] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:4]; - self.item5 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort2Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleRectangles] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:5]; - self.tabBar.items = @[ self.item1, self.item2, self.item3, self.item4, self.item5 ]; - self.tabBar.alignment = (MDCTabBarAlignment)MDCTabBarExtendedAlignmentBestEffortJustified; - self.tabBar.selectedItem = self.item2; - [self.tabBar applyPrimaryThemeWithScheme:[[MDCContainerScheme alloc] init]]; -} - -- (void)tearDown { - self.tabBar = nil; - self.item1 = nil; - self.item2 = nil; - self.item3 = nil; - self.item4 = nil; - self.item5 = nil; - - [super tearDown]; -} - -- (void)changeLayoutToRTL { - [self changeViewToRTL:self.tabBar]; -} - -- (void)setTitlesToLatinLong { - self.item1.title = kItemTitleLong1Latin; - self.item2.title = kItemTitleLong2Latin; - self.item3.title = kItemTitleLong3Latin; - self.item3.badgeValue = kItemTitleLong1Latin; - self.item4.title = kItemTitleLong1Latin; - self.item5.title = kItemTitleLong2Latin; -} - -- (void)setTitlesToArabicShort { - self.item1.title = kItemTitleShort1Arabic; - self.item2.title = kItemTitleShort2Arabic; - self.item3.title = kItemTitleShort3Arabic; - self.item3.badgeValue = kItemTitleShort1Arabic; - self.item4.title = kItemTitleShort1Arabic; - self.item5.title = kItemTitleShort2Arabic; -} - -- (void)setTitlesToArabicLong { - self.item1.title = kItemTitleLong1Arabic; - self.item2.title = kItemTitleLong2Arabic; - self.item3.title = kItemTitleLong3Arabic; - self.item3.badgeValue = kItemTitleLong1Arabic; - self.item4.title = kItemTitleLong1Arabic; - self.item5.title = kItemTitleLong2Arabic; -} - -- (void)generateSnapshotAndVerifyForView:(UIView *)view { - UIView *snapshotView = [view mdc_addToBackgroundView]; - [self snapshotVerifyView:snapshotView]; -} - -#pragma mark - Static alignment tests - -- (void)testTabBarTitlesOnlyFitLatinLTR { - // When - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitlesOnlyFitArabicRTL { - // When - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitlesOnlyDontFitLatinLTR { - // When - [self setTitlesToLatinLong]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitlesOnlyDontFitArabicRTL { - // When - [self setTitlesToArabicLong]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitledImagesAppearanceFitLatinLTR { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitledImagesAppearanceFitArabicRTL { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitledImagesAppearanceDontFitLatinLTR { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - self.tabBar.frame = CGRectMake(0, 0, 200, 100); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitledImagesAppearanceDontFitArabicRTL { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 200, 100); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarImagesAppearanceFitLatinLTR { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceImages; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarImagesAppearanceFitArabicRTL { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceImages; - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarImagesAppearanceDontFitLatinLTR { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceImages; - self.tabBar.frame = CGRectMake(0, 0, 100, 100); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarImagesAppearanceDontFitArabicRTL { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceImages; - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 100, 100); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -#pragma mark - Reactive alignment tests - -- (void)testTabBarTitlesOnlyWhenSizeChangesToNotFitLatinLTR { - // Given - self.tabBar.selectedItem = self.item1; // Make it easier to see Leading alignment - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 200, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitlesOnlyWhenSizeChangesToNotFitArabicRTL { - // Given - self.tabBar.selectedItem = self.item1; // Make it easier to see Leading alignment - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 200, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitlesOnlyWhenSizeChangesToFitLatinLTR { - // Given - self.tabBar.frame = CGRectMake(0, 0, 100, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 480, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitlesOnlyWhenSizeChangesToFitArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 100, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 480, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarImagesOnlyWhenSizeChangesToNotFitLatinLTR { - // Given - self.tabBar.itemAppearance = MDCTabBarItemAppearanceImages; - self.tabBar.selectedItem = self.item1; // Make it easier to see Leading alignment - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 200, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarImagesOnlyWhenSizeChangesToNotFitArabicRTL { - // Given - self.tabBar.itemAppearance = MDCTabBarItemAppearanceImages; - self.tabBar.selectedItem = self.item1; // Make it easier to see Leading alignment - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 200, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarImagesOnlyWhenSizeChangesToFitLatinLTR { - // Given - self.tabBar.itemAppearance = MDCTabBarItemAppearanceImages; - self.tabBar.frame = CGRectMake(0, 0, 100, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 480, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarImagesOnlyWhenSizeChangesToFitArabicRTL { - // Given - self.tabBar.itemAppearance = MDCTabBarItemAppearanceImages; - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 100, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 480, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitledImagesWhenSizeChangesToNotFitLatinLTR { - // Given - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - self.tabBar.selectedItem = self.item1; // Make it easier to see Leading alignment - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 200, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitledImagesWhenSizeChangesToNotFitArabicRTL { - // Given - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - self.tabBar.selectedItem = self.item1; // Make it easier to see Leading alignment - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 480, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 200, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitledImagesWhenSizeChangesToFitLatinLTR { - // Given - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - self.tabBar.frame = CGRectMake(0, 0, 100, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 480, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarTitledImagesWhenSizeChangesToFitArabicRTL { - // Given - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - [self setTitlesToArabicShort]; - [self changeLayoutToRTL]; - self.tabBar.frame = CGRectMake(0, 0, 100, 100); - [self.tabBar sizeToFit]; - [self.tabBar layoutIfNeeded]; - - // When - self.tabBar.frame = CGRectMake(0, 0, 480, CGRectGetHeight(self.tabBar.bounds)); - [self.tabBar layoutIfNeeded]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -@end diff --git a/components/Tabs/tests/snapshot/MDCTabBarSizeClassDelegateSnapshotTests.m b/components/Tabs/tests/snapshot/MDCTabBarSizeClassDelegateSnapshotTests.m deleted file mode 100644 index fbfee42a105..00000000000 --- a/components/Tabs/tests/snapshot/MDCTabBarSizeClassDelegateSnapshotTests.m +++ /dev/null @@ -1,409 +0,0 @@ -// Copyright 2019-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 "MaterialSnapshot.h" - -#import "MaterialTabs.h" -#import "MDCTabBarSizeClassDelegate.h" -#import "MaterialTabs+Theming.h" -#import "MaterialContainerScheme.h" - -static NSString *const kItemTitleShort1Latin = @"Quando"; -static NSString *const kItemTitleShort2Latin = @"No"; -static NSString *const kItemTitleShort3Latin = @"Facer"; - -static NSString *const kItemTitleShort1Arabic = @"عل"; -static NSString *const kItemTitleShort2Arabic = @"قد"; -static NSString *const kItemTitleShort3Arabic = @"وتم"; - -/** Snapshot tests for MDCTabBar rendering .*/ -@interface MDCTabBarSizeClassDelegateSnapshotTests - : MDCSnapshotTestCase - -/** The view being tested. */ -@property(nonatomic, strong) MDCTabBar *tabBar; -@property(nonatomic, strong) UITabBarItem *item1; -@property(nonatomic, strong) UITabBarItem *item2; -@property(nonatomic, strong) UITabBarItem *item3; -@property(nonatomic, strong) UITabBarItem *item4; -@property(nonatomic, strong) UITabBarItem *item5; - -/** The returned horizontal size class when acting as the tab bar's size class delegate. */ -@property(nonatomic) UIUserInterfaceSizeClass horizontalSizeClass; -@end - -@implementation MDCTabBarSizeClassDelegateSnapshotTests - -- (void)setUp { - [super setUp]; - - // Uncomment below to recreate all the goldens (or add the following line to the specific - // test you wish to recreate the golden for). - // self.recordMode = YES; - - CGSize imageSize = CGSizeMake(24, 24); - self.tabBar = [[MDCTabBar alloc] init]; - self.item1 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort1Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleCheckerboard] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:1]; - self.item2 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort2Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleDiagonalLines] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:2]; - self.item3 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort3Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleFramedX] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:3]; - self.item3.badgeValue = kItemTitleShort1Latin; - self.item4 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort1Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleEllipses] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:4]; - self.item5 = [[UITabBarItem alloc] - initWithTitle:kItemTitleShort2Latin - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleRectangles] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:5]; - self.tabBar.items = @[ self.item1, self.item2, self.item3, self.item4, self.item5 ]; - [self.tabBar applySurfaceThemeWithScheme:[[MDCContainerScheme alloc] init]]; -} - -- (void)tearDown { - self.tabBar = nil; - self.item1 = nil; - self.item2 = nil; - self.item3 = nil; - self.item4 = nil; - self.item5 = nil; - - [super tearDown]; -} - -- (void)changeLayoutToRTL { - [self changeViewToRTL:self.tabBar]; -} - -- (void)setTitlesToArabicShort { - self.item1.title = kItemTitleShort1Arabic; - self.item2.title = kItemTitleShort2Arabic; - self.item3.title = kItemTitleShort3Arabic; - self.item3.badgeValue = kItemTitleShort1Arabic; - self.item4.title = kItemTitleShort1Arabic; - self.item5.title = kItemTitleShort2Arabic; -} - -- (void)generateSnapshotAndVerifyTabBar { - self.tabBar.frame = CGRectMake(0, 0, 240, 100); - [self.tabBar sizeToFit]; - UIView *snapshotView = [self.tabBar mdc_addToBackgroundView]; - [self snapshotVerifyView:snapshotView]; -} - -#pragma mark - MDCTabBarSizeClassDelegate methods - -- (UIUserInterfaceSizeClass)horizontalSizeClassForObject:(id)object { - return self.horizontalSizeClass; -} - -#pragma mark - Tests for Leading Alignment - -- (void)testLeadingAlignmentNilHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.alignment = MDCTabBarAlignmentLeading; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testLeadingAlignmentNilHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.alignment = MDCTabBarAlignmentLeading; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testLeadingAlignmentCompactHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassCompact; - self.tabBar.alignment = MDCTabBarAlignmentLeading; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testLeadingAlignmentCompactHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassCompact; - self.tabBar.alignment = MDCTabBarAlignmentLeading; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testLeadingAlignmentRegularHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassRegular; - self.tabBar.alignment = MDCTabBarAlignmentLeading; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testLeadingAlignmentRegularHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassRegular; - self.tabBar.alignment = MDCTabBarAlignmentLeading; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -#pragma mark - Tests for Justified Alignment - -- (void)testJustifiedAlignmentNilHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.alignment = MDCTabBarAlignmentJustified; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testJustifiedAlignmentNilHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.alignment = MDCTabBarAlignmentJustified; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testJustifiedAlignmentCompactHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassCompact; - self.tabBar.alignment = MDCTabBarAlignmentJustified; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testJustifiedAlignmentCompactHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassCompact; - self.tabBar.alignment = MDCTabBarAlignmentJustified; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testJustifiedAlignmentRegularHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassRegular; - self.tabBar.alignment = MDCTabBarAlignmentJustified; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testJustifiedAlignmentRegularHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassRegular; - self.tabBar.alignment = MDCTabBarAlignmentJustified; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -#pragma mark - Tests for Center Alignment - -- (void)testCenterAlignmentNilHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.alignment = MDCTabBarAlignmentCenter; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterAlignmentNilHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.alignment = MDCTabBarAlignmentCenter; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterAlignmentCompactHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassCompact; - self.tabBar.alignment = MDCTabBarAlignmentCenter; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterAlignmentCompactHorizontalSizeClassDelegateArabicRTL { - // Given - self.tabBar.sizeClassDelegate = self; - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.horizontalSizeClass = UIUserInterfaceSizeClassCompact; - self.tabBar.alignment = MDCTabBarAlignmentCenter; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterAlignmentRegularHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassRegular; - self.tabBar.alignment = MDCTabBarAlignmentCenter; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterAlignmentRegularHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassRegular; - self.tabBar.alignment = MDCTabBarAlignmentCenter; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -#pragma mark - Tests for CenterSelected Alignment - -- (void)testCenterSelectedAlignmentNilHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.alignment = MDCTabBarAlignmentCenterSelected; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterSelectedAlignmentNilHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.alignment = MDCTabBarAlignmentCenterSelected; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterSelectedAlignmentCompactHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassCompact; - self.tabBar.alignment = MDCTabBarAlignmentCenterSelected; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterSelectedAlignmentCompactHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassCompact; - self.tabBar.alignment = MDCTabBarAlignmentCenterSelected; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterSelectedAlignmentRegularHorizontalSizeClassDelegateLatinLTR { - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassRegular; - self.tabBar.alignment = MDCTabBarAlignmentCenterSelected; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -- (void)testCenterSelectedAlignmentRegularHorizontalSizeClassDelegateArabicRTL { - // Given - [self setTitlesToArabicShort]; - [self changeViewToRTL:self.tabBar]; - - // When - self.tabBar.sizeClassDelegate = self; - self.horizontalSizeClass = UIUserInterfaceSizeClassRegular; - self.tabBar.alignment = MDCTabBarAlignmentCenterSelected; - - // Then - [self generateSnapshotAndVerifyTabBar]; -} - -@end diff --git a/components/Tabs/tests/snapshot/Theming/MDCTabBar_MaterialThemingSnapshotTests.m b/components/Tabs/tests/snapshot/Theming/MDCTabBar_MaterialThemingSnapshotTests.m deleted file mode 100644 index 9168fee040c..00000000000 --- a/components/Tabs/tests/snapshot/Theming/MDCTabBar_MaterialThemingSnapshotTests.m +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2019-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 "MaterialSnapshot.h" - -#import "MaterialContainerScheme.h" -#import "MaterialTabs+Theming.h" -#import "MaterialTabs.h" - -static NSString *const kItemTitle1 = @"Item 1"; -static NSString *const kItemTitle2 = @"Item 2"; -static NSString *const kItemTitle3 = @"Item 3"; -static NSString *const kItemBadgeValue = @"Badge"; - -/** Snapshot tests for MDCTabBar rendering .*/ -@interface MDCTabBar_MaterialThemingSnapshotTests : MDCSnapshotTestCase - -/** The view being tested. */ -@property(nonatomic, strong) MDCTabBar *tabBar; -@property(nonatomic, strong) UITabBarItem *item1; -@property(nonatomic, strong) UITabBarItem *item2; -@property(nonatomic, strong) UITabBarItem *item3; -@property(nonatomic, strong) MDCContainerScheme *containerScheme; -@end - -@implementation MDCTabBar_MaterialThemingSnapshotTests - -- (void)setUp { - [super setUp]; - - // Uncomment below to recreate all the goldens (or add the following line to the specific - // test you wish to recreate the golden for). - // self.recordMode = YES; - - CGSize imageSize = CGSizeMake(24, 24); - self.tabBar = [[MDCTabBar alloc] init]; - self.item1 = [[UITabBarItem alloc] - initWithTitle:kItemTitle1 - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleCheckerboard] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:1]; - self.item2 = [[UITabBarItem alloc] - initWithTitle:kItemTitle2 - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleDiagonalLines] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:2]; - self.item3 = [[UITabBarItem alloc] - initWithTitle:kItemTitle3 - image:[[UIImage mdc_testImageOfSize:imageSize - withStyle:MDCSnapshotTestImageStyleFramedX] - imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - tag:3]; - self.item3.badgeValue = kItemBadgeValue; - self.tabBar.items = @[ self.item1, self.item2, self.item3 ]; - - self.containerScheme = [[MDCContainerScheme alloc] init]; -} - -- (void)tearDown { - self.tabBar = nil; - self.item1 = nil; - self.item2 = nil; - self.item3 = nil; - self.containerScheme = nil; - - [super tearDown]; -} - -- (void)generateSnapshotAndVerifyForView:(UIView *)view { - UIView *snapshotView = [view mdc_addToBackgroundView]; - [self snapshotVerifyView:snapshotView]; -} - -#pragma mark - Theme tests - -- (void)testTabBarPrimaryTheme { - // When - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - self.tabBar.frame = CGRectMake(0, 0, 250, 100); - [self.tabBar sizeToFit]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarSurfaceVariantTheme { - // When - [self.tabBar applySurfaceThemeWithScheme:self.containerScheme]; - self.tabBar.frame = CGRectMake(0, 0, 250, 100); - [self.tabBar sizeToFit]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarPrimaryThemeWithImage { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - self.tabBar.frame = CGRectMake(0, 0, 300, 100); - [self.tabBar sizeToFit]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -- (void)testTabBarSurfaceVariantThemeWithImage { - // When - self.tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; - [self.tabBar applySurfaceThemeWithScheme:self.containerScheme]; - self.tabBar.frame = CGRectMake(0, 0, 300, 100); - [self.tabBar sizeToFit]; - - // Then - [self generateSnapshotAndVerifyForView:self.tabBar]; -} - -@end diff --git a/components/Tabs/tests/unit/TabsThemingTests.m b/components/Tabs/tests/unit/TabsThemingTests.m deleted file mode 100644 index fff98ddb863..00000000000 --- a/components/Tabs/tests/unit/TabsThemingTests.m +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright 2019-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 "MaterialColorScheme.h" -#import "MaterialContainerScheme.h" -#import "MaterialTabs+Theming.h" -#import "MaterialTabs.h" -#import "MaterialTypographyScheme.h" - -static const CGFloat kPrimaryThemeUnselectedOpacity = (CGFloat)0.74; -static const CGFloat kSurfaceThemeUnselectedOpacity = (CGFloat)0.6; - -@interface MDCTabsThemingTest : XCTestCase -@property(nonatomic, strong) MDCTabBar *tabBar; -@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme; -@property(nonatomic, strong) MDCTypographyScheme *typographyScheme; -@property(nonatomic, strong) MDCContainerScheme *containerScheme; -@end - -@implementation MDCTabsThemingTest - -- (void)setUp { - [super setUp]; - - self.tabBar = [[MDCTabBar alloc] init]; - self.colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; - self.typographyScheme = - [[MDCTypographyScheme alloc] initWithDefaults:MDCTypographySchemeDefaultsMaterial201804]; - self.containerScheme = [[MDCContainerScheme alloc] init]; - self.containerScheme.colorScheme = self.colorScheme; - self.containerScheme.typographyScheme = self.typographyScheme; -} - -- (void)tearDown { - self.tabBar = nil; - self.colorScheme = nil; - self.typographyScheme = nil; - self.containerScheme = nil; - - [super tearDown]; -} - -- (void)testTabBarPrimaryThemingDefault { - // When - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - - // Then - [self verifyTabBarPrimaryTheming]; -} - -- (void)testTabBarPrimaryThemingCustom { - // Given - self.colorScheme = [self customColorScheme]; - self.typographyScheme = [self customTypographyScheme]; - self.containerScheme.colorScheme = self.colorScheme; - self.containerScheme.typographyScheme = self.typographyScheme; - - // When - [self.tabBar applyPrimaryThemeWithScheme:self.containerScheme]; - - // Then - [self verifyTabBarPrimaryTheming]; -} - -- (void)testTabBarSurfaceVariantThemingDefault { - // When - [self.tabBar applySurfaceThemeWithScheme:self.containerScheme]; - - // Then - [self verifyTabBarSurfaceVariantTheming]; -} - -- (void)testTabBarSurfaceVariantThemingCustom { - // Given - self.colorScheme = [self customColorScheme]; - self.typographyScheme = [self customTypographyScheme]; - self.containerScheme.colorScheme = self.colorScheme; - self.containerScheme.typographyScheme = self.typographyScheme; - - // When - [self.tabBar applySurfaceThemeWithScheme:self.containerScheme]; - - // Then - [self verifyTabBarSurfaceVariantTheming]; -} - -#pragma mark - Test helpers - -- (MDCSemanticColorScheme *)customColorScheme { - MDCSemanticColorScheme *colorScheme = - [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; - - colorScheme.primaryColor = [UIColor colorWithWhite:(CGFloat)0.9 alpha:0]; - colorScheme.primaryColorVariant = [UIColor colorWithWhite:(CGFloat)0.8 alpha:(CGFloat)0.1]; - colorScheme.secondaryColor = [UIColor colorWithWhite:(CGFloat)0.7 alpha:(CGFloat)0.2]; - colorScheme.errorColor = [UIColor colorWithWhite:(CGFloat)0.6 alpha:(CGFloat)0.3]; - colorScheme.surfaceColor = [UIColor colorWithWhite:(CGFloat)0.5 alpha:(CGFloat)0.4]; - colorScheme.backgroundColor = [UIColor colorWithWhite:(CGFloat)0.4 alpha:(CGFloat)0.5]; - colorScheme.onPrimaryColor = [UIColor colorWithWhite:(CGFloat)0.3 alpha:(CGFloat)0.6]; - colorScheme.onSecondaryColor = [UIColor colorWithWhite:(CGFloat)0.2 alpha:(CGFloat)0.7]; - colorScheme.onSurfaceColor = [UIColor colorWithWhite:(CGFloat)0.1 alpha:(CGFloat)0.8]; - colorScheme.onBackgroundColor = [UIColor colorWithWhite:0 alpha:(CGFloat)0.9]; - - return colorScheme; -} - -- (MDCTypographyScheme *)customTypographyScheme { - MDCTypographyScheme *typographyScheme = [[MDCTypographyScheme alloc] init]; - - typographyScheme.headline1 = [UIFont systemFontOfSize:1]; - typographyScheme.headline2 = [UIFont systemFontOfSize:2]; - typographyScheme.headline3 = [UIFont systemFontOfSize:3]; - typographyScheme.headline4 = [UIFont systemFontOfSize:4]; - typographyScheme.headline5 = [UIFont systemFontOfSize:5]; - typographyScheme.headline6 = [UIFont systemFontOfSize:6]; - typographyScheme.subtitle1 = [UIFont systemFontOfSize:7]; - typographyScheme.subtitle2 = [UIFont systemFontOfSize:8]; - typographyScheme.body1 = [UIFont systemFontOfSize:9]; - typographyScheme.body2 = [UIFont systemFontOfSize:10]; - typographyScheme.caption = [UIFont systemFontOfSize:11]; - typographyScheme.button = [UIFont systemFontOfSize:12]; - typographyScheme.overline = [UIFont systemFontOfSize:13]; - - return typographyScheme; -} - -- (void)verifyTabBarPrimaryTheming { - // Color - XCTAssertEqualObjects(self.tabBar.barTintColor, self.colorScheme.primaryColor); - XCTAssertEqualObjects(self.tabBar.tintColor, self.colorScheme.onPrimaryColor); - XCTAssertEqualObjects([self.tabBar titleColorForState:MDCTabBarItemStateSelected], - self.colorScheme.onPrimaryColor); - XCTAssertEqualObjects([self.tabBar imageTintColorForState:MDCTabBarItemStateSelected], - self.colorScheme.onPrimaryColor); - UIColor *unselectedTitleColor = - [self.colorScheme.onPrimaryColor colorWithAlphaComponent:kPrimaryThemeUnselectedOpacity]; - UIColor *unselectedImageColor = - [self.colorScheme.onPrimaryColor colorWithAlphaComponent:kPrimaryThemeUnselectedOpacity]; - XCTAssertEqualObjects([self.tabBar titleColorForState:MDCTabBarItemStateNormal], - unselectedTitleColor); - XCTAssertEqualObjects([self.tabBar imageTintColorForState:MDCTabBarItemStateNormal], - unselectedImageColor); - - // Typography - XCTAssertEqualObjects(self.tabBar.selectedItemTitleFont, self.typographyScheme.button); - XCTAssertEqualObjects(self.tabBar.unselectedItemTitleFont, self.typographyScheme.button); -} - -- (void)verifyTabBarSurfaceVariantTheming { - // Color - XCTAssertEqualObjects(self.tabBar.barTintColor, self.colorScheme.surfaceColor); - XCTAssertEqualObjects(self.tabBar.tintColor, self.colorScheme.primaryColor); - XCTAssertEqualObjects([self.tabBar titleColorForState:MDCTabBarItemStateSelected], - self.colorScheme.primaryColor); - XCTAssertEqualObjects([self.tabBar imageTintColorForState:MDCTabBarItemStateSelected], - self.colorScheme.primaryColor); - UIColor *unselectedTitleColor = - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:kSurfaceThemeUnselectedOpacity]; - UIColor *unselectedImageColor = - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:kSurfaceThemeUnselectedOpacity]; - XCTAssertEqualObjects([self.tabBar titleColorForState:MDCTabBarItemStateNormal], - unselectedTitleColor); - XCTAssertEqualObjects([self.tabBar imageTintColorForState:MDCTabBarItemStateNormal], - unselectedImageColor); - - // Typography - XCTAssertEqualObjects(self.tabBar.selectedItemTitleFont, self.typographyScheme.button); - XCTAssertEqualObjects(self.tabBar.unselectedItemTitleFont, self.typographyScheme.button); -} - -@end