Junius Gunaratne 4596b7c861 [MDCFloatingButton] Floating action button should use a shape rather than text (#833)
* [MDCInkView] cancelAllAnimationsAnimated should support disabling animation

* [MDCProgressView] Allow completion block to be modified if setHidden:animated:completion is called sequentially

* Call completion block immediately rather than storing as a property.

* Add nil check for completion block

* [Shrine] Update to Swift 3

* [AppBar] Add Objective C AppBar storyboard example

* Add right button bar item to AppBar swift demo

* Add plus shape icon to FAB

* Move plus symbol to example code

* Add plus icon asset, move to supplemental

* Remove unused methods

* Undo change to print.

* Move plus CAShapeLayer code into its own method

* Remove plus path method

* Use supplemental method to get plus symbol CAShapeLayer
2016-11-16 13:31:59 -05:00

113 lines
3.8 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 "ButtonsTypicalUseSupplemental.h"
#import "MaterialButtons.h"
#import "MaterialTypography.h"
@interface ButtonsTypicalUseViewController ()
@end
@implementation ButtonsTypicalUseViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// Raised button
MDCRaisedButton *raisedButton = [[MDCRaisedButton alloc] init];
[raisedButton setTitle:@"Button" forState:UIControlStateNormal];
[raisedButton sizeToFit];
[raisedButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
raisedButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:raisedButton];
// Disabled raised button
MDCRaisedButton *disabledRaisedButton = [[MDCRaisedButton alloc] init];
[disabledRaisedButton setTitle:@"Button" forState:UIControlStateNormal];
[disabledRaisedButton sizeToFit];
[disabledRaisedButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[disabledRaisedButton setEnabled:NO];
disabledRaisedButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:disabledRaisedButton];
// Flat button
MDCFlatButton *flatButton = [[MDCFlatButton alloc] init];
[flatButton setTitle:@"Button" forState:UIControlStateNormal];
[flatButton setCustomTitleColor:[UIColor grayColor]];
[flatButton sizeToFit];
[flatButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
flatButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:flatButton];
// Disabled flat
MDCFlatButton *disabledFlatButton = [[MDCFlatButton alloc] init];
[disabledFlatButton setTitle:@"Button" forState:UIControlStateNormal];
[disabledFlatButton setCustomTitleColor:[UIColor grayColor]];
[disabledFlatButton sizeToFit];
[disabledFlatButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
[disabledFlatButton setEnabled:NO];
disabledFlatButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:disabledFlatButton];
// Floating action button
MDCFloatingButton *floatingButton = [[MDCFloatingButton alloc] init];
[floatingButton sizeToFit];
[floatingButton addTarget:self
action:@selector(didTap:)
forControlEvents:UIControlEventTouchUpInside];
floatingButton.translatesAutoresizingMaskIntoConstraints = NO;
CGFloat floatingButtonPlusDimension = 24.0f;
UIImage *plusImage = [UIImage imageNamed:@"Plus"];
[floatingButton setImage:plusImage forState:UIControlStateNormal];
[self.view addSubview:floatingButton];
NSDictionary *views = @{
@"raised" : raisedButton,
@"disabledRaised" : disabledRaisedButton,
@"flat" : flatButton,
@"disabledFlat" : disabledFlatButton,
@"floating" : floatingButton
};
self.views = [NSMutableDictionary dictionary];
[self.views addEntriesFromDictionary:views];
[self setupExampleViews];
}
- (void)didTap:(id)sender {
NSLog(@"%@ was tapped.", NSStringFromClass([sender class]));
}
@end