| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_promo_cell.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_promo_cell.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #import "base/mac/objc_property_releaser.h" | 10 #include "base/mac/objc_release_properties.h" |
| 11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
| 12 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" | 12 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" |
| 13 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 13 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 14 #import "ios/chrome/browser/ui/rtl_geometry.h" | 14 #import "ios/chrome/browser/ui/rtl_geometry.h" |
| 15 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 15 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 16 #include "ios/chrome/grit/ios_chromium_strings.h" | 16 #include "ios/chrome/grit/ios_chromium_strings.h" |
| 17 #include "ios/chrome/grit/ios_strings.h" | 17 #include "ios/chrome/grit/ios_strings.h" |
| 18 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" | 18 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
| 19 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 19 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 20 #import "ui/base/l10n/l10n_util_mac.h" | 20 #import "ui/base/l10n/l10n_util_mac.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // clang-format on | 144 // clang-format on |
| 145 ApplyVisualConstraintsWithMetricsAndOptions( | 145 ApplyVisualConstraintsWithMetricsAndOptions( |
| 146 constraints, views, metrics, LayoutOptionForRTLSupport(), self); | 146 constraints, views, metrics, LayoutOptionForRTLSupport(), self); |
| 147 AddSameCenterYConstraint(self, self.signInButton, self.dismissButton); | 147 AddSameCenterYConstraint(self, self.signInButton, self.dismissButton); |
| 148 } | 148 } |
| 149 [super updateConstraints]; | 149 [super updateConstraints]; |
| 150 } | 150 } |
| 151 | 151 |
| 152 @end | 152 @end |
| 153 | 153 |
| 154 @interface BookmarkPromoCell () { | 154 @interface BookmarkPromoCell () |
| 155 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkPromoCell; | |
| 156 } | |
| 157 @property(nonatomic, assign) BookmarkPromoView* promoView; | 155 @property(nonatomic, assign) BookmarkPromoView* promoView; |
| 158 @property(nonatomic, retain) NSArray* compactContentViewConstraints; | 156 @property(nonatomic, retain) NSArray* compactContentViewConstraints; |
| 159 @property(nonatomic, retain) NSArray* regularContentViewConstraints; | 157 @property(nonatomic, retain) NSArray* regularContentViewConstraints; |
| 160 @end | 158 @end |
| 161 | 159 |
| 162 @implementation BookmarkPromoCell | 160 @implementation BookmarkPromoCell |
| 163 | 161 |
| 164 @synthesize delegate = _delegate; | 162 @synthesize delegate = _delegate; |
| 165 @synthesize promoView = _promoView; | 163 @synthesize promoView = _promoView; |
| 166 @synthesize compactContentViewConstraints = _compactContentViewConstraints; | 164 @synthesize compactContentViewConstraints = _compactContentViewConstraints; |
| 167 @synthesize regularContentViewConstraints = _regularContentViewConstraints; | 165 @synthesize regularContentViewConstraints = _regularContentViewConstraints; |
| 168 | 166 |
| 169 + (NSString*)reuseIdentifier { | 167 + (NSString*)reuseIdentifier { |
| 170 return @"BookmarkPromoCell"; | 168 return @"BookmarkPromoCell"; |
| 171 } | 169 } |
| 172 | 170 |
| 173 + (BOOL)requiresConstraintBasedLayout { | 171 + (BOOL)requiresConstraintBasedLayout { |
| 174 return YES; | 172 return YES; |
| 175 } | 173 } |
| 176 | 174 |
| 177 - (instancetype)initWithFrame:(CGRect)frame { | 175 - (instancetype)initWithFrame:(CGRect)frame { |
| 178 self = [super initWithFrame:frame]; | 176 self = [super initWithFrame:frame]; |
| 179 if (self) { | 177 if (self) { |
| 180 _propertyReleaser_BookmarkPromoCell.Init(self, [BookmarkPromoCell class]); | |
| 181 self.contentView.translatesAutoresizingMaskIntoConstraints = NO; | 178 self.contentView.translatesAutoresizingMaskIntoConstraints = NO; |
| 182 | 179 |
| 183 _promoView = [[[BookmarkPromoView alloc] initWithFrame:frame] autorelease]; | 180 _promoView = [[[BookmarkPromoView alloc] initWithFrame:frame] autorelease]; |
| 184 [_promoView.signInButton addTarget:self | 181 [_promoView.signInButton addTarget:self |
| 185 action:@selector(signIn:) | 182 action:@selector(signIn:) |
| 186 forControlEvents:UIControlEventTouchUpInside]; | 183 forControlEvents:UIControlEventTouchUpInside]; |
| 187 [_promoView.dismissButton addTarget:self | 184 [_promoView.dismissButton addTarget:self |
| 188 action:@selector(dismiss:) | 185 action:@selector(dismiss:) |
| 189 forControlEvents:UIControlEventTouchUpInside]; | 186 forControlEvents:UIControlEventTouchUpInside]; |
| 190 _promoView.translatesAutoresizingMaskIntoConstraints = NO; | 187 _promoView.translatesAutoresizingMaskIntoConstraints = NO; |
| 191 [self.contentView addSubview:_promoView]; | 188 [self.contentView addSubview:_promoView]; |
| 192 [self updatePromoView]; | 189 [self updatePromoView]; |
| 193 } | 190 } |
| 194 return self; | 191 return self; |
| 195 } | 192 } |
| 196 | 193 |
| 194 - (void)dealloc { |
| 195 base::mac::ReleaseProperties(self); |
| 196 [super dealloc]; |
| 197 } |
| 198 |
| 197 - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { | 199 - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { |
| 198 [self updatePromoView]; | 200 [self updatePromoView]; |
| 199 } | 201 } |
| 200 | 202 |
| 201 - (void)updateConstraints { | 203 - (void)updateConstraints { |
| 202 if ([[self constraints] count] == 0) { | 204 if ([[self constraints] count] == 0) { |
| 203 NSArray* constraints = @[ @"H:|[contentView]|" ]; | 205 NSArray* constraints = @[ @"H:|[contentView]|" ]; |
| 204 NSDictionary* views = @{ @"contentView" : self.contentView }; | 206 NSDictionary* views = @{ @"contentView" : self.contentView }; |
| 205 ApplyVisualConstraintsWithMetricsAndOptions( | 207 ApplyVisualConstraintsWithMetricsAndOptions( |
| 206 constraints, views, nil, LayoutOptionForRTLSupport(), self); | 208 constraints, views, nil, LayoutOptionForRTLSupport(), self); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 283 |
| 282 - (void)signIn:(id)sender { | 284 - (void)signIn:(id)sender { |
| 283 [self.delegate bookmarkPromoCellDidTapSignIn:self]; | 285 [self.delegate bookmarkPromoCellDidTapSignIn:self]; |
| 284 } | 286 } |
| 285 | 287 |
| 286 - (void)dismiss:(id)sender { | 288 - (void)dismiss:(id)sender { |
| 287 [self.delegate bookmarkPromoCellDidTapDismiss:self]; | 289 [self.delegate bookmarkPromoCellDidTapDismiss:self]; |
| 288 } | 290 } |
| 289 | 291 |
| 290 @end | 292 @end |
| OLD | NEW |