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

Unified Diff: ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.mm

Issue 2838373002: Adding Sign-in promo for bookmark view. (Closed)
Patch Set: From CGFLOAT_MAX to 1000 Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.mm
diff --git a/ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.mm b/ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.mm
new file mode 100644
index 0000000000000000000000000000000000000000..14bbbf0deb0817dd97185432e8df641d57a86198
--- /dev/null
+++ b/ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.mm
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.h"
+
+#import "ios/chrome/browser/ui/authentication/signin_promo_view.h"
+#import "ios/chrome/browser/ui/uikit_ui_util.h"
+#include "ios/chrome/grit/ios_chromium_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@implementation BookmarkSigninPromoCell {
+ SigninPromoView* _signinPromoView;
+}
+
+@synthesize signinPromoView = _signinPromoView;
+
++ (NSString*)reuseIdentifier {
+ return @"BookmarkSigninPromoCell";
+}
+
++ (BOOL)requiresConstraintBasedLayout {
+ return YES;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ UIView* contentView = self.contentView;
+ _signinPromoView = [[SigninPromoView alloc] initWithFrame:self.bounds];
+ _signinPromoView.translatesAutoresizingMaskIntoConstraints = NO;
+ [contentView addSubview:_signinPromoView];
+ AddSameConstraints(_signinPromoView, contentView);
+ _signinPromoView.backgroundColor = [UIColor whiteColor];
+ _signinPromoView.textLabel.text =
+ l10n_util::GetNSString(IDS_IOS_SIGNIN_PROMO_SETTINGS);
+ }
+ return self;
+}
+
+- (void)layoutSubviews {
+ // Adjust the text label preferredMaxLayoutWidth according self.frame.width,
+ // so the text will adjust its height and not its width.
+ CGFloat parentWidth = CGRectGetWidth(self.bounds);
+ _signinPromoView.textLabel.preferredMaxLayoutWidth =
+ parentWidth - 2 * _signinPromoView.horizontalPadding;
+
+ // Re-layout with the new preferred width to allow the label to adjust its
+ // height.
+ [super layoutSubviews];
+}
+
+@end
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698