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/search_widget_extension/search_widget_view.h" | 5 #import "ios/chrome/search_widget_extension/search_widget_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) | 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." | 10 #error "This file requires ARC support." |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 const CGFloat kCursorHeight = 40; | 15 const CGFloat kContentMargin = 16; |
| 16 const CGFloat kCursorWidth = 2; | 16 const CGFloat kURLButtonMargin = 10; |
| 17 const CGFloat kCursorHorizontalPadding = 10; | 17 const CGFloat kActionButtonSize = 55; |
| 18 const CGFloat kCursorVerticalPadding = 10; | 18 const CGFloat kIconSize = 35; |
| 19 const CGFloat kFakeboxHorizontalPadding = 40; | 19 const CGFloat kMaxContentSize = 421; |
| 20 const CGFloat kFakeboxVerticalPadding = 40; | |
| 21 | 20 |
| 22 } // namespace | 21 } // namespace |
| 23 | 22 |
| 24 @interface SearchWidgetView () { | 23 @interface SearchWidgetView () { |
| 25 __weak id<SearchWidgetViewActionTarget> _target; | 24 __weak id<SearchWidgetViewActionTarget> _target; |
|
stkhapugin
2017/05/04 13:12:08
nit: Since this is your only ivar, convert it to a
lody
2017/05/05 17:05:44
Done.
| |
| 26 } | 25 } |
| 27 | 26 |
| 27 // The copied URL value. | |
|
stkhapugin
2017/05/04 13:12:08
This comment is confusing to someone who's reading
lody
2017/05/05 17:05:43
Done.
| |
| 28 @property(nonatomic, copy) NSString* copiedURL; | 28 @property(nonatomic, copy) NSString* copiedURL; |
| 29 // The copied URL label containing the URL or a placeholder text. | |
| 29 @property(nonatomic, strong) UILabel* copiedURLLabel; | 30 @property(nonatomic, strong) UILabel* copiedURLLabel; |
| 30 @property(nonatomic, weak) UIView* cursor; | 31 // The copued URL title label containing the title of the copied URL button. |
| 31 | 32 @property(nonatomic, strong) UILabel* openCopiedURLTitleLabel; |
| 32 // Creates and adds a fake omnibox with blinking cursor to the view and sets the | 33 // The hairline view shown between the action and copied URL views. |
| 33 // class cursor property. | 34 @property(nonatomic, strong) UIView* hairlineView; |
| 34 - (void)addFakebox; | 35 // The button shown when there is a copied URL to open. |
| 36 @property(nonatomic, strong) UIView* copiedButtonView; | |
| 37 // The primary effect view of the widget. Add views here for a more opaque | |
| 38 // appearance. | |
| 39 @property(nonatomic, strong) UIVisualEffectView* primaryEffectView; | |
| 40 // The secondary effect view of the widget. Add views here for a more | |
| 41 // transparent appearance. | |
| 42 @property(nonatomic, strong) UIVisualEffectView* secondaryEffectView; | |
| 43 // The constraints to be activated when the copiedURL section is visible. | |
| 44 @property(nonatomic, strong) | |
| 45 NSArray<NSLayoutConstraint*>* visibleCopiedURLConstraints; | |
| 46 // The constraints to be activated when the copiedURL section is hidden. | |
| 47 @property(nonatomic, strong) | |
| 48 NSArray<NSLayoutConstraint*>* hiddenCopiedURLConstraints; | |
| 49 | |
| 50 // Sets up the widget UI. | |
| 51 - (void)createUI; | |
| 52 | |
| 53 // Creates the view for the action buttons. | |
|
stkhapugin
2017/05/04 13:12:09
Depending on your class comment's descriptiveness,
lody
2017/05/05 17:05:43
Acknowledged.
| |
| 54 - (UIView*)createActionsView: | |
|
stkhapugin
2017/05/04 13:12:08
This should be:
- (UIView*)newActionsView;
(you
lody
2017/05/05 17:05:43
Done.
| |
| 55 (NSMutableArray<NSLayoutConstraint*>*)constraintArray; | |
| 56 | |
| 57 // Creates the view for the copiedURL section. | |
| 58 - (void)createOpenCopiedURLView:(NSLayoutAnchor*)topAnchor | |
|
stkhapugin
2017/05/04 13:12:09
This method must return a UIView. Also, if you nee
lody
2017/05/05 17:05:43
This does not create a single view, so returning o
| |
| 59 constraintArray: | |
| 60 (NSMutableArray<NSLayoutConstraint*>*)constraintArray; | |
| 35 | 61 |
| 36 @end | 62 @end |
| 37 | 63 |
| 38 @implementation SearchWidgetView | 64 @implementation SearchWidgetView |
| 39 | 65 |
| 66 @synthesize copiedURLVisible = _copiedURLVisible; | |
| 40 @synthesize copiedURL = _copiedURL; | 67 @synthesize copiedURL = _copiedURL; |
| 41 @synthesize copiedURLLabel = _copiedURLLabel; | 68 @synthesize copiedURLLabel = _copiedURLLabel; |
| 42 | 69 @synthesize openCopiedURLTitleLabel = _openCopiedURLTitleLabel; |
| 43 @synthesize cursor = _cursor; | 70 @synthesize hairlineView = _hairlineView; |
| 44 | 71 @synthesize copiedButtonView = _copiedButtonView; |
| 45 - (instancetype)initWithActionTarget:(id<SearchWidgetViewActionTarget>)target { | 72 @synthesize primaryEffectView = _primaryEffectView; |
| 73 @synthesize secondaryEffectView = _secondaryEffectView; | |
| 74 @synthesize visibleCopiedURLConstraints = _visibleCopiedURLConstraints; | |
| 75 @synthesize hiddenCopiedURLConstraints = _hiddenCopiedURLConstraints; | |
| 76 | |
| 77 - (void)setCopiedURLVisible:(BOOL)copiedURLVisible { | |
|
stkhapugin
2017/05/04 13:12:09
This should be below initWith...
lody
2017/05/05 17:05:43
Done.
| |
| 78 _copiedURLVisible = copiedURLVisible; | |
| 79 [self updateCopiedURLUI]; | |
| 80 } | |
| 81 | |
| 82 - (instancetype)initWithActionTarget:(id<SearchWidgetViewActionTarget>)target | |
| 83 primaryVibrancyEffect:(UIVibrancyEffect*)primaryVibrancyEffect | |
| 84 secondaryVibrancyEffect: | |
| 85 (UIVibrancyEffect*)secondaryVibrancyEffect { | |
| 46 self = [super initWithFrame:CGRectZero]; | 86 self = [super initWithFrame:CGRectZero]; |
| 47 if (self) { | 87 if (self) { |
| 48 DCHECK(target); | 88 DCHECK(target); |
| 49 _target = target; | 89 _target = target; |
| 50 [self addFakebox]; | 90 _primaryEffectView = |
| 91 [[UIVisualEffectView alloc] initWithEffect:primaryVibrancyEffect]; | |
| 92 _secondaryEffectView = | |
| 93 [[UIVisualEffectView alloc] initWithEffect:secondaryVibrancyEffect]; | |
| 94 _copiedURLVisible = YES; | |
| 95 [self createUI]; | |
| 96 [self updateCopiedURLUI]; | |
| 51 } | 97 } |
| 52 return self; | 98 return self; |
| 53 } | 99 } |
| 54 | 100 |
| 55 - (void)addFakebox { | 101 - (void)createUI { |
| 56 UIView* fakebox = [[UIView alloc] initWithFrame:CGRectZero]; | 102 // Views added to different effect views need to be constrained to each other. |
| 57 | 103 // This is made easier by putting all the constraints into an array and |
| 104 // activating them all at once after adding all the views. | |
| 105 NSMutableArray<NSLayoutConstraint*>* constraintArray = [NSMutableArray array]; | |
|
stkhapugin
2017/05/04 13:12:08
This potentially gives you a small performance bum
lody
2017/05/05 17:05:43
As discussed, the passing around of constraints is
| |
| 106 | |
| 107 for (UIVisualEffectView* effectView in | |
| 108 @[ self.primaryEffectView, self.secondaryEffectView ]) { | |
|
stkhapugin
2017/05/04 13:12:09
Please make this array a local variable for improv
lody
2017/05/05 17:05:44
(indentation is good, eyeballs are less good as se
| |
| 109 [self addSubview:effectView]; | |
| 110 effectView.translatesAutoresizingMaskIntoConstraints = NO; | |
| 111 | |
| 112 [constraintArray addObjectsFromArray:@[ | |
|
stkhapugin
2017/05/04 13:12:08
There's a helper for this.
lody
2017/05/05 17:05:44
Done.
| |
| 113 [self.leadingAnchor constraintEqualToAnchor:effectView.leadingAnchor], | |
| 114 [self.trailingAnchor constraintEqualToAnchor:effectView.trailingAnchor], | |
| 115 [self.topAnchor constraintEqualToAnchor:effectView.topAnchor], | |
| 116 [self.bottomAnchor constraintEqualToAnchor:effectView.bottomAnchor] | |
| 117 ]]; | |
| 118 } | |
| 119 | |
| 120 UIView* actionsView = [self createActionsView:constraintArray]; | |
| 121 | |
| 122 [self createOpenCopiedURLView:actionsView.bottomAnchor | |
| 123 constraintArray:constraintArray]; | |
| 124 | |
| 125 [NSLayoutConstraint activateConstraints:constraintArray]; | |
| 126 } | |
| 127 | |
| 128 - (UIView*)createActionsView: | |
| 129 (NSMutableArray<NSLayoutConstraint*>*)constraintArray { | |
| 130 UIStackView* actionRow = [[UIStackView alloc] initWithArrangedSubviews:@[ | |
| 131 [self createActionView:@"New Search" | |
| 132 imageName:@"quick_action_search" | |
| 133 actionSelector:@selector(openSearch:) | |
| 134 constraintArray:constraintArray], | |
| 135 [self createActionView:@"Incognito Search" | |
| 136 imageName:@"quick_action_incognito_search" | |
| 137 actionSelector:@selector(openIncognito:) | |
| 138 constraintArray:constraintArray], | |
| 139 [self createActionView:@"Voice Search" | |
| 140 imageName:@"quick_action_voice_search" | |
| 141 actionSelector:@selector(openVoice:) | |
| 142 constraintArray:constraintArray], | |
| 143 [self createActionView:@"Scan QR/Bar Code" | |
| 144 imageName:@"quick_action_camera_search" | |
| 145 actionSelector:@selector(openQRCode:) | |
| 146 constraintArray:constraintArray], | |
| 147 ]]; | |
| 148 | |
| 149 actionRow.axis = UILayoutConstraintAxisHorizontal; | |
| 150 actionRow.alignment = UIStackViewAlignmentCenter; | |
| 151 actionRow.distribution = UIStackViewDistributionEqualSpacing; | |
| 152 actionRow.layoutMargins = | |
| 153 UIEdgeInsetsMake(0, kContentMargin, 0, kContentMargin); | |
| 154 actionRow.layoutMarginsRelativeArrangement = YES; | |
| 155 actionRow.translatesAutoresizingMaskIntoConstraints = NO; | |
| 156 | |
| 157 [self.secondaryEffectView.contentView addSubview:actionRow]; | |
| 158 | |
| 159 // These constraints stretch the action row to the full width of the widget. | |
| 160 // Their priority is < UILayoutPriorityRequired so that they can break when | |
| 161 // the view is larger than kMaxContentSize. | |
| 162 NSLayoutConstraint* actionsLeftConstraint = [actionRow.leftAnchor | |
| 163 constraintEqualToAnchor:self.secondaryEffectView.leftAnchor]; | |
| 164 actionsLeftConstraint.priority = UILayoutPriorityDefaultHigh; | |
| 165 | |
| 166 NSLayoutConstraint* actionsRightConstraint = [actionRow.rightAnchor | |
| 167 constraintEqualToAnchor:self.secondaryEffectView.rightAnchor]; | |
| 168 actionsRightConstraint.priority = UILayoutPriorityDefaultHigh; | |
| 169 | |
| 170 // This constraint sets the top alignment for the action row. Its priority is | |
| 171 // < UILayoutPriorityRequired so that it can break in favor of the | |
| 172 // centerYAnchor rule (on the next line) when the copiedURL section is hidden. | |
| 173 NSLayoutConstraint* actionsTopConstraint = [actionRow.topAnchor | |
| 174 constraintEqualToAnchor:self.secondaryEffectView.topAnchor | |
| 175 constant:kContentMargin]; | |
| 176 actionsTopConstraint.priority = UILayoutPriorityDefaultHigh; | |
| 177 | |
| 178 self.hiddenCopiedURLConstraints = @[ [actionRow.centerYAnchor | |
| 179 constraintEqualToAnchor:self.secondaryEffectView.centerYAnchor] ]; | |
| 180 | |
| 181 [constraintArray addObjectsFromArray:@[ | |
| 182 [actionRow.centerXAnchor | |
| 183 constraintEqualToAnchor:self.secondaryEffectView.centerXAnchor], | |
| 184 [actionRow.widthAnchor constraintLessThanOrEqualToConstant:kMaxContentSize], | |
| 185 actionsLeftConstraint, | |
| 186 actionsRightConstraint, | |
| 187 actionsTopConstraint, | |
| 188 ]]; | |
| 189 | |
| 190 return actionRow; | |
| 191 } | |
| 192 | |
| 193 - (UIView*)createActionView:(NSString*)title | |
|
stkhapugin
2017/05/04 13:12:09
This name should be:
newActionViewWithTitle: imag
lody
2017/05/05 17:05:43
Done.
| |
| 194 imageName:(NSString*)imageName | |
| 195 actionSelector:(SEL)actionSelector | |
| 196 constraintArray: | |
| 197 (NSMutableArray<NSLayoutConstraint*>*)constraintArray { | |
| 198 UIView* circleView = [[UIView alloc] initWithFrame:CGRectZero]; | |
| 199 circleView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.05]; | |
| 200 circleView.layer.cornerRadius = kActionButtonSize / 2; | |
| 201 | |
| 202 [constraintArray addObjectsFromArray:@[ | |
| 203 [circleView.widthAnchor constraintEqualToConstant:kActionButtonSize], | |
| 204 [circleView.heightAnchor constraintEqualToConstant:kActionButtonSize] | |
| 205 ]]; | |
| 206 | |
| 207 UILabel* labelView = [[UILabel alloc] initWithFrame:CGRectZero]; | |
| 208 labelView.text = title; | |
|
stkhapugin
2017/05/04 13:12:09
l10n?
lody
2017/05/05 17:05:43
Acknowledged.
| |
| 209 labelView.numberOfLines = 2; | |
|
stkhapugin
2017/05/04 13:12:09
also l10n?
lody
2017/05/05 17:05:43
Acknowledged.
| |
| 210 labelView.textAlignment = NSTextAlignmentCenter; | |
| 211 labelView.font = [UIFont systemFontOfSize:UIFont.smallSystemFontSize]; | |
|
stkhapugin
2017/05/04 13:12:09
Does this work with gigantic dynamic type?
lody
2017/05/05 17:05:43
whoops, used the wrong api. It looks good now, I t
| |
| 212 [labelView | |
| 213 setContentCompressionResistancePriority:UILayoutPriorityRequired | |
| 214 forAxis:UILayoutConstraintAxisVertical]; | |
| 215 | |
| 216 UIStackView* stack = | |
| 217 [[UIStackView alloc] initWithArrangedSubviews:@[ circleView, labelView ]]; | |
| 218 stack.axis = UILayoutConstraintAxisVertical; | |
| 219 stack.spacing = 5; | |
|
stkhapugin
2017/05/04 13:12:09
make a constant
lody
2017/05/05 17:05:43
Done.
| |
| 220 stack.translatesAutoresizingMaskIntoConstraints = NO; | |
| 221 [self addTapAction:actionSelector toView:stack]; | |
|
stkhapugin
2017/05/04 13:12:08
Create a transparent UIButton and constrain to |st
lody
2017/05/05 17:05:44
Done.
| |
| 222 | |
| 223 UIImage* iconImage = [UIImage imageNamed:imageName]; | |
| 224 UIImageView* icon = [[UIImageView alloc] initWithImage:iconImage]; | |
| 225 icon.translatesAutoresizingMaskIntoConstraints = NO; | |
| 226 | |
| 227 [constraintArray addObjectsFromArray:@[ | |
| 228 [icon.widthAnchor constraintEqualToConstant:kIconSize], | |
| 229 [icon.heightAnchor constraintEqualToConstant:kIconSize], | |
| 230 [icon.centerXAnchor constraintEqualToAnchor:circleView.centerXAnchor], | |
| 231 [icon.centerYAnchor constraintEqualToAnchor:circleView.centerYAnchor], | |
| 232 ]]; | |
| 233 [self.primaryEffectView.contentView addSubview:icon]; | |
| 234 | |
| 235 return stack; | |
| 236 } | |
| 237 | |
| 238 - (void)createOpenCopiedURLView:(NSLayoutAnchor*)topAnchor | |
| 239 constraintArray: | |
| 240 (NSMutableArray<NSLayoutConstraint*>*)constraintArray { | |
| 241 self.hairlineView = [[UIView alloc] initWithFrame:CGRectZero]; | |
| 242 self.hairlineView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.05]; | |
| 243 self.hairlineView.translatesAutoresizingMaskIntoConstraints = NO; | |
| 244 [self.secondaryEffectView.contentView addSubview:self.hairlineView]; | |
| 245 | |
| 246 self.copiedButtonView = [[UIView alloc] initWithFrame:CGRectZero]; | |
|
stkhapugin
2017/05/04 13:12:08
Just make this a UIButton to avoid having a gestur
lody
2017/05/05 17:05:43
Done.
| |
| 247 self.copiedButtonView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.05]; | |
| 248 self.copiedButtonView.layer.cornerRadius = 5; | |
| 249 self.copiedButtonView.translatesAutoresizingMaskIntoConstraints = NO; | |
| 250 [self.secondaryEffectView.contentView addSubview:self.copiedButtonView]; | |
| 251 [self addTapAction:@selector(openCopiedURL:) toView:self.copiedButtonView]; | |
| 252 | |
| 253 self.openCopiedURLTitleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | |
| 254 self.openCopiedURLTitleLabel.textAlignment = NSTextAlignmentCenter; | |
| 255 self.openCopiedURLTitleLabel.translatesAutoresizingMaskIntoConstraints = NO; | |
| 256 self.openCopiedURLTitleLabel.font = [UIFont boldSystemFontOfSize:16]; | |
| 257 [self.primaryEffectView.contentView addSubview:self.openCopiedURLTitleLabel]; | |
| 258 | |
| 259 self.copiedURLLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | |
| 260 self.copiedURLLabel.textAlignment = NSTextAlignmentCenter; | |
| 261 self.copiedURLLabel.font = | |
| 262 [UIFont systemFontOfSize:UIFont.smallSystemFontSize]; | |
| 263 self.copiedURLLabel.translatesAutoresizingMaskIntoConstraints = NO; | |
| 264 [self.secondaryEffectView.contentView addSubview:self.copiedURLLabel]; | |
| 265 | |
| 266 // | |
| 267 // NSLayoutConstraint* hairlineTopAnchor = | |
|
stkhapugin
2017/05/04 13:12:09
remove
lody
2017/05/05 17:05:43
Done.
| |
| 268 // ; | |
| 269 // hairlineTopAnchor.priority = UILayoutPriorityDefaultHigh; | |
| 270 | |
| 271 self.visibleCopiedURLConstraints = @[ | |
| 272 [self.hairlineView.topAnchor constraintEqualToAnchor:topAnchor | |
| 273 constant:kContentMargin], | |
| 274 [self.hairlineView.leftAnchor | |
| 275 constraintEqualToAnchor:self.secondaryEffectView.leftAnchor], | |
| 276 [self.hairlineView.rightAnchor | |
| 277 constraintEqualToAnchor:self.secondaryEffectView.rightAnchor], | |
| 278 [self.hairlineView.heightAnchor constraintEqualToConstant:0.5], | |
| 279 | |
| 280 [self.copiedButtonView.centerXAnchor | |
| 281 constraintEqualToAnchor:self.secondaryEffectView.centerXAnchor], | |
| 282 [self.copiedButtonView.widthAnchor | |
| 283 constraintEqualToAnchor:self.secondaryEffectView.widthAnchor | |
| 284 constant:-2 * kContentMargin], | |
| 285 [self.copiedButtonView.topAnchor | |
| 286 constraintEqualToAnchor:self.hairlineView.bottomAnchor | |
| 287 constant:12], | |
| 288 [self.copiedButtonView.bottomAnchor | |
| 289 constraintEqualToAnchor:self.secondaryEffectView.bottomAnchor | |
| 290 constant:-kContentMargin], | |
| 291 | |
| 292 [self.openCopiedURLTitleLabel.centerXAnchor | |
| 293 constraintEqualToAnchor:self.primaryEffectView.centerXAnchor], | |
| 294 [self.openCopiedURLTitleLabel.topAnchor | |
| 295 constraintEqualToAnchor:self.copiedButtonView.topAnchor | |
| 296 constant:kURLButtonMargin], | |
| 297 [self.openCopiedURLTitleLabel.widthAnchor | |
| 298 constraintEqualToAnchor:self.copiedButtonView.widthAnchor | |
| 299 constant:-kContentMargin * 2], | |
| 300 | |
| 301 [self.copiedURLLabel.centerXAnchor | |
| 302 constraintEqualToAnchor:self.primaryEffectView.centerXAnchor], | |
| 303 [self.copiedURLLabel.topAnchor | |
| 304 constraintEqualToAnchor:self.openCopiedURLTitleLabel.bottomAnchor], | |
| 305 [self.copiedURLLabel.widthAnchor | |
| 306 constraintEqualToAnchor:self.openCopiedURLTitleLabel.widthAnchor], | |
| 307 [self.copiedURLLabel.bottomAnchor | |
| 308 constraintEqualToAnchor:self.copiedButtonView.bottomAnchor | |
| 309 constant:-kURLButtonMargin], | |
| 310 ]; | |
| 311 } | |
| 312 | |
| 313 - (void)addTapAction:(SEL)action toView:(UIView*)view { | |
|
stkhapugin
2017/05/04 13:12:08
With two comments above, you'll no longer need thi
lody
2017/05/05 17:05:43
Done.
| |
| 58 UIGestureRecognizer* tapRecognizer = | 314 UIGestureRecognizer* tapRecognizer = |
| 59 [[UITapGestureRecognizer alloc] initWithTarget:_target | 315 [[UITapGestureRecognizer alloc] initWithTarget:_target action:action]; |
| 60 action:@selector(openSearch:)]; | 316 [view addGestureRecognizer:tapRecognizer]; |
| 61 | 317 } |
| 62 [fakebox addGestureRecognizer:tapRecognizer]; | 318 |
| 63 [self addSubview:fakebox]; | 319 - (void)updateCopiedURLUI { |
| 64 | 320 // If the copiedURL section is not visible, hide all the copiedURL section |
|
stkhapugin
2017/05/04 13:12:09
All of this logic belongs to controller layer, not
lody
2017/05/05 17:05:43
As seen offline, this is tbd.
| |
| 65 UIView* cursor = [[UIView alloc] initWithFrame:CGRectZero]; | 321 // views and activate the correct constraint set. If it is visible, show the |
| 66 self.cursor = cursor; | 322 // views in function of whether there is or not a copied URL to show. |
| 67 self.cursor.backgroundColor = [UIColor blueColor]; | 323 |
| 68 [fakebox addSubview:self.cursor]; | 324 if (!self.copiedURLVisible) { |
| 69 | 325 self.copiedURLLabel.hidden = YES; |
| 70 [fakebox setTranslatesAutoresizingMaskIntoConstraints:NO]; | 326 self.openCopiedURLTitleLabel.hidden = YES; |
| 71 [self.cursor setTranslatesAutoresizingMaskIntoConstraints:NO]; | 327 self.hairlineView.hidden = YES; |
| 72 [NSLayoutConstraint activateConstraints:@[ | 328 self.copiedButtonView.hidden = YES; |
| 73 [[fakebox leadingAnchor] constraintEqualToAnchor:self.leadingAnchor | 329 [NSLayoutConstraint deactivateConstraints:self.visibleCopiedURLConstraints]; |
| 74 constant:kFakeboxHorizontalPadding], | 330 [NSLayoutConstraint activateConstraints:self.hiddenCopiedURLConstraints]; |
| 75 [[fakebox trailingAnchor] | 331 return; |
| 76 constraintEqualToAnchor:self.trailingAnchor | 332 } |
| 77 constant:-kFakeboxHorizontalPadding], | 333 |
| 78 [[fakebox topAnchor] constraintEqualToAnchor:self.topAnchor | 334 self.copiedURLLabel.hidden = NO; |
| 79 constant:kFakeboxVerticalPadding], | 335 self.openCopiedURLTitleLabel.hidden = NO; |
| 80 [[fakebox heightAnchor] | 336 |
| 81 constraintEqualToConstant:kCursorHeight + 2 * kCursorVerticalPadding], | 337 [NSLayoutConstraint deactivateConstraints:self.hiddenCopiedURLConstraints]; |
| 82 | 338 [NSLayoutConstraint activateConstraints:self.visibleCopiedURLConstraints]; |
| 83 [[self.cursor widthAnchor] constraintEqualToConstant:kCursorWidth], | 339 |
| 84 [[self.cursor leadingAnchor] | 340 if (self.copiedURL) { |
| 85 constraintEqualToAnchor:fakebox.leadingAnchor | 341 self.copiedButtonView.hidden = NO; |
| 86 constant:kCursorHorizontalPadding], | 342 self.hairlineView.hidden = YES; |
| 87 [[self.cursor heightAnchor] constraintEqualToConstant:kCursorHeight], | 343 self.copiedURLLabel.text = self.copiedURL; |
| 88 [[self.cursor centerYAnchor] constraintEqualToAnchor:fakebox.centerYAnchor] | 344 self.openCopiedURLTitleLabel.alpha = 1; |
| 89 ]]; | 345 self.openCopiedURLTitleLabel.text = @"Open Copied Link"; |
|
stkhapugin
2017/05/04 13:12:08
localization?
lody
2017/05/05 17:05:43
I knew something was missing from the list of "thi
| |
| 90 | 346 self.copiedURLLabel.alpha = 1; |
| 91 [UIView animateWithDuration:0.3 | 347 return; |
| 92 delay:0.0 | 348 } |
| 93 options:UIViewAnimationOptionRepeat | | 349 |
| 94 UIViewAnimationOptionAutoreverse | 350 self.copiedButtonView.hidden = YES; |
| 95 animations:^{ | 351 self.hairlineView.hidden = NO; |
| 96 self.cursor.alpha = 0.0f; | 352 self.copiedURLLabel.text = @"Links you copy will appear here."; |
|
stkhapugin
2017/05/04 13:12:09
l10n?
lody
2017/05/05 17:05:43
Acknowledged.
| |
| 97 } | 353 self.openCopiedURLTitleLabel.alpha = 0.5; |
| 98 completion:nil]; | 354 self.openCopiedURLTitleLabel.text = @"No Copied Link"; |
|
stkhapugin
2017/05/04 13:12:09
l10n
lody
2017/05/05 17:05:43
Acknowledged.
| |
| 355 self.copiedURLLabel.alpha = 0.5; | |
| 99 } | 356 } |
| 100 | 357 |
| 101 - (void)updateCopiedURL:(NSString*)copiedURL { | 358 - (void)updateCopiedURL:(NSString*)copiedURL { |
| 102 self.copiedURL = copiedURL; | 359 self.copiedURL = copiedURL; |
| 103 self.copiedURLLabel.text = copiedURL; | 360 [self updateCopiedURLUI]; |
| 104 } | 361 } |
| 105 | |
| 106 @end | 362 @end |
| OLD | NEW |