Skip to content

Commit

Permalink
Change bubble arrow direction based on toolbar state
Browse files Browse the repository at this point in the history
This CL changes the direction of the arrow pointing from the bubble
tip to its anchor based on the toolbar mode (split or unsplit) when
the UI Refresh is enabled.

Bug: 804760
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I8de0cb833004c646fd7578d6421aa4dbe0810c0f
Reviewed-on: https://chromium-review.googlesource.com/1015022
Reviewed-by: edchin <edchin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555334}
  • Loading branch information
Gauthier Ambard authored and Commit Bot committed May 2, 2018
1 parent 2917a61 commit 1dc3331
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ios/chrome/browser/ui/browser_view_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2689,18 +2689,22 @@ - (void)presentNewTabTipBubble {
if (![self isTabScrolledToTop:currentTab])
return;

BubbleArrowDirection arrowDirection =
(IsUIRefreshPhase1Enabled() && IsSplitToolbarMode())
? BubbleArrowDirectionDown
: BubbleArrowDirectionUp;
NSString* text =
l10n_util::GetNSStringWithFixup(IDS_IOS_NEW_TAB_IPH_PROMOTION_TEXT);
CGPoint tabSwitcherAnchor;
if (IsIPadIdiom()) {
tabSwitcherAnchor = [self.tabStripCoordinator
anchorPointForTabSwitcherButton:BubbleArrowDirectionUp];
anchorPointForTabSwitcherButton:arrowDirection];
} else {
UILayoutGuide* guide =
[NamedGuide guideWithName:kTabSwitcherGuide view:self.view];
DCHECK(guide);
CGPoint anchorPoint =
bubble_util::AnchorPoint(guide.layoutFrame, BubbleArrowDirectionUp);
bubble_util::AnchorPoint(guide.layoutFrame, arrowDirection);
tabSwitcherAnchor = [guide.owningView convertPoint:anchorPoint
toView:guide.owningView.window];
}
Expand All @@ -2710,7 +2714,7 @@ - (void)presentNewTabTipBubble {
// of the existing |tabTipBubblePresenter| to nil.
BubbleViewControllerPresenter* presenter =
[self bubblePresenterForFeature:feature_engagement::kIPHNewTabTipFeature
direction:BubbleArrowDirectionUp
direction:arrowDirection
alignment:BubbleAlignmentTrailing
text:text];
if (!presenter)
Expand Down Expand Up @@ -2756,14 +2760,18 @@ - (void)presentNewIncognitoTabTipBubble {
if (![self isTabScrolledToTop:currentTab])
return;

BubbleArrowDirection arrowDirection =
(IsUIRefreshPhase1Enabled() && IsSplitToolbarMode())
? BubbleArrowDirectionDown
: BubbleArrowDirectionUp;
NSString* text = l10n_util::GetNSStringWithFixup(
IDS_IOS_NEW_INCOGNITO_TAB_IPH_PROMOTION_TEXT);
CGPoint toolsButtonAnchor;
UILayoutGuide* guide =
[NamedGuide guideWithName:kToolsMenuGuide view:self.view];
DCHECK(guide);
CGPoint anchorPoint =
bubble_util::AnchorPoint(guide.layoutFrame, BubbleArrowDirectionUp);
bubble_util::AnchorPoint(guide.layoutFrame, arrowDirection);
toolsButtonAnchor = [guide.owningView convertPoint:anchorPoint
toView:guide.owningView.window];

Expand All @@ -2773,7 +2781,7 @@ - (void)presentNewIncognitoTabTipBubble {
BubbleViewControllerPresenter* presenter =
[self bubblePresenterForFeature:feature_engagement::
kIPHNewIncognitoTabTipFeature
direction:BubbleArrowDirectionUp
direction:arrowDirection
alignment:BubbleAlignmentTrailing
text:text];
if (!presenter)
Expand Down

0 comments on commit 1dc3331

Please sign in to comment.