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

145 lines
4.6 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 "MaterialAppBar.h"
#import "MaterialAppBar+ColorThemer.h"
@interface AppBarImageryExample : UITableViewController
@property(nonatomic, strong) MDCAppBarViewController *appBarViewController;
@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
@end
@implementation AppBarImageryExample
- (void)dealloc {
// Required for pre-iOS 11 devices because we've enabled observesTrackingScrollViewScrollEvents.
self.appBarViewController.headerView.trackingScrollView = nil;
}
- (id)init {
self = [super init];
if (self) {
_colorScheme = [[MDCSemanticColorScheme alloc] init];
_appBarViewController = [[MDCAppBarViewController alloc] init];
// Behavioral flags.
_appBarViewController.inferTopSafeAreaInsetFromViewController = YES;
_appBarViewController.headerView.minMaxHeightIncludesSafeArea = NO;
self.title = @"Imagery";
[self addChildViewController:_appBarViewController];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Create our custom image view and add it to the header view.
UIImageView *imageView = [[UIImageView alloc]
initWithImage:
[UIImage imageNamed:@"mdc_theme"
inBundle:[NSBundle bundleForClass:[AppBarImageryExample class]]
compatibleWithTraitCollection:nil]];
imageView.frame = self.appBarViewController.headerView.bounds;
// Ensure that the image view resizes in reaction to the header view bounds changing.
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// Ensure that the image view is below other App Bar views (headerStackView).
[self.appBarViewController.headerView insertSubview:imageView atIndex:0];
// Scales up the image while the header is over-extending.
imageView.contentMode = UIViewContentModeScaleAspectFill;
// The header view does not clip to bounds by default so we ensure that the image is clipped.
imageView.clipsToBounds = YES;
[MDCAppBarColorThemer applyColorScheme:self.colorScheme
toAppBarViewController:self.appBarViewController];
// Make sure navigation bar background color is clear so the image view is visible.
self.appBarViewController.navigationBar.backgroundColor = [UIColor clearColor];
// Allow the header to show more of the image.
self.appBarViewController.headerView.maximumHeight = 300;
// Allows us to avoid forwarding events, but means we can't enable shift behaviors.
self.appBarViewController.headerView.observesTrackingScrollViewScrollEvents = YES;
// Typical use
self.appBarViewController.headerView.trackingScrollView = self.tableView;
[self.view addSubview:self.appBarViewController.view];
[self.appBarViewController didMoveToParentViewController:self];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
// Ensure that our status bar is white.
return UIStatusBarStyleLightContent;
}
@end
@implementation AppBarImageryExample (TypicalUse)
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
@end
@implementation AppBarImageryExample (CatalogByConvention)
+ (NSDictionary *)catalogMetadata {
return @{
@"breadcrumbs": @[ @"App Bar", @"Imagery" ],
@"primaryDemo": @NO,
@"presentable": @YES
};
}
- (BOOL)catalogShouldHideNavigation {
return YES;
}
@end
#pragma mark - Typical application code (not Material-specific)
@implementation AppBarImageryExample (UITableViewDataSource)
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell =
[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
@end