Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: ios/chrome/browser/ui/uikit_ui_util.mm

Issue 1329713002: Add convenience methods for checking horizontal size class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/uikit_ui_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/uikit_ui_util.h" 5 #import "ios/chrome/browser/ui/uikit_ui_util.h"
6 6
7 #import <Accelerate/Accelerate.h> 7 #import <Accelerate/Accelerate.h>
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 #import <QuartzCore/QuartzCore.h> 9 #import <QuartzCore/QuartzCore.h>
10 #import <UIKit/UIKit.h> 10 #import <UIKit/UIKit.h>
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 [parentView addConstraint:[NSLayoutConstraint 510 [parentView addConstraint:[NSLayoutConstraint
511 constraintWithItem:subview1 511 constraintWithItem:subview1
512 attribute:NSLayoutAttributeCenterY 512 attribute:NSLayoutAttributeCenterY
513 relatedBy:NSLayoutRelationEqual 513 relatedBy:NSLayoutRelationEqual
514 toItem:subview2 514 toItem:subview2
515 attribute:NSLayoutAttributeCenterY 515 attribute:NSLayoutAttributeCenterY
516 multiplier:1 516 multiplier:1
517 constant:0]]; 517 constant:0]];
518 } 518 }
519 519
520 bool IsCompact() { 520 bool IsCompact(id<UITraitEnvironment> environment) {
521 if (base::ios::IsRunningOnIOS8OrLater()) { 521 if (base::ios::IsRunningOnIOS8OrLater()) {
522 UIWindow* keyWindow = [UIApplication sharedApplication].keyWindow; 522 return environment.traitCollection.horizontalSizeClass ==
523 return [keyWindow.traitCollection horizontalSizeClass] ==
524 UIUserInterfaceSizeClassCompact; 523 UIUserInterfaceSizeClassCompact;
525 } else { 524 } else {
526 // Prior to iOS 8, iPad is always regular, iPhone is always compact. 525 // Prior to iOS 8, iPad is always regular, iPhone is always compact.
527 return !IsIPadIdiom(); 526 return !IsIPadIdiom();
528 } 527 }
529 } 528 }
530 529
530 bool IsCompact() {
531 UIWindow* keyWindow = [UIApplication sharedApplication].keyWindow;
532 return IsCompact(keyWindow);
533 }
534
535 bool IsCompactTablet(id<UITraitEnvironment> environment) {
536 return IsIPadIdiom() && IsCompact(environment);
537 }
538
531 bool IsCompactTablet() { 539 bool IsCompactTablet() {
532 return IsIPadIdiom() && IsCompact(); 540 return IsIPadIdiom() && IsCompact();
533 } 541 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/uikit_ui_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698