OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.h" |
| 6 |
| 7 #import "ios/chrome/browser/ui/authentication/signin_promo_view.h" |
| 8 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 9 #include "ios/chrome/grit/ios_chromium_strings.h" |
| 10 #include "ui/base/l10n/l10n_util.h" |
| 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 16 @implementation BookmarkSigninPromoCell { |
| 17 SigninPromoView* _signinPromoView; |
| 18 } |
| 19 |
| 20 @synthesize signinPromoView = _signinPromoView; |
| 21 |
| 22 + (NSString*)reuseIdentifier { |
| 23 return @"BookmarkSigninPromoCell"; |
| 24 } |
| 25 |
| 26 + (BOOL)requiresConstraintBasedLayout { |
| 27 return YES; |
| 28 } |
| 29 |
| 30 - (instancetype)initWithFrame:(CGRect)frame { |
| 31 self = [super initWithFrame:frame]; |
| 32 if (self) { |
| 33 UIView* contentView = self.contentView; |
| 34 _signinPromoView = [[SigninPromoView alloc] initWithFrame:self.bounds]; |
| 35 _signinPromoView.translatesAutoresizingMaskIntoConstraints = NO; |
| 36 [contentView addSubview:_signinPromoView]; |
| 37 AddSameConstraints(_signinPromoView, contentView); |
| 38 _signinPromoView.backgroundColor = [UIColor whiteColor]; |
| 39 _signinPromoView.textLabel.text = |
| 40 l10n_util::GetNSString(IDS_IOS_SIGNIN_PROMO_SETTINGS); |
| 41 } |
| 42 return self; |
| 43 } |
| 44 |
| 45 - (void)layoutSubviews { |
| 46 // Adjust the text label preferredMaxLayoutWidth according self.frame.width, |
| 47 // so the text will adjust its height and not its width. |
| 48 CGFloat parentWidth = CGRectGetWidth(self.bounds); |
| 49 _signinPromoView.textLabel.preferredMaxLayoutWidth = |
| 50 parentWidth - 2 * _signinPromoView.horizontalPadding; |
| 51 |
| 52 // Re-layout with the new preferred width to allow the label to adjust its |
| 53 // height. |
| 54 [super layoutSubviews]; |
| 55 } |
| 56 |
| 57 @end |
OLD | NEW |