Commit b472bbd6 authored by Jean-François Geyelin's avatar Jean-François Geyelin Committed by Commit Bot

Have the toolbar's KAV respect the safeAreaLayoutGuide on iOS11.

Bug: 764692
Change-Id: I3e2493f770e8218aa9a5eb0351dfc0db0612832d
Reviewed-on: https://chromium-review.googlesource.com/664809
Commit-Queue: Jean-François Geyelin <jif@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501638}
parent a43ad218
...@@ -88,18 +88,32 @@ ...@@ -88,18 +88,32 @@
[self addSubview:searchStackView]; [self addSubview:searchStackView];
// Position the stack views. // Position the stack views.
NSArray* constraints = @[ if (@available(iOS 11, *)) {
@"H:|-horizontalMargin-[searchStackView]-(>=0)-[shortcutStackView]", UILayoutGuide* layoutGuide = self.safeAreaLayoutGuide;
@"[shortcutStackView]-horizontalMargin-|", [NSLayoutConstraint activateConstraints:@[
]; [searchStackView.leadingAnchor
NSDictionary* viewsDictionary = @{ constraintEqualToAnchor:layoutGuide.leadingAnchor
@"searchStackView" : searchStackView, constant:kHorizontalMargin],
@"shortcutStackView" : shortcutStackView, [shortcutStackView.trailingAnchor
}; constraintEqualToAnchor:layoutGuide.trailingAnchor
NSDictionary* metrics = @{ constant:-kHorizontalMargin],
@"horizontalMargin" : @(kHorizontalMargin), [searchStackView.trailingAnchor
}; constraintLessThanOrEqualToAnchor:shortcutStackView.leadingAnchor]
ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics); ]];
} else {
NSArray* constraints = @[
@"H:|-horizontalMargin-[searchStackView]-(>=0)-[shortcutStackView]",
@"[shortcutStackView]-horizontalMargin-|",
];
NSDictionary* viewsDictionary = @{
@"searchStackView" : searchStackView,
@"shortcutStackView" : shortcutStackView,
};
NSDictionary* metrics = @{
@"horizontalMargin" : @(kHorizontalMargin),
};
ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics);
}
AddSameCenterYConstraint(searchStackView, self); AddSameCenterYConstraint(searchStackView, self);
AddSameCenterYConstraint(shortcutStackView, self); AddSameCenterYConstraint(shortcutStackView, self);
} }
...@@ -135,6 +149,17 @@ ...@@ -135,6 +149,17 @@
return YES; return YES;
} }
- (void)layoutMarginsDidChange {
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
NSLog(@"%i", self.preservesSuperviewLayoutMargins);
NSLog(@"%f %f", self.layoutMargins.left, self.layoutMargins.right);
[super layoutMarginsDidChange];
}
- (void)keyboardButtonPressed:(id)sender { - (void)keyboardButtonPressed:(id)sender {
UIButton* button = base::mac::ObjCCastStrict<UIButton>(sender); UIButton* button = base::mac::ObjCCastStrict<UIButton>(sender);
[[UIDevice currentDevice] playInputClick]; [[UIDevice currentDevice] playInputClick];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment