Commit 7755d9ab authored by Roberto Moura's avatar Roberto Moura Committed by Commit Bot

Change ViewRevealingVerticalPanHandler's base view height when the user

rotates the screen.

Update the ViewRevealingVerticalPanHandler's base view height when the
BVC transitions to a different size. Keep track of whether the BVC is
positioned at the bottom of the screen and reposition it on rotation if
needed.

Bug: 1123729, 1127604
Change-Id: I8fb2ee0f531204ff3788845af8f32b515f101931
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414393Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Roberto Moura <mouraroberto@google.com>
Cr-Commit-Position: refs/heads/master@{#807822}
parent 3b429c6a
......@@ -493,6 +493,9 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// Whether BVC prefers to hide the status bar. This value is used to determine
// the response from the |prefersStatusBarHidden| method.
@property(nonatomic, assign) BOOL hideStatusBar;
// Whether the BVC is positioned at the bottom of the window, for example after
// switching from thumb strip to tab grid.
@property(nonatomic, assign) BOOL bottomPosition;
// Coordinator for displaying a modal overlay with activity indicator to prevent
// the user from interacting with the browser view.
@property(nonatomic, strong)
......@@ -1648,6 +1651,16 @@ NSString* const kBrowserViewControllerSnackbarCategory =
[strongSelf.tabStripCoordinator tabStripSizeDidChange];
}
}];
if (IsThumbStripEnabled()) {
CGFloat baseViewHeight = size.height;
self.thumbStripPanHandler.baseViewHeight = baseViewHeight;
// On rotation, reposition the BVC container if positioned at the bottom.
if (self.bottomPosition) {
self.view.superview.transform = CGAffineTransformMakeTranslation(
0, self.thumbStripPanHandler.revealedHeight);
}
}
}
- (void)dismissViewControllerAnimated:(BOOL)flag
......@@ -2778,6 +2791,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
- (void)didAnimateViewReveal:(ViewRevealState)viewRevealState {
self.tabStripView.hidden = (viewRevealState != ViewRevealState::Hidden);
[self.tabStripSnapshot removeFromSuperview];
self.bottomPosition = (viewRevealState == ViewRevealState::Revealed);
}
#pragma mark - BubblePresenterDelegate
......
......@@ -14,8 +14,6 @@
// TODO(crbug.com/1123512): Add support for going straight from a Hidden state
// to a revealed state (and vice-versa) if the gesture's translation and
// velocity are enough to trigger such transition.
// TODO(crbug.com/1123729): Change base view size when the user rotates the
// screen.
@interface ViewRevealingVerticalPanHandler : NSObject
// |peekedHeight| is the height of the view when peeked (partially revealed).
......@@ -41,6 +39,8 @@
@property(nonatomic, assign, readonly) CGFloat peekedHeight;
// Height of the revealed view after the transition to Revealed state.
@property(nonatomic, assign, readonly) CGFloat revealedHeight;
// Height of the base view. It changes when the user rotates the screen.
@property(nonatomic, assign) CGFloat baseViewHeight;
@end
......
......@@ -36,8 +36,6 @@ const CGFloat kAnimationDuration = 0.25f;
// Total distance between the Peeked state and Revealed state. Equal to
// |revealedHeight| - |peekedHeight|.
@property(nonatomic, assign, readonly) CGFloat remainingHeight;
// Height of the base view.
@property(nonatomic, assign, readonly) CGFloat baseViewHeight;
// Height of the cover view (the view in front of the view that will be
// revealed) that will still be visible after the remaining reveal transition.
@property(nonatomic, assign, readonly) CGFloat revealedCoverHeight;
......@@ -81,6 +79,12 @@ const CGFloat kAnimationDuration = 0.25f;
[self.animatees addObject:animatee];
}
- (void)setBaseViewHeight:(CGFloat)baseViewHeight {
_baseViewHeight = baseViewHeight;
_revealedHeight = baseViewHeight - _revealedCoverHeight;
_remainingHeight = _revealedHeight - _peekedHeight;
}
#pragma mark - Private Methods: Animating
// Called right before an animation block to warn all animatees of a transition
......
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