Yurii Samsoniuk 2a96682230 Replace unnecessary imports with forward declarations (#2429)
* [Themes] Remove unnecessary imports.

* [TextFields] Remove unnecessary imports.

* [Typography] Do not use an umbrella header inside of a component.

* [Snackbar] Do not use self umbrella header.

* [ActivityIndicator] Do not use self umbrella header.

* [AppBar] Use umbrella headers.

* [AppBar] Remove self import header.

* [ButtonBar] Removed self umbrella header imports.

* [Buttons] Removed self umbrella header imports.

* [Collections] Update imports.

* [Dialogs] Moved import into an m file.

* [Collections] Fixed imports.

* [FeatureHighlight] Removed self umbrealla imports.

* [HeaderStackView] Reordered imports.

* [Ink] Replaced imports with forward declarations.

* [Slider] Replaced self umbrella import use.

* [Snackbar] Removed self umbrella header import.

* [Tabs] Changed math import. Replaced self umbrella header import.

* [Icons] Removed unnecessary imports.

* [Overlay] Replaced umbrella header import.

* [ShapeLibrary] Replace Shapes imports with an umbrella header.

* [Shapes] Replaced imports with forward declarations.

* [AppBar] Replace import with a forward declaration.

* [Examples] Updated imports.

* Fixed conflicting imports

* Added space between different import categories
2017-11-16 18:25:06 -05:00

163 lines
5.7 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 "MaterialButtons.h"
#import "MaterialTypography.h"
#import "supplemental/ButtonsTypicalUseSupplemental.h"
@interface ButtonsTypicalUseViewController ()
@property(nonatomic, strong) MDCFloatingButton *floatingButton;
@end
@implementation ButtonsTypicalUseViewController
- (MDCButton *)buildCustomStrokedButton {
MDCButton *button = [[MDCButton alloc] init];
[button setBackgroundColor:[UIColor clearColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor colorWithWhite:0.1f alpha:1] forState:UIControlStateNormal];
button.inkColor = [UIColor colorWithWhite:0 alpha:0.06f];
button.disabledAlpha = 0.38f;
[button setBorderWidth:1.0 forState:UIControlStateNormal];
[button setBorderColor:[UIColor colorWithWhite:0.1f alpha:1] forState:UIControlStateNormal];
return button;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithWhite:0.9f alpha:1];
UIColor *titleColor = [UIColor whiteColor];
// Raised button
MDCRaisedButton *raisedButton = [[MDCRaisedButton alloc] init];
[raisedButton setTitleColor:titleColor forState:UIControlStateNormal];
[raisedButton setTitle:@"Button" forState:UIControlStateNormal];
[raisedButton sizeToFit];
[raisedButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:raisedButton];
// Disabled raised button
MDCRaisedButton *disabledRaisedButton = [[MDCRaisedButton alloc] init];
[disabledRaisedButton setTitleColor:titleColor forState:UIControlStateNormal];
[disabledRaisedButton setTitle:@"Button" forState:UIControlStateNormal];
[disabledRaisedButton sizeToFit];
[disabledRaisedButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[disabledRaisedButton setEnabled:NO];
[self.view addSubview:disabledRaisedButton];
// Flat button
MDCFlatButton *flatButton = [[MDCFlatButton alloc] init];
[flatButton setTitle:@"Button" forState:UIControlStateNormal];
[flatButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[flatButton sizeToFit];
[flatButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:flatButton];
// Disabled flat
MDCFlatButton *disabledFlatButton = [[MDCFlatButton alloc] init];
[disabledFlatButton setTitle:@"Button" forState:UIControlStateNormal];
[disabledFlatButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[disabledFlatButton sizeToFit];
[disabledFlatButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[disabledFlatButton setEnabled:NO];
[self.view addSubview:disabledFlatButton];
// Custom stroked button
MDCButton *strokedButton = [self buildCustomStrokedButton];
[strokedButton setTitle:@"Button" forState:UIControlStateNormal];
[strokedButton sizeToFit];
[strokedButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:strokedButton];
// Disabled custom stroked button
MDCButton *disabledStrokedButton = [self buildCustomStrokedButton];
[disabledStrokedButton setTitle:@"Button" forState:UIControlStateNormal];
[disabledStrokedButton sizeToFit];
[disabledStrokedButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[disabledStrokedButton setEnabled:NO];
[self.view addSubview:disabledStrokedButton];
// Floating action button
self.floatingButton = [[MDCFloatingButton alloc] init];
[self.floatingButton setTitleColor:titleColor forState:UIControlStateNormal];
[self.floatingButton sizeToFit];
[self.floatingButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
UIImage *plusImage = [UIImage imageNamed:@"Plus"];
[self.floatingButton setImage:plusImage forState:UIControlStateNormal];
[self.view addSubview:self.floatingButton];
self.buttons = @[
raisedButton, disabledRaisedButton, flatButton, disabledFlatButton, strokedButton,
disabledStrokedButton, self.floatingButton
];
[self setupExampleViews];
}
- (void)didTap:(id)sender {
NSLog(@"%@ was tapped.", NSStringFromClass([sender class]));
if (sender == self.floatingButton) {
[self.floatingButton
collapse:YES
completion:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
[self.floatingButton expand:YES completion:nil];
});
}];
}
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (animated) {
[self.floatingButton collapse:NO completion:nil];
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (animated) {
[self.floatingButton expand:YES completion:nil];
}
}
@end