material-components_materia.../components/HeaderStackView/examples/HeaderStackViewTypicalUseViewController.m
Junius Gunaratne 0411613c71 [Catalog] Demo selection screen updated with description and primary demo
Summary: Screenshot http://codereview.cc/M13

Reviewers: featherless, jstriegel, ajsecord, #mdc_ios_owners

Reviewed By: jstriegel, ajsecord, #mdc_ios_owners

Subscribers: ajsecord

Projects: #material_components_ios

Differential Revision: http://codereview.cc/D514
2016-04-07 16:45:52 -04:00

92 lines
2.7 KiB
Objective-C

/*
Copyright 2015-present Google Inc. 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 "MaterialHeaderStackView.h"
@interface HeaderStackViewTypicalUseViewController : UIViewController
@end
@implementation HeaderStackViewTypicalUseViewController {
BOOL _toggled;
MDCHeaderStackView *_stackView;
}
// TODO: Support other categorizational methods.
+ (NSArray *)catalogBreadcrumbs {
return @[ @"Header Stack View", @"Header Stack View" ];
}
+ (NSString *)catalogDescription {
return @"The Header Stack View component is a view that coordinates the layout of two"
" vertically-stacked bar views.";
}
- (BOOL)catalogIsPrimaryDemo {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIColor *blueColor = [UIColor colorWithRed:0.012 green:0.663 blue:0.957 alpha:0.2];
_stackView = [[MDCHeaderStackView alloc] init];
_stackView.backgroundColor = blueColor;
UINavigationBar *topBar = [[UINavigationBar alloc] init];
[topBar pushNavigationItem:self.navigationItem animated:NO];
_stackView.topBar = topBar;
UIToolbar *bottomBar = [[UIToolbar alloc] init];
bottomBar.items =
@[ [[UIBarButtonItem alloc] initWithTitle:@"Toggle"
style:UIBarButtonItemStylePlain
target:self
action:@selector(didTapToggleButton:)] ];
_stackView.bottomBar = bottomBar;
CGRect frame = self.view.bounds;
frame.origin.y = 150;
_stackView.frame = frame;
[_stackView sizeToFit];
[self.view addSubview:_stackView];
}
#pragma mark User actions
- (void)didTapToggleButton:(id)sender {
_toggled = !_toggled;
[UIView animateWithDuration:0.4
animations:^{
CGRect frame = _stackView.frame;
if (_toggled) {
frame.size.height = 200;
} else {
frame.size = [_stackView sizeThatFits:_stackView.bounds.size];
}
_stackView.frame = frame;
[_stackView layoutIfNeeded];
}];
}
@end