Chromium Code Reviews| 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/bookmarks/bookmark_signin_promo_cell.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.h" |
| 6 | 6 |
| 7 #import "MDCFlatButton.h" | |
|
lpromero
2017/05/23 12:06:16
This works? Weird.
#import "ios/third_party/.../Ma
jlebel
2017/05/23 12:43:26
Done.
| |
| 7 #import "ios/chrome/browser/ui/authentication/signin_promo_view.h" | 8 #import "ios/chrome/browser/ui/authentication/signin_promo_view.h" |
| 8 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 9 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 9 #include "ios/chrome/grit/ios_chromium_strings.h" | 10 #include "ios/chrome/grit/ios_chromium_strings.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 11 | 12 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." | 14 #error "This file requires ARC support." |
| 14 #endif | 15 #endif |
| 15 | 16 |
| 16 namespace { | |
| 17 // Close button size. | |
| 18 const CGFloat kCloseButtonSize = 24; | |
| 19 } | |
| 20 | |
| 21 @implementation BookmarkSigninPromoCell { | 17 @implementation BookmarkSigninPromoCell { |
| 22 SigninPromoView* _signinPromoView; | 18 SigninPromoView* _signinPromoView; |
| 23 UIButton* _closeButton; | 19 UIButton* _closeButton; |
| 24 } | 20 } |
| 25 | 21 |
| 26 @synthesize signinPromoView = _signinPromoView; | 22 @synthesize signinPromoView = _signinPromoView; |
| 27 @synthesize closeButtonAction = _closeButtonAction; | 23 @synthesize closeButtonAction = _closeButtonAction; |
| 28 | 24 |
| 29 + (NSString*)reuseIdentifier { | 25 + (NSString*)reuseIdentifier { |
| 30 return @"BookmarkSigninPromoCell"; | 26 return @"BookmarkSigninPromoCell"; |
| 31 } | 27 } |
| 32 | 28 |
| 33 + (BOOL)requiresConstraintBasedLayout { | 29 + (BOOL)requiresConstraintBasedLayout { |
| 34 return YES; | 30 return YES; |
| 35 } | 31 } |
| 36 | 32 |
| 37 - (instancetype)initWithFrame:(CGRect)frame { | 33 - (instancetype)initWithFrame:(CGRect)frame { |
| 38 self = [super initWithFrame:frame]; | 34 self = [super initWithFrame:frame]; |
| 39 if (self) { | 35 if (self) { |
| 40 UIView* contentView = self.contentView; | 36 UIView* contentView = self.contentView; |
| 41 _signinPromoView = [[SigninPromoView alloc] initWithFrame:self.bounds]; | 37 _signinPromoView = [[SigninPromoView alloc] initWithFrame:self.bounds]; |
| 42 _signinPromoView.translatesAutoresizingMaskIntoConstraints = NO; | 38 _signinPromoView.translatesAutoresizingMaskIntoConstraints = NO; |
| 43 [contentView addSubview:_signinPromoView]; | 39 [contentView addSubview:_signinPromoView]; |
| 44 AddSameConstraints(_signinPromoView, contentView); | 40 AddSameConstraints(_signinPromoView, contentView); |
| 45 | 41 |
| 46 _closeButton = [[UIButton alloc] | 42 [_signinPromoView.closeButton addTarget:self |
| 47 initWithFrame:CGRectMake(0, 0, kCloseButtonSize, kCloseButtonSize)]; | 43 action:@selector(closeButtonAction:) |
| 48 [_closeButton addTarget:self | 44 forControlEvents:UIControlEventTouchUpInside]; |
| 49 action:@selector(closeButtonAction:) | 45 _signinPromoView.closeButton.hidden = NO; |
| 50 forControlEvents:UIControlEventTouchUpInside]; | 46 // [_signinPromoView addSubview:_closeButton]; |
|
lpromero
2017/05/23 12:06:16
Please clean up.
jlebel
2017/05/23 12:43:26
Done.
| |
| 51 _closeButton.translatesAutoresizingMaskIntoConstraints = NO; | 47 // [_closeButton setImage:[UIImage imageNamed:@"signin_promo_close_gray"] |
| 52 [contentView addSubview:_closeButton]; | 48 // forState:UIControlStateNormal]; |
| 53 [_closeButton setImage:[UIImage imageNamed:@"signin_promo_close_gray"] | 49 // NSArray* buttonVisualConstraints = |
| 54 forState:UIControlStateNormal]; | 50 // @[ @"H:[closeButton]-|", @"V:|-[closeButton]" ]; |
| 55 NSArray* buttonVisualConstraints = | 51 // NSDictionary* views = @{ @"closeButton" : _closeButton }; |
| 56 @[ @"H:[closeButton]-|", @"V:|-[closeButton]" ]; | 52 // ApplyVisualConstraints(buttonVisualConstraints, views); |
| 57 NSDictionary* views = @{ @"closeButton" : _closeButton }; | |
| 58 ApplyVisualConstraints(buttonVisualConstraints, views); | |
| 59 | 53 |
| 60 _signinPromoView.backgroundColor = [UIColor whiteColor]; | 54 _signinPromoView.backgroundColor = [UIColor whiteColor]; |
| 61 _signinPromoView.textLabel.text = | 55 _signinPromoView.textLabel.text = |
| 62 l10n_util::GetNSString(IDS_IOS_SIGNIN_PROMO_BOOKMARKS); | 56 l10n_util::GetNSString(IDS_IOS_SIGNIN_PROMO_BOOKMARKS); |
| 63 } | 57 } |
| 64 return self; | 58 return self; |
| 65 } | 59 } |
| 66 | 60 |
| 67 - (void)layoutSubviews { | 61 - (void)layoutSubviews { |
| 68 // Adjust the text label preferredMaxLayoutWidth according self.frame.width, | 62 // Adjust the text label preferredMaxLayoutWidth according self.frame.width, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 81 _signinPromoView.delegate = nil; | 75 _signinPromoView.delegate = nil; |
| 82 } | 76 } |
| 83 | 77 |
| 84 - (void)closeButtonAction:(id)sender { | 78 - (void)closeButtonAction:(id)sender { |
| 85 if (_closeButtonAction) { | 79 if (_closeButtonAction) { |
| 86 _closeButtonAction(); | 80 _closeButtonAction(); |
| 87 } | 81 } |
| 88 } | 82 } |
| 89 | 83 |
| 90 @end | 84 @end |
| OLD | NEW |