Commit 59dfb241 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Exit fullscreen when tapping the collapsed toolbar

This CL makes sure that it is possible to exit fullscreen by tapping the
collapsed toolbar.
For now, it is possible to exit it by tapping the steady view.

Bug: 862557
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I31667dd679d1b38f41d819197aedc54c76024ab4
Reviewed-on: https://chromium-review.googlesource.com/1184912Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585010}
parent 0b6f9c31
...@@ -264,16 +264,7 @@ const int kLocationAuthorizationStatusCount = 4; ...@@ -264,16 +264,7 @@ const int kLocationAuthorizationStatusCount = 4;
#pragma mark - LocationBarViewControllerDelegate #pragma mark - LocationBarViewControllerDelegate
- (void)locationBarSteadyViewTapped { - (void)locationBarSteadyViewTapped {
FullscreenController* fullscreenController = [self focusOmnibox];
FullscreenControllerFactory::GetInstance()->GetForBrowserState(
_browserState);
if (fullscreenController->GetProgress() < 1) {
// The first tap should exit fullscreen.
fullscreenController->ResetModel();
} else {
// The toolbar is fully visible, focus the omnibox.
[self focusOmnibox];
}
} }
- (void)locationBarCopyTapped { - (void)locationBarCopyTapped {
......
...@@ -155,6 +155,12 @@ ...@@ -155,6 +155,12 @@
animated:NO]; animated:NO];
} }
- (void)exitFullscreen {
FullscreenControllerFactory::GetInstance()
->GetForBrowserState(self.browserState)
->ResetModel();
}
#pragma mark - FakeboxFocuser #pragma mark - FakeboxFocuser
- (void)focusFakebox { - (void)focusFakebox {
......
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
// Button to cancel the edit of the location bar. // Button to cancel the edit of the location bar.
@property(nonatomic, strong, readonly) UIButton* cancelButton; @property(nonatomic, strong, readonly) UIButton* cancelButton;
// Button taking the full size of the toolbar. Expands the toolbar when tapped.
@property(nonatomic, strong, readonly) UIButton* collapsedToolbarButton;
// Constraints to be activated when the location bar is expanded and positioned // Constraints to be activated when the location bar is expanded and positioned
// relatively to the cancel button. // relatively to the cancel button.
@property(nonatomic, strong, readonly) @property(nonatomic, strong, readonly)
......
...@@ -76,6 +76,9 @@ ...@@ -76,6 +76,9 @@
// Button to cancel the edit of the location bar, redefined as readwrite. // Button to cancel the edit of the location bar, redefined as readwrite.
@property(nonatomic, strong, readwrite) UIButton* cancelButton; @property(nonatomic, strong, readwrite) UIButton* cancelButton;
// Button taking the full size of the toolbar. Expands the toolbar when tapped.
// Redefined as readwrite.
@property(nonatomic, strong, readwrite) UIButton* collapsedToolbarButton;
// Constraints for the location bar, redefined as readwrite. // Constraints for the location bar, redefined as readwrite.
@property(nonatomic, strong, readwrite) @property(nonatomic, strong, readwrite)
...@@ -112,6 +115,7 @@ ...@@ -112,6 +115,7 @@
@synthesize bookmarkButton = _bookmarkButton; @synthesize bookmarkButton = _bookmarkButton;
@synthesize toolsMenuButton = _toolsMenuButton; @synthesize toolsMenuButton = _toolsMenuButton;
@synthesize cancelButton = _cancelButton; @synthesize cancelButton = _cancelButton;
@synthesize collapsedToolbarButton = _collapsedToolbarButton;
@synthesize expandedConstraints = _expandedConstraints; @synthesize expandedConstraints = _expandedConstraints;
@synthesize contractedConstraints = _contractedConstraints; @synthesize contractedConstraints = _contractedConstraints;
@synthesize contractedNoMarginConstraints = _contractedNoMarginConstraints; @synthesize contractedNoMarginConstraints = _contractedNoMarginConstraints;
...@@ -143,6 +147,7 @@ ...@@ -143,6 +147,7 @@
[self setUpCancelButton]; [self setUpCancelButton];
[self setUpLocationBar]; [self setUpLocationBar];
[self setUpProgressBar]; [self setUpProgressBar];
[self setUpCollapsedToolbarButton];
[self setUpConstraints]; [self setUpConstraints];
} }
...@@ -291,6 +296,14 @@ ...@@ -291,6 +296,14 @@
[self addSubview:self.progressBar]; [self addSubview:self.progressBar];
} }
// Sets the collapsedToolbarButton up.
- (void)setUpCollapsedToolbarButton {
self.collapsedToolbarButton = [[UIButton alloc] init];
self.collapsedToolbarButton.translatesAutoresizingMaskIntoConstraints = NO;
self.collapsedToolbarButton.hidden = YES;
[self addSubview:self.collapsedToolbarButton];
}
// Sets the constraints up. // Sets the constraints up.
- (void)setUpConstraints { - (void)setUpConstraints {
id<LayoutGuideProvider> safeArea = SafeAreaLayoutGuideForView(self); id<LayoutGuideProvider> safeArea = SafeAreaLayoutGuideForView(self);
...@@ -408,6 +421,9 @@ ...@@ -408,6 +421,9 @@
[self.progressBar.heightAnchor [self.progressBar.heightAnchor
constraintEqualToConstant:kProgressBarHeight], constraintEqualToConstant:kProgressBarHeight],
]]; ]];
// CollapsedToolbarButton constraints.
AddSameConstraints(self, self.collapsedToolbarButton);
} }
#pragma mark - Property accessors #pragma mark - Property accessors
......
...@@ -102,6 +102,10 @@ ...@@ -102,6 +102,10 @@
// set to topLayoutGuide after the view creation on iOS 10. // set to topLayoutGuide after the view creation on iOS 10.
[self.view setUp]; [self.view setUp];
[self.view.collapsedToolbarButton addTarget:self
action:@selector(exitFullscreen)
forControlEvents:UIControlEventTouchUpInside];
if (IsCompactHeight(self)) { if (IsCompactHeight(self)) {
self.view.locationBarExtraBottomPadding.constant = self.view.locationBarExtraBottomPadding.constant =
kAdaptiveLocationBarExtraVerticalMargin; kAdaptiveLocationBarExtraVerticalMargin;
...@@ -172,6 +176,8 @@ ...@@ -172,6 +176,8 @@
[self.buttonFactory.toolbarConfiguration [self.buttonFactory.toolbarConfiguration
locationBarBackgroundColorWithVisibility:alphaValue]; locationBarBackgroundColorWithVisibility:alphaValue];
self.previousFullscreenProgress = progress; self.previousFullscreenProgress = progress;
self.view.collapsedToolbarButton.hidden = progress > 0.05;
} }
- (void)updateForFullscreenEnabled:(BOOL)enabled { - (void)updateForFullscreenEnabled:(BOOL)enabled {
...@@ -262,4 +268,9 @@ ...@@ -262,4 +268,9 @@
[NSLayoutConstraint deactivateConstraints:self.view.expandedConstraints]; [NSLayoutConstraint deactivateConstraints:self.view.expandedConstraints];
} }
// Exits fullscreen.
- (void)exitFullscreen {
[self.delegate exitFullscreen];
}
@end @end
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
- (void)viewControllerTraitCollectionDidChange: - (void)viewControllerTraitCollectionDidChange:
(UITraitCollection*)previousTraitCollection; (UITraitCollection*)previousTraitCollection;
// Exits fullscreen.
- (void)exitFullscreen;
@end @end
#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_ADAPTIVE_PRIMARY_TOOLBAR_VIEW_CONTROLLER_DELEGATE_H_ #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_ADAPTIVE_PRIMARY_TOOLBAR_VIEW_CONTROLLER_DELEGATE_H_
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