Skip to content

Commit

Permalink
[Buttons] Update secondary floating action button themer examples (#5922
Browse files Browse the repository at this point in the history
)

Update examples to use secondary floating button theming extension method instead of calling themer's class methods.

Related https://github.com/material-components/material-components-ios/issues/5844
  • Loading branch information
wenyuzzzz committed Dec 5, 2018
1 parent 89301b3 commit 6267009
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
15 changes: 9 additions & 6 deletions components/BottomAppBar/examples/BottomAppBarTypicalUseExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "MaterialBottomAppBar+ColorThemer.h"
#import "MaterialBottomAppBar.h"
#import "MaterialButtons+ButtonThemer.h"
#import "MaterialButtons+Theming.h"

#import "supplemental/BottomAppBarTypicalUseSupplemental.h"

Expand All @@ -33,6 +33,13 @@ - (id)init {
return self;
}

- (MDCContainerScheme *)containerScheme {
MDCContainerScheme *scheme = [[MDCContainerScheme alloc] init];
scheme.colorScheme = self.colorScheme;
scheme.typographyScheme = self.typographyScheme;
return scheme;
}

- (void)commonBottomBarSetup {
[self setupExampleTableLayout];

Expand Down Expand Up @@ -73,11 +80,7 @@ - (void)viewDidLoad {
[super viewDidLoad];
[self commonBottomBarSetup];

MDCButtonScheme *buttonScheme = [[MDCButtonScheme alloc] init];
buttonScheme.colorScheme = self.colorScheme;
buttonScheme.typographyScheme = self.typographyScheme;
[MDCFloatingActionButtonThemer applyScheme:buttonScheme
toButton:self.bottomBarView.floatingButton];
[self.bottomBarView.floatingButton applySecondaryThemeWithScheme:[self containerScheme]];
[MDCBottomAppBarColorThemer applySurfaceVariantWithSemanticColorScheme:self.colorScheme
toBottomAppBarView:self.bottomBarView];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ - (void)viewDidLoad {
setCorners:[[MDCCutCornerTreatment alloc]
initWithCut:CGRectGetWidth(self.floatingButton.bounds) / 2]];
self.floatingButton.shapeGenerator = floatingShapeGenerator;
[MDCFloatingActionButtonThemer applyScheme:buttonScheme toButton:self.floatingButton];
[self.floatingButton applySecondaryThemeWithScheme:self.containerScheme];

[self.floatingButton addTarget:self
action:@selector(didTap:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ - (id)init {
return self;
}

- (MDCContainerScheme *)containerScheme {
MDCContainerScheme *scheme = [[MDCContainerScheme alloc] init];
scheme.colorScheme = self.colorScheme;
scheme.shapeScheme = self.shapeScheme;
scheme.typographyScheme = self.typographyScheme;
return scheme;
}

- (void)viewDidLoad {
[super viewDidLoad];

Expand Down Expand Up @@ -157,7 +165,7 @@ - (void)viewDidLoad {
UIImage *plusImage =
[[UIImage imageNamed:@"Plus"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.floatingButton setImage:plusImage forState:UIControlStateNormal];
[MDCFloatingActionButtonThemer applyScheme:buttonScheme toButton:self.floatingButton];
[self.floatingButton applySecondaryThemeWithScheme:[self containerScheme]];
self.floatingButton.accessibilityLabel = @"Create";
[self.view addSubview:self.floatingButton];

Expand Down
1 change: 1 addition & 0 deletions components/Buttons/src/Theming/MaterialButtons+Theming.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
// limitations under the License.

#import "MDCButton+Theming.h"
#import "MDCFloatingButton+Theming.h"
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#import "MaterialButtons+Theming.h"
#import "MaterialButtons.h"
#import "MaterialButtons+ButtonThemer.h"
#import "MaterialFeatureHighlight.h"
#import "MaterialFeatureHighlight+ColorThemer.h"
#import "MaterialFeatureHighlight+FeatureHighlightAccessibilityMutator.h"
#import "MaterialFeatureHighlight+TypographyThemer.h"
#import "MaterialFeatureHighlight.h"
#import "supplemental/FeatureHighlightExampleSupplemental.h"

@implementation FeatureHighlightShownViewExample
Expand All @@ -32,17 +32,20 @@ - (id)init {
return self;
}

- (void)didTapButton:(id)sender {
MDCButtonScheme *buttonScheme = [[MDCButtonScheme alloc] init];
buttonScheme.colorScheme = self.colorScheme;
buttonScheme.typographyScheme = self.typographyScheme;
- (MDCContainerScheme *)containerScheme {
MDCContainerScheme *scheme = [[MDCContainerScheme alloc] init];
scheme.colorScheme = self.colorScheme;
scheme.typographyScheme = self.typographyScheme;
return scheme;
}

- (void)didTapButton:(id)sender {
MDCFloatingButton *fab = [[MDCFloatingButton alloc] init];
[fab setImage:[UIImage imageNamed:@"Plus"] forState:UIControlStateNormal];
[fab sizeToFit];
fab.center = _button.center;

[MDCFloatingActionButtonThemer applyScheme:buttonScheme toButton:fab];
[fab applySecondaryThemeWithScheme:self.containerScheme];

MDCFeatureHighlightViewController *vc =
[[MDCFeatureHighlightViewController alloc] initWithHighlightedView:_button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#import "MaterialCollections.h"
#import "MaterialColorScheme.h"
#import "MaterialContainerScheme.h"
#import "MaterialTypographyScheme.h"

@interface FeatureHighlightTypicalUseViewController : UIViewController
Expand Down Expand Up @@ -47,6 +48,7 @@

@property(nonatomic, strong) MDCSemanticColorScheme *colorScheme;
@property(nonatomic, strong) MDCTypographyScheme *typographyScheme;
@property(nonatomic, readonly, strong) MDCContainerScheme *containerScheme;

- (void)didTapButton:(id)sender;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

#import "FeatureHighlightExampleSupplemental.h"

#import "MaterialButtons.h"
#import "MaterialButtons+ButtonThemer.h"
#import "MaterialButtons+Theming.h"
#import "MaterialButtons.h"
#import "MaterialMath.h"
#import "MaterialPalettes.h"
#import "MaterialTypography.h"
Expand Down Expand Up @@ -209,8 +210,7 @@ - (void)viewDidLoad {
self.button = fab;
[self.view addSubview:self.button];

[MDCFloatingActionButtonThemer applyScheme:buttonScheme toButton:fab];

[fab applySecondaryThemeWithScheme:self.containerScheme];

MDCButton *actionButton = [[MDCButton alloc] init];
self.actionButton = actionButton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#import "MaterialChips+ShapeThemer.h"
#import "MaterialChips.h"
#import "MaterialColorScheme.h"
#import "MaterialContainerScheme.h"
#import "MaterialShapeLibrary.h"
#import "MaterialShapeScheme.h"
#import "MaterialTypographyScheme.h"
Expand Down Expand Up @@ -123,7 +124,7 @@ - (void)initializeComponentry {
UIImage *plusImage =
[[UIImage imageNamed:@"Plus"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.floatingButton setImage:plusImage forState:UIControlStateNormal];
[MDCFloatingActionButtonThemer applyScheme:buttonScheme toButton:self.floatingButton];
[self.floatingButton applySecondaryThemeWithScheme:[self containerScheme]];
[self.floatingButton sizeToFit];
self.floatingButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.componentContentView addSubview:self.floatingButton];
Expand Down

0 comments on commit 6267009

Please sign in to comment.