| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/authentication/signin_promo_item.h" | 5 #import "ios/chrome/browser/ui/authentication/signin_promo_item.h" |
| 6 | 6 |
| 7 #import "ios/chrome/browser/ui/authentication/signin_promo_view.h" | 7 #import "ios/chrome/browser/ui/authentication/signin_promo_view.h" |
| 8 #import "ios/chrome/browser/ui/authentication/signin_promo_view_configurator.h" | 8 #import "ios/chrome/browser/ui/authentication/signin_promo_view_configurator.h" |
| 9 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 9 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 10 #include "ios/chrome/grit/ios_chromium_strings.h" | 10 #include "ios/chrome/grit/ios_chromium_strings.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 @synthesize signinPromoView = _signinPromoView; | 42 @synthesize signinPromoView = _signinPromoView; |
| 43 | 43 |
| 44 - (instancetype)initWithFrame:(CGRect)frame { | 44 - (instancetype)initWithFrame:(CGRect)frame { |
| 45 self = [super initWithFrame:frame]; | 45 self = [super initWithFrame:frame]; |
| 46 if (self) { | 46 if (self) { |
| 47 UIView* contentView = self.contentView; | 47 UIView* contentView = self.contentView; |
| 48 _signinPromoView = [[SigninPromoView alloc] initWithFrame:self.bounds]; | 48 _signinPromoView = [[SigninPromoView alloc] initWithFrame:self.bounds]; |
| 49 _signinPromoView.translatesAutoresizingMaskIntoConstraints = NO; | 49 _signinPromoView.translatesAutoresizingMaskIntoConstraints = NO; |
| 50 [contentView addSubview:_signinPromoView]; | 50 [contentView addSubview:_signinPromoView]; |
| 51 AddSameSizeConstraint(_signinPromoView, contentView); | 51 AddSameConstraints(_signinPromoView, contentView); |
| 52 } | 52 } |
| 53 return self; | 53 return self; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Implements -layoutSubviews as per instructions in documentation for | 56 // Implements -layoutSubviews as per instructions in documentation for |
| 57 // +[MDCCollectionViewCell cr_preferredHeightForWidth:forItem:]. | 57 // +[MDCCollectionViewCell cr_preferredHeightForWidth:forItem:]. |
| 58 - (void)layoutSubviews { | 58 - (void)layoutSubviews { |
| 59 [super layoutSubviews]; | 59 [super layoutSubviews]; |
| 60 | 60 |
| 61 // Adjust the text label preferredMaxLayoutWidth when the parent's width | 61 // Adjust the text label preferredMaxLayoutWidth when the parent's width |
| 62 // changes, for instance on screen rotation. | 62 // changes, for instance on screen rotation. |
| 63 CGFloat parentWidth = CGRectGetWidth(self.bounds); | 63 CGFloat parentWidth = CGRectGetWidth(self.bounds); |
| 64 _signinPromoView.textLabel.preferredMaxLayoutWidth = | 64 _signinPromoView.textLabel.preferredMaxLayoutWidth = |
| 65 parentWidth - 2 * _signinPromoView.horizontalPadding; | 65 parentWidth - 2 * _signinPromoView.horizontalPadding; |
| 66 | 66 |
| 67 // Re-layout with the new preferred width to allow the label to adjust its | 67 // Re-layout with the new preferred width to allow the label to adjust its |
| 68 // height. | 68 // height. |
| 69 [super layoutSubviews]; | 69 [super layoutSubviews]; |
| 70 } | 70 } |
| 71 | 71 |
| 72 @end | 72 @end |
| OLD | NEW |