Commit 47cc27a9 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Changes History presentation to UIModalPresentationFormSheet on iOS13.

Screenshots:
iPhoneX Portrait:
https://drive.google.com/open?id=1EuSPpb_-7yGjbxSaz5bOkWWWKmq74zq8
iPhoneX Landscape:
https://drive.google.com/open?id=1sfpAppZAvrMp3k20527vxXbu7WG8ZiPi
iPadPro Portrait:
https://drive.google.com/open?id=1EuL2t9yWlU4IpIERGMHxxlYBYKoLYA5M
iPadPro Landscape:
https://drive.google.com/open?id=1nBDidl8oYXjrx9_NOtF-trfts_0x7Ea5
iPadPro Portrait DynamicType:
https://drive.google.com/open?id=1k5pwO0agJ5uf-pmOVeFf4frmHOR25W8W

Bug: 979201
Change-Id: I97a59a5ac32f9f45a091f32fe73e90d8cfd8ec61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1709650Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686527}
parent 475d0bb6
...@@ -27,6 +27,7 @@ source_set("history") { ...@@ -27,6 +27,7 @@ source_set("history") {
"//ios/chrome/browser/ui/context_menu", "//ios/chrome/browser/ui/context_menu",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:feature_flags",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
] ]
libs = [ libs = [
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "ios/chrome/browser/ui/history/history_table_view_controller.h" #include "ios/chrome/browser/ui/history/history_table_view_controller.h"
#import "ios/chrome/browser/ui/history/history_transitioning_delegate.h" #import "ios/chrome/browser/ui/history/history_transitioning_delegate.h"
#include "ios/chrome/browser/ui/history/ios_browsing_history_driver.h" #include "ios/chrome/browser/ui/history/ios_browsing_history_driver.h"
#import "ios/chrome/browser/ui/table_view/feature_flags.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h" #import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
...@@ -86,12 +87,28 @@ ...@@ -86,12 +87,28 @@
self.historyTableViewController.localDispatcher = self; self.historyTableViewController.localDispatcher = self;
self.historyTableViewController.presentationDelegate = self.historyTableViewController.presentationDelegate =
self.presentationDelegate; self.presentationDelegate;
self.historyTransitioningDelegate =
[[HistoryTransitioningDelegate alloc] init]; BOOL useCustomPresentation = YES;
self.historyNavigationController.transitioningDelegate = if (IsCollectionsCardPresentationStyleEnabled()) {
self.historyTransitioningDelegate; if (@available(iOS 13, *)) {
[self.historyNavigationController #if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
setModalPresentationStyle:UIModalPresentationCustom]; [self.historyNavigationController
setModalPresentationStyle:UIModalPresentationFormSheet];
self.historyNavigationController.presentationController.delegate =
self.historyTableViewController;
useCustomPresentation = NO;
#endif
}
}
if (useCustomPresentation) {
self.historyTransitioningDelegate =
[[HistoryTransitioningDelegate alloc] init];
self.historyNavigationController.transitioningDelegate =
self.historyTransitioningDelegate;
[self.historyNavigationController
setModalPresentationStyle:UIModalPresentationCustom];
}
[self.baseViewController [self.baseViewController
presentViewController:self.historyNavigationController presentViewController:self.historyNavigationController
animated:YES animated:YES
......
...@@ -22,7 +22,8 @@ enum class UrlLoadStrategy; ...@@ -22,7 +22,8 @@ enum class UrlLoadStrategy;
// ChromeTableViewController for displaying history items. // ChromeTableViewController for displaying history items.
@interface HistoryTableViewController @interface HistoryTableViewController
: ChromeTableViewController<HistoryConsumer> : ChromeTableViewController <HistoryConsumer,
UIAdaptivePresentationControllerDelegate>
// The ViewController's BrowserState. // The ViewController's BrowserState.
@property(nonatomic, assign) ios::ChromeBrowserState* browserState; @property(nonatomic, assign) ios::ChromeBrowserState* browserState;
// Abstraction to communicate with HistoryService and WebHistoryService. // Abstraction to communicate with HistoryService and WebHistoryService.
......
...@@ -167,6 +167,7 @@ const CGFloat kButtonHorizontalPadding = 30.0; ...@@ -167,6 +167,7 @@ const CGFloat kButtonHorizontalPadding = 30.0;
// Add a tableFooterView in order to disable separators at the bottom of the // Add a tableFooterView in order to disable separators at the bottom of the
// tableView. // tableView.
self.tableView.tableFooterView = [[UIView alloc] init]; self.tableView.tableFooterView = [[UIView alloc] init];
self.tableView.accessibilityIdentifier = kHistoryTableViewIdentifier;
// ContextMenu gesture recognizer. // ContextMenu gesture recognizer.
UILongPressGestureRecognizer* longPressRecognizer = [ UILongPressGestureRecognizer* longPressRecognizer = [
...@@ -475,6 +476,24 @@ const CGFloat kButtonHorizontalPadding = 30.0; ...@@ -475,6 +476,24 @@ const CGFloat kButtonHorizontalPadding = 30.0;
[self updateEntriesStatusMessage]; [self updateEntriesStatusMessage];
} }
#pragma mark UIAdaptivePresentationControllerDelegate
- (void)presentationControllerWillDismiss:
(UIPresentationController*)presentationController {
if (self.searchInProgress) {
// Dismiss the keyboard if trying to dismiss the VC so the keyboard doesn't
// linger until the VC dismissal has completed.
[self.searchController.searchBar endEditing:YES];
}
}
- (void)presentationControllerDidDismiss:
(UIPresentationController*)presentationController {
// Call the localDispatcher dismissHistoryWithCompletion to clean up state and
// stop the Coordinator.
[self.localDispatcher dismissHistoryWithCompletion:nil];
}
#pragma mark - History Data Updates #pragma mark - History Data Updates
// Search history for text |query| and display the results. |query| may be nil. // Search history for text |query| and display the results. |query| may be nil.
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
// Accessibility identifier for the History TableView.
extern NSString* const kHistoryTableViewIdentifier;
// Accessibility identifier of the search controller search bar. // Accessibility identifier of the search controller search bar.
extern NSString* const kHistorySearchControllerSearchBarIdentifier; extern NSString* const kHistorySearchControllerSearchBarIdentifier;
// Accessibility identifier of the navigation controller done button. // Accessibility identifier of the navigation controller done button.
...@@ -19,7 +21,7 @@ extern NSString* const kHistoryToolbarClearBrowsingButtonIdentifier; ...@@ -19,7 +21,7 @@ extern NSString* const kHistoryToolbarClearBrowsingButtonIdentifier;
extern NSString* const kHistoryToolbarEditButtonIdentifier; extern NSString* const kHistoryToolbarEditButtonIdentifier;
// Accessibility identifier of the cancel toolbar button. // Accessibility identifier of the cancel toolbar button.
extern NSString* const kHistoryToolbarCancelButtonIdentifier; extern NSString* const kHistoryToolbarCancelButtonIdentifier;
// Accessibility ID for the scrim over TableView. // Accessibility identifier for the scrim over TableView.
extern NSString* const kHistorySearchScrimIdentifier; extern NSString* const kHistorySearchScrimIdentifier;
#endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_UI_CONSTANTS_H_ #endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_UI_CONSTANTS_H_
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
NSString* const kHistoryTableViewIdentifier = @"kHistoryTableViewIdentifier";
NSString* const kHistorySearchControllerSearchBarIdentifier = NSString* const kHistorySearchControllerSearchBarIdentifier =
@"kHistorySearchControllerSearchBarIdentifier"; @"kHistorySearchControllerSearchBarIdentifier";
NSString* const kHistoryNavigationControllerDoneButtonIdentifier = NSString* const kHistoryNavigationControllerDoneButtonIdentifier =
......
...@@ -404,6 +404,62 @@ id<GREYMatcher> OpenInNewIncognitoTabButton() { ...@@ -404,6 +404,62 @@ id<GREYMatcher> OpenInNewIncognitoTabButton() {
_URL1.spec().c_str()); _URL1.spec().c_str());
} }
// Tests that the VC can be dismissed by swiping down.
- (void)testSwipeDownDismiss {
if (!base::ios::IsRunningOnOrLater(13, 0, 0)) {
EARL_GREY_TEST_SKIPPED(@"Test disabled on iOS 12 and lower.");
}
[self loadTestURLs];
[self openHistoryPanel];
// Check that the TableView is presented.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kHistoryTableViewIdentifier)]
assertWithMatcher:grey_notNil()];
// Swipe TableView down.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kHistoryTableViewIdentifier)]
performAction:grey_swipeFastInDirection(kGREYDirectionDown)];
// Check that the TableView has been dismissed.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kHistoryTableViewIdentifier)]
assertWithMatcher:grey_nil()];
}
// Tests that the VC can be dismissed by swiping down while its searching.
- (void)testSwipeDownDismissWhileSearching {
if (!base::ios::IsRunningOnOrLater(13, 0, 0)) {
EARL_GREY_TEST_SKIPPED(@"Test disabled on iOS 12 and lower.");
}
[self loadTestURLs];
[self openHistoryPanel];
// Check that the TableView is presented.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kHistoryTableViewIdentifier)]
assertWithMatcher:grey_notNil()];
// Search for the first URL.
[[EarlGrey selectElementWithMatcher:SearchIconButton()]
performAction:grey_tap()];
NSString* searchString =
[NSString stringWithFormat:@"%s", _URL1.path().c_str()];
[[EarlGrey selectElementWithMatcher:SearchIconButton()]
performAction:grey_typeText(searchString)];
// Swipe TableView down.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kHistoryTableViewIdentifier)]
performAction:grey_swipeFastInDirection(kGREYDirectionDown)];
// Check that the TableView has been dismissed.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kHistoryTableViewIdentifier)]
assertWithMatcher:grey_nil()];
}
// Navigates to history and checks elements for accessibility. // Navigates to history and checks elements for accessibility.
- (void)testAccessibilityOnHistory { - (void)testAccessibilityOnHistory {
[self loadTestURLs]; [self loadTestURLs];
......
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