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 @@
[self addSubview:searchStackView];
// Position the stack views.
NSArray* constraints = @[
@"H:|-horizontalMargin-[searchStackView]-(>=0)-[shortcutStackView]",
@"[shortcutStackView]-horizontalMargin-|",
];
NSDictionary* viewsDictionary = @{
@"searchStackView" : searchStackView,
@"shortcutStackView" : shortcutStackView,
};
NSDictionary* metrics = @{
@"horizontalMargin" : @(kHorizontalMargin),
};
ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics);
if (@available(iOS 11, *)) {
UILayoutGuide* layoutGuide = self.safeAreaLayoutGuide;
[NSLayoutConstraint activateConstraints:@[
[searchStackView.leadingAnchor
constraintEqualToAnchor:layoutGuide.leadingAnchor
constant:kHorizontalMargin],
[shortcutStackView.trailingAnchor
constraintEqualToAnchor:layoutGuide.trailingAnchor
constant:-kHorizontalMargin],
[searchStackView.trailingAnchor
constraintLessThanOrEqualToAnchor:shortcutStackView.leadingAnchor]
]];
} 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(shortcutStackView, self);
}
......@@ -135,6 +149,17 @@
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 {
UIButton* button = base::mac::ObjCCastStrict<UIButton>(sender);
[[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