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/widget_extension/widget_view.h" | 5 #import "ios/chrome/widget_extension/widget_view.h" |
| 6 | 6 |
| 7 #if !defined(__has_feature) || !__has_feature(objc_arc) | 7 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 8 #error "This file requires ARC support." | 8 #error "This file requires ARC support." |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 @interface WidgetView () | |
| 12 | |
| 13 @property(nonatomic, weak) UIView* cursor; | |
| 14 | |
| 15 @end | |
| 16 | |
| 11 @implementation WidgetView | 17 @implementation WidgetView |
| 12 | 18 |
| 13 #pragma mark - Lifecycle | 19 @synthesize cursor = _cursor; |
| 14 | 20 |
| 15 - (instancetype)init { | 21 - (instancetype)init { |
| 16 self = [super initWithFrame:CGRectZero]; | 22 self = [super initWithFrame:CGRectZero]; |
| 23 if (self) { | |
| 24 [self addCursor]; | |
| 25 } | |
| 17 return self; | 26 return self; |
| 18 } | 27 } |
| 19 | 28 |
| 29 - (void)addCursor { | |
|
Olivier
2017/01/19 10:33:07
declare method and add comment.
Document that it s
lody
2017/01/19 13:17:55
Done.
| |
| 30 UIView* cursor = [[UIView alloc] initWithFrame:CGRectZero]; | |
|
Olivier
2017/01/19 10:33:07
Is the cursor added directly in the widget view?
S
lody
2017/01/19 13:17:55
Some of the current mocks say yes, some say no. I
| |
| 31 self.cursor = cursor; | |
| 32 self.cursor.backgroundColor = [UIColor blueColor]; | |
| 33 [self addSubview:_cursor]; | |
|
Olivier
2017/01/19 10:33:07
cursor or self.cursor
lody
2017/01/19 13:17:55
Done.
| |
| 34 | |
| 35 [self.cursor setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
| 36 [NSLayoutConstraint activateConstraints:@[ | |
| 37 [[self.cursor widthAnchor] constraintEqualToConstant:2], | |
| 38 [[self.cursor leadingAnchor] constraintEqualToAnchor:self.leadingAnchor | |
| 39 constant:40], | |
| 40 [[self.cursor heightAnchor] constraintEqualToConstant:40], | |
| 41 [[self.cursor centerYAnchor] constraintEqualToAnchor:self.centerYAnchor] | |
| 42 ]]; | |
| 43 | |
| 44 [UIView animateWithDuration:0.3 | |
| 45 delay:0.0 | |
| 46 options:UIViewAnimationOptionRepeat | | |
| 47 UIViewAnimationOptionAutoreverse | |
| 48 animations:^{ | |
| 49 self.cursor.alpha = 0.0f; | |
| 50 } | |
| 51 completion:nil]; | |
| 52 } | |
| 53 | |
| 20 @end | 54 @end |
| OLD | NEW |