Commit 17471a72 authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Use the TableViewPresentationController for History.

BUG=805154
TEST=None

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Iaa70b4edc0e0cf69ad8d2fa00be867d56ccc7625
Reviewed-on: https://chromium-review.googlesource.com/1012164
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550708}
parent 2ec363c2
......@@ -103,6 +103,8 @@ source_set("history_ui") {
"history_table_view_controller.h",
"history_table_view_controller.mm",
"history_table_view_controller_delegate.h",
"history_transitioning_delegate.h",
"history_transitioning_delegate.mm",
"history_util.h",
"history_util.mm",
]
......@@ -123,6 +125,7 @@ source_set("history_ui") {
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/list_model",
"//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:presentation",
"//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells",
"//ui/base",
......
......@@ -14,6 +14,7 @@
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#import "ios/chrome/browser/ui/history/history_table_container_view_controller.h"
#include "ios/chrome/browser/ui/history/history_table_view_controller.h"
#import "ios/chrome/browser/ui/history/history_transitioning_delegate.h"
#include "ios/chrome/browser/ui/history/ios_browsing_history_driver.h"
#import "ios/chrome/browser/ui/util/form_sheet_navigation_controller.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -31,11 +32,16 @@
// ViewController being managed by this Coordinator.
@property(nonatomic, strong)
HistoryTableContainerViewController* historyContainerViewController;
// The transitioning delegate used by the history view controller.
@property(nonatomic, strong)
HistoryTransitioningDelegate* historyTransitioningDelegate;
@end
@implementation HistoryCoordinator
@synthesize dispatcher = _dispatcher;
@synthesize historyContainerViewController = _historyContainerViewController;
@synthesize historyTransitioningDelegate = _historyTransitioningDelegate;
@synthesize loader = _loader;
- (void)start {
......@@ -75,7 +81,13 @@
FormSheetNavigationController* navController =
[[FormSheetNavigationController alloc]
initWithRootViewController:self.historyContainerViewController];
[navController setModalPresentationStyle:UIModalPresentationFormSheet];
self.historyTransitioningDelegate =
[[HistoryTransitioningDelegate alloc] init];
[navController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
navController.navigationBar.translucent = NO;
navController.transitioningDelegate = self.historyTransitioningDelegate;
[navController setModalPresentationStyle:UIModalPresentationCustom];
[self.baseViewController presentViewController:navController
animated:YES
completion:nil];
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_TRANSITIONING_DELEGATE_H_
#define IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_TRANSITIONING_DELEGATE_H_
#import <UIKit/UIKit.h>
@interface HistoryTransitioningDelegate
: NSObject<UIViewControllerTransitioningDelegate>
@end
#endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_TRANSITIONING_DELEGATE_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/history/history_transitioning_delegate.h"
#import "ios/chrome/browser/ui/table_view/table_view_animator.h"
#import "ios/chrome/browser/ui/table_view/table_view_presentation_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation HistoryTransitioningDelegate
- (UIPresentationController*)
presentationControllerForPresentedViewController:(UIViewController*)presented
presentingViewController:(UIViewController*)presenting
sourceViewController:(UIViewController*)source {
return [[TableViewPresentationController alloc]
initWithPresentedViewController:presented
presentingViewController:presenting];
}
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForPresentedController:(UIViewController*)presented
presentingController:(UIViewController*)presenting
sourceController:(UIViewController*)source {
UITraitCollection* traitCollection = presenting.traitCollection;
if (traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact &&
traitCollection.verticalSizeClass != UIUserInterfaceSizeClassCompact) {
// Use the default animator for fullscreen presentations.
return nil;
}
TableViewAnimator* animator = [[TableViewAnimator alloc] init];
animator.presenting = YES;
return animator;
}
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForDismissedController:(UIViewController*)dismissed {
UITraitCollection* traitCollection = dismissed.traitCollection;
if (traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact &&
traitCollection.verticalSizeClass != UIUserInterfaceSizeClassCompact) {
// Use the default animator for fullscreen presentations.
return nil;
}
TableViewAnimator* animator = [[TableViewAnimator alloc] init];
animator.presenting = NO;
return animator;
}
@end
......@@ -71,6 +71,10 @@ const CGFloat kTableViewMaxWidth = 414.0;
CGFloat maxAvailableWidth = containerWidth - 2 * kTableViewEdgeMargin;
CGFloat tableWidth = std::min(maxAvailableWidth, kTableViewMaxWidth);
if (@available(iOS 11, *)) {
NSLog(@"%@", NSStringFromUIEdgeInsets(self.containerView.safeAreaInsets));
}
LayoutRect tableLayoutRect = LayoutRectMake(
containerWidth - tableWidth - kTableViewEdgeMargin, containerWidth,
kTableViewTopMargin, tableWidth,
......@@ -185,7 +189,7 @@ const CGFloat kTableViewMaxWidth = 414.0;
#pragma mark - Adaptivity
- (UIModalPresentationStyle)adaptivePresentationStyleForTraitCollection:
- (UIModalPresentationStyle)XXadaptivePresentationStyleForTraitCollection:
(UITraitCollection*)traitCollection {
if (traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact &&
traitCollection.verticalSizeClass != UIUserInterfaceSizeClassCompact) {
......
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