material-components_materia.../components/Tabs/examples/TabBarInterfaceBuilderExample.m
featherless 2181084272
[automated] Standardize our open source license stanza to what Xcode generates. (#4985)
Removes the need to copy-paste stanzas from other files anymore as we'll rely on #4478 to generate the correct stanza for us instead.

This was an automated change generated by running a find-and-replace regular expression:

```
/\*
 Copyright ([0-9]+)-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\.
 \*/
```

```
/\*
Copyright ([0-9]+)-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\.
\*/
```

```
/\*
 Copyright ([0-9]+)-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\.
 \*/
```

```
// Copyright $1-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.
```
2018-08-31 12:13:07 -04:00

122 lines
4.5 KiB
Objective-C

// 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/UIKit.h>
#import "MaterialColorScheme.h"
#import "MaterialPalettes.h"
#import "MaterialTabs.h"
#import "MaterialTabs+ColorThemer.h"
@interface TabBarInterfaceBuilderExample : UIViewController <MDCTabBarDelegate>
@property(weak, nonatomic) IBOutlet MDCTabBar *tabBar;
@property(nonatomic) NSArray<UIColor *> *colors;
@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
@end
@implementation TabBarInterfaceBuilderExample
- (id)init {
self = [super init];
if (self) {
self.colorScheme = [[MDCSemanticColorScheme 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
];
[MDCTabBarColorThemer applySemanticColorScheme:self.colorScheme toTabs:self.tabBar];
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