mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
## Related links * Related bug: #6441 * Theming extensions: [Buttons+Theming](https://github.com/material-components/material-components-ios/tree/develop/components/Buttons/src/Theming) ## Introduction The team is pivoting to using theming extensions so our examples should reflect the current best practices when using our APIs. ## The problem We are using _Themers_ in some instances and some instances used a work around for the container scheme. In #6458 we added a Catalog wide container scheme. ## The fix Remove _Themers_ for _Theming extensions_ and remove the workarounds for not having a catalog wide container scheme.
78 lines
2.6 KiB
Objective-C
78 lines
2.6 KiB
Objective-C
// Copyright 2017-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 "MaterialButtons+Theming.h"
|
|
#import "MaterialButtons.h"
|
|
#import "MaterialContainerScheme.h"
|
|
|
|
@interface ButtonsContentEdgeInsetsExample : UIViewController
|
|
@property(weak, nonatomic) IBOutlet MDCButton *textButton;
|
|
@property(weak, nonatomic) IBOutlet MDCButton *containedButton;
|
|
@property(weak, nonatomic) IBOutlet MDCFloatingButton *floatingActionButton;
|
|
@property(weak, nonatomic) IBOutlet UISwitch *inkBoundingSwitch;
|
|
@property(strong, nonatomic) MDCContainerScheme *containerScheme;
|
|
@end
|
|
|
|
@implementation ButtonsContentEdgeInsetsExample
|
|
|
|
#pragma mark - Catalog by Convention
|
|
|
|
+ (NSDictionary *)catalogMetadata {
|
|
return @{
|
|
@"breadcrumbs" : @[ @"Buttons", @"Buttons (Content Edge Insets)" ],
|
|
@"primaryDemo" : @NO,
|
|
@"presentable" : @NO,
|
|
@"storyboardName" : @"ButtonsContentEdgeInsets",
|
|
};
|
|
}
|
|
|
|
#pragma mark - UIViewController
|
|
|
|
- (id)init {
|
|
self = [super init];
|
|
if (self) {
|
|
_containerScheme = [[MDCContainerScheme alloc] init];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
[self.textButton applyTextThemeWithScheme:self.containerScheme];
|
|
[self.containedButton applyContainedThemeWithScheme:[self containerScheme]];
|
|
|
|
self.textButton.contentEdgeInsets = UIEdgeInsetsMake(64, 64, 0, 0);
|
|
self.containedButton.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 64, 64);
|
|
[self.floatingActionButton setContentEdgeInsets:UIEdgeInsetsMake(40, 40, 0, 0)
|
|
forShape:MDCFloatingButtonShapeDefault
|
|
inMode:MDCFloatingButtonModeNormal];
|
|
|
|
[self updateInkStyle:self.inkBoundingSwitch.isOn ? MDCInkStyleBounded : MDCInkStyleUnbounded];
|
|
}
|
|
|
|
- (void)updateInkStyle:(MDCInkStyle)inkStyle {
|
|
self.textButton.inkStyle = inkStyle;
|
|
self.containedButton.inkStyle = inkStyle;
|
|
self.floatingActionButton.inkStyle = inkStyle;
|
|
}
|
|
|
|
- (IBAction)didChangeInkStyle:(UISwitch *)sender {
|
|
[self updateInkStyle:sender.isOn ? MDCInkStyleBounded : MDCInkStyleUnbounded];
|
|
}
|
|
|
|
@end
|