Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tabs] fix TabBarViewControllerExample to respect safe area #4949

Merged
merged 2 commits into from
Aug 30, 2018

Conversation

wenyuzhang666
Copy link
Contributor

closes #3728

Before

b1

After:

a1

TBVCSampleViewController *vc =
[TBVCSampleViewController sampleWithTitle:@"Push&Hide" color:UIColor.grayColor];
vc.colorScheme = self.colorScheme;
vc.typographyScheme = self.typographyScheme;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use strongSelf here and above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Addressed in a46864d.

action:@selector(toggleTabBar)
forControlEvents:UIControlEventTouchUpInside];

self.selectedViewController = [self.viewControllers firstObject];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Please use dot notation for property access.

self.selectedViewController = self.viewControllers.firstObject;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Addressed in a46864d.

- (void)addMDCButtonWithFrame:(CGRect)frame
buttonScheme:(id<MDCButtonScheming>)buttonScheme
title:(NSString *)title
actionBlock:(MDCButtonActionBlock)actionBlock;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add nullability specifiers for these arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a46864d.

@property(nonatomic) MDCAppBarViewController *appBarViewController;
@property(nonatomic) UILabel *titleLabel;
@property(nonatomic) CGRect buttonFrame;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document that this is the "target" frame desired by the calling code. Reading the property, I thought it was going to be just a copy of self.button.frame.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Addressed in a46864d.

@property(nonatomic) MDCAppBarViewController *appBarViewController;
@property(nonatomic) UILabel *titleLabel;
@property(nonatomic) CGRect buttonFrame;
@property(nonatomic) UIButton *button;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this MDCButton * since we cannot apply an <MDCButtonScheming> to a UIButton.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a46864d.

@@ -78,6 +84,17 @@ - (void)viewWillAppear:(BOOL)animated {
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
_titleLabel.center = self.view.center;
UIEdgeInsets edgeInsets = UIEdgeInsetsZero;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit/nameing: safeAreaInsets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a46864d.

edgeInsets = self.view.safeAreaInsets;
}
CGRect buttonFrame = self.buttonFrame;
self.button.frame = CGRectMake(buttonFrame.origin.x + edgeInsets.left,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider using CGRectOffset, since I believe that's what you're going for here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a46864d.

[MDCContainedButtonThemer applyScheme:buttonScheme toButton:button];
[self.view addSubview:button];
self.button = button;
self.buttonFrame = frame;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider calling CGRectStandardize before assigning the property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a46864d.


+ (nonnull instancetype)sampleWithTitle:(nonnull NSString *)title color:(nonnull UIColor *)color;

- (void)addMDCButtonWithFrame:(CGRect)frame
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming/nit: Please make this setMDCButtonWithFrame:... since there can only be one. :highlander:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a46864d.

title:@"Toggle Tab Bar"
actionBlock:^{
TabBarViewControllerExample *strongSelf = weakSelf;
[strongSelf setTabBarHidden:!strongSelf.tabBarHidden animated:YES];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a property, please use the dot syntax.

strongSelf.tabBarHidden = !self.isTabBarHidden;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the original behavior since it wanted to animate out the tab bar. Would it be okay if I change the behavior?

Copy link
Contributor Author

@wenyuzhang666 wenyuzhang666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romoore thanks for the comments. I addressed them in a46864d.

@wenyuzhang666 wenyuzhang666 merged commit 4b00a6c into material-components:develop Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants