Commit 9e2c6d5c authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Add a named guide for the BVC content area.

Adds a named guide to the content area so it can be positionally matched by transitions.

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ifcb0d873d88cf0af2b9f898a8d9e151b601504da
Reviewed-on: https://chromium-review.googlesource.com/1118169
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571527}
parent 27b0225c
......@@ -1609,7 +1609,6 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
#pragma mark - UIViewController
// Perform additional set up after loading the view, typically from a nib.
- (void)viewDidLoad {
CGRect initialViewsRect = self.view.bounds;
if (!self.usesFullscreenContainer) {
......@@ -2403,6 +2402,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
aboveSubview:self.primaryToolbarCoordinator.viewController.view];
}
NSArray<GuideName*>* guideNames = @[
kContentAreaGuide,
kOmniboxGuide,
kBackButtonGuide,
kForwardButtonGuide,
......@@ -2413,6 +2413,33 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
kVoiceSearchButtonGuide,
];
AddNamedGuidesToView(guideNames, self.view);
// Configure the content area guide.
NamedGuide* contentAreaGuide =
[NamedGuide guideWithName:kContentAreaGuide view:self.view];
// Constrain top to bottom of top toolbar.
UIView* primaryToolbarView =
self.primaryToolbarCoordinator.viewController.view;
[contentAreaGuide.topAnchor
constraintEqualToAnchor:primaryToolbarView.bottomAnchor]
.active = YES;
LayoutSides contentSides = LayoutSides::kLeading | LayoutSides::kTrailing;
if (self.secondaryToolbarCoordinator) {
// If there's a bottom toolbar, the content area guide is constrained to
// its top.
UIView* secondaryToolbarView =
self.secondaryToolbarCoordinator.viewController.view;
[contentAreaGuide.bottomAnchor
constraintEqualToAnchor:secondaryToolbarView.topAnchor]
.active = YES;
} else {
// Otherwise, the content area guide is constrained to self.view's bootom
// along with its sides;
contentSides = contentSides | LayoutSides::kBottom;
}
AddSameConstraintsToSides(self.view, contentAreaGuide, contentSides);
}
if (initialLayout) {
[self.primaryToolbarCoordinator.viewController
......
......@@ -12,6 +12,8 @@ typedef NSString GuideName;
// The list of well-known UILayoutGuides. When adding a new guide to the app,
// create a constant for it below.
// A guide that is constrained to match the frame of the tab's content area.
extern GuideName* const kContentAreaGuide;
// A guide that is constrained to match the frame of the secondary toolbar.
extern GuideName* const kSecondaryToolbar;
// A guide that is constrained to match the frame the secondary toolbar would
......
......@@ -8,6 +8,7 @@
#error "This file requires ARC support."
#endif
GuideName* const kContentAreaGuide = @"ContentAreaGuide";
GuideName* const kSecondaryToolbar = @"kSecondaryToolbar";
GuideName* const kSecondaryToolbarNoFullscreen =
@"kSecondaryToolbarNoFullscreen";
......
......@@ -7,7 +7,7 @@
#import "ios/chrome/browser/ui/util/layout_guide_names.h"
// Adds NamedGuides with the GuideNames in |names| to |view|.
// Creates NamedGuides with the GuideNames in |names| and adds them to |view|.
void AddNamedGuidesToView(NSArray<GuideName*>* names, UIView* view);
// Sets the constrained views for the NamedGuides indicated by the keys of
......
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