Commit 0b5a1d44 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Fix QR code scanner animation

This fixes the QR Code scanner animation when presenting and dismissing
it. The animation was animating frames, which was causing problem with
the topLayoutGuide. Using translate transformation fixes this.

Bug: 793829
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ibd38205dbe15fe0edef44a44e30b5ed36f0c28b1
Reviewed-on: https://chromium-review.googlesource.com/828833
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarLouis Romero <lpromero@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524375}
parent 32099f3d
......@@ -58,37 +58,34 @@ enum QRScannerTransition { PRESENT, DISMISS };
CGRect finalFrame =
[transitionContext finalFrameForViewController:presentedViewController];
CGRect initialFrame;
ProceduralBlock animations;
// Set the frame for the presented view.
presentedView.frame = finalFrame;
[presentedView layoutIfNeeded];
switch (_transition) {
case PRESENT: {
[containerView insertSubview:presentedView belowSubview:presentingView];
initialFrame = finalFrame;
finalFrame.origin.y = -finalFrame.size.height;
animations = ^void {
[presentingView setFrame:finalFrame];
presentingView.transform =
CGAffineTransformMakeTranslation(0, -finalFrame.size.height);
};
break;
}
case DISMISS: {
[containerView insertSubview:presentedView aboveSubview:presentingView];
initialFrame = finalFrame;
initialFrame.origin.y = -initialFrame.size.height;
presentedView.transform =
CGAffineTransformMakeTranslation(0, -finalFrame.size.height);
animations = ^void {
[presentedView setFrame:finalFrame];
presentedView.transform = CGAffineTransformIdentity;
};
break;
}
}
// Set the frame for the presented view.
if (!CGRectIsEmpty(initialFrame)) {
[presentedView setFrame:initialFrame];
}
[presentedView layoutIfNeeded];
void (^completion)(BOOL) = ^void(BOOL finished) {
presentingView.transform = CGAffineTransformIdentity;
[transitionContext completeTransition:finished];
};
......
......@@ -720,6 +720,15 @@
self.buttonUpdater.forwardButton = self.forwardButton;
self.buttonUpdater.voiceSearchButton = self.voiceSearchButton;
for (NSLayoutConstraint* constraint in buttonConstraints) {
// The buttons are added to a UIStackView. If the priority is
// |UILayoutPriorityRequired|, there is a conflict when the buttons are
// hidden as the stack view is setting their width to 0. Setting the
// priority to UILayoutPriorityDefaultHigh doesn't work as they would have a
// lower priority than the location bar which would expand.
constraint.priority = UILayoutPriorityRequired - 1;
}
[NSLayoutConstraint activateConstraints:buttonConstraints];
}
......@@ -752,9 +761,13 @@
ToolbarComponentVisibilityRegularWidth;
self.locationBarLeadingButton.alpha = 0;
self.locationBarLeadingButton.hidden = YES;
[self.locationBarLeadingButton.widthAnchor
constraintEqualToConstant:kLeadingLocationBarButtonWidth]
.active = YES;
NSLayoutConstraint* width = [self.locationBarLeadingButton.widthAnchor
constraintEqualToConstant:kLeadingLocationBarButtonWidth];
// The button is added to a UIStackView. If the priority is
// |UILayoutPriorityRequired|, there is a conflict when the button is hidden
// as the stack view is setting the width to 0.
width.priority = UILayoutPriorityRequired - 1;
width.active = YES;
self.locationBarLeadingButton.imageEdgeInsets =
UIEdgeInsetsMakeDirected(0, kLeadingLocationBarButtonImageInset, 0, 0);
}
......
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