Commit f4d4f30b authored by sczs's avatar sczs Committed by Commit Bot

[ios] Changes ToolbarButtons to a stable state after animations

Since loading pages hides ToolbarButtons, this CL makes sure hidden buttons are updated correctly
after the expanding/contracting animations.

Bug: 794246
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I633e18bd0899fd6d9586e4136719ea39279c35bc
Reviewed-on: https://chromium-review.googlesource.com/823228Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523789}
parent 99e2d691
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
-kToolbarButtonAnimationOffset -kToolbarButtonAnimationOffset
forButtons: forButtons:
self.trailingStackViewButtons]; self.trailingStackViewButtons];
[self setAllVisibleToolbarButtonsOpacity:0]; [self setAllToolbarButtonsOpacity:0];
} }
completion:nil]; completion:nil];
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
[NSLayoutConstraint activateConstraints:self.regularToolbarConstraints]; [NSLayoutConstraint activateConstraints:self.regularToolbarConstraints];
// Change the Toolbar buttons opacity to 0 since these will fade in once the // Change the Toolbar buttons opacity to 0 since these will fade in once the
// locationBarContainer has been contracted. // locationBarContainer has been contracted.
[self setAllVisibleToolbarButtonsOpacity:0]; [self setAllToolbarButtonsOpacity:0];
[animator addAnimations:^{ [animator addAnimations:^{
self.locationBarContainer.layer.borderWidth = kLocationBarBorderWidth; self.locationBarContainer.layer.borderWidth = kLocationBarBorderWidth;
[self.view layoutIfNeeded]; [self.view layoutIfNeeded];
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
setHorizontalTranslationOffset:0 setHorizontalTranslationOffset:0
forButtons: forButtons:
self.trailingStackViewButtons]; self.trailingStackViewButtons];
[self setAllVisibleToolbarButtonsOpacity:1]; [self setAllToolbarButtonsOpacity:1];
} }
completion:nil]; completion:nil];
}]; }];
...@@ -999,22 +999,21 @@ ...@@ -999,22 +999,21 @@
[self.dispatcher startVoiceSearch:command]; [self.dispatcher startVoiceSearch:command];
} }
// Sets all Visible Toolbar Buttons opacity to |alpha|. // Sets all Toolbar Buttons opacity to |alpha|.
- (void)setAllVisibleToolbarButtonsOpacity:(CGFloat)alpha { - (void)setAllToolbarButtonsOpacity:(CGFloat)alpha {
for (UIButton* button in [self.leadingStackViewButtons for (UIButton* button in [self.leadingStackViewButtons
arrayByAddingObjectsFromArray:self.trailingStackViewButtons]) { arrayByAddingObjectsFromArray:self.trailingStackViewButtons]) {
if (!button.hidden)
button.alpha = alpha; button.alpha = alpha;
} }
} }
// Offsets the horizontal translation transform of all visible Toolbar Buttons // Offsets the horizontal translation transform of all visible Toolbar Buttons
// in |array| by |offset|. Used for fade in animations. // in |array| by |offset|. If the button is hidden it will assign the
// IdentityTransform. Used for fade in animations.
- (void)setHorizontalTranslationOffset:(LayoutOffset)offset - (void)setHorizontalTranslationOffset:(LayoutOffset)offset
forButtons:(NSArray<ToolbarButton*>*)array { forButtons:(NSArray<ToolbarButton*>*)array {
for (UIButton* button in array) { for (UIButton* button in array) {
if (!button.hidden) button.transform = (offset != 0 && !button.hidden)
button.transform = (offset != 0)
? CGAffineTransformMakeTranslation(offset, 0) ? CGAffineTransformMakeTranslation(offset, 0)
: CGAffineTransformIdentity; : CGAffineTransformIdentity;
} }
......
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